aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/expression.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 02:55:38 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 02:55:38 -0400
commitc222d406b09de529388fcd248476e9ae258895b8 (patch)
tree9cfcc6ee29e4e88757a91f572283c714115cb6e3 /nexgb/xgbgen/expression.go
parenta5d4ad6c9d763b3d3f797075038023756c38bb28 (diff)
downloadhaven-c222d406b09de529388fcd248476e9ae258895b8.tar.gz
haven-c222d406b09de529388fcd248476e9ae258895b8.tar.xz
haven-c222d406b09de529388fcd248476e9ae258895b8.zip
converting to new reply/cookie scheme
Diffstat (limited to 'nexgb/xgbgen/expression.go')
-rw-r--r--nexgb/xgbgen/expression.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go
index 12bcb19..6a8aa52 100644
--- a/nexgb/xgbgen/expression.go
+++ b/nexgb/xgbgen/expression.go
@@ -158,6 +158,33 @@ func (e *UnaryOp) Initialize(p *Protocol) {
e.Expr.Initialize(p)
}
+type Padding struct {
+ Expr Expression
+}
+
+func (e *Padding) Concrete() bool {
+ return e.Expr.Concrete()
+}
+
+func (e *Padding) Eval() uint {
+ return uint(pad(int(e.Expr.Eval())))
+}
+
+func (e *Padding) Reduce(prefix string) string {
+ if e.Concrete() {
+ return fmt.Sprintf("%d", e.Eval())
+ }
+ return fmt.Sprintf("pad(%s)", e.Expr.Reduce(prefix))
+}
+
+func (e *Padding) String() string {
+ return e.Reduce("")
+}
+
+func (e *Padding) Initialize(p *Protocol) {
+ e.Expr.Initialize(p)
+}
+
type PopCount struct {
Expr Expression
}