summaryrefslogtreecommitdiff
path: root/xgbgen/expression.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <[email protected]>2012-05-05 02:55:38 -0400
committerAndrew Gallant (Ocelot) <[email protected]>2012-05-05 02:55:38 -0400
commit6ed03adaa17357113a6dd58de54e057b1256a012 (patch)
tree02fde0eb2840a1e44f39ca82d2e684084bd7c1c2 /xgbgen/expression.go
parent9f44c6226003c93fd8a43bc0e35b433325c894eb (diff)
converting to new reply/cookie scheme
Diffstat (limited to 'xgbgen/expression.go')
-rw-r--r--xgbgen/expression.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/xgbgen/expression.go b/xgbgen/expression.go
index 12bcb19..6a8aa52 100644
--- a/xgbgen/expression.go
+++ b/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
}