aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/field.go
diff options
context:
space:
mode:
Diffstat (limited to 'nexgb/xgbgen/field.go')
-rw-r--r--nexgb/xgbgen/field.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go
index 0f2323e..6d39af2 100644
--- a/nexgb/xgbgen/field.go
+++ b/nexgb/xgbgen/field.go
@@ -9,6 +9,7 @@ type Field interface {
Initialize(p *Protocol)
SrcName() string
XmlName() string
+ SrcType() string
Size() Size
Define(c *Context)
@@ -30,6 +31,10 @@ func (p *PadField) XmlName() string {
panic("illegal to take XML name of a pad field")
}
+func (f *PadField) SrcType() string {
+ panic("it is illegal to call SrcType on a SwitchField field")
+}
+
func (p *PadField) Size() Size {
return newFixedSize(p.Bytes)
}
@@ -53,6 +58,10 @@ func (f *SingleField) XmlName() string {
return f.xmlName
}
+func (f *SingleField) SrcType() string {
+ return f.Type.SrcName()
+}
+
func (f *SingleField) Size() Size {
return f.Type.Size()
}
@@ -72,9 +81,9 @@ func (f *ListField) XmlName() string {
return f.xmlName
}
-// func (f *ListField) Size() Size {
- // return newExpressionSize(f.LengthExpr).Multiply(f.Type.Size())
-// }
+func (f *ListField) SrcType() string {
+ return fmt.Sprintf("[]%s", f.Type.SrcName())
+}
func (f *ListField) Size() Size {
simpleLen := &Function{
@@ -126,6 +135,10 @@ func (f *ExprField) XmlName() string {
return f.xmlName
}
+func (f *ExprField) SrcType() string {
+ return f.Type.SrcName()
+}
+
func (f *ExprField) Size() Size {
return f.Type.Size()
}
@@ -150,6 +163,10 @@ func (f *ValueField) XmlName() string {
panic("it is illegal to call XmlName on a ValueField field")
}
+func (f *ValueField) SrcType() string {
+ return f.MaskType.SrcName()
+}
+
func (f *ValueField) Size() Size {
return f.MaskType.Size()
}
@@ -174,6 +191,10 @@ func (f *SwitchField) XmlName() string {
panic("it is illegal to call XmlName on a SwitchField field")
}
+func (f *SwitchField) SrcType() string {
+ panic("it is illegal to call SrcType on a SwitchField field")
+}
+
// XXX: This is a bit tricky. The size has to be represented as a non-concrete
// expression that finds *which* bitcase fields are included, and sums the
// sizes of those fields.