"strconv";
)
+// A Type conventionally represents a pointer to any of the
+// specific Type structures (CharType, StructType, etc.).
+type Type interface {
+ Common() *CommonType;
+ String() string;
+ Size() int64;
+}
+
// A CommonType holds fields common to multiple types.
// If a field is not known or not applicable for a given type,
// the zero value is used.
return c;
}
+func (c *CommonType) Size() int64 {
+ return c.ByteSize;
+}
+
// Basic types
// A BasicType holds fields common to all basic types.
return t.Qual + " " + t.Type.String();
}
+func (t *QualType) Size() int64 {
+ return t.Type.Size();
+}
+
// An ArrayType represents a fixed size array type.
type ArrayType struct {
CommonType;
return "[" + strconv.Itoa64(t.Count) + "]" + t.Type.String();
}
+func (t *ArrayType) Size() int64 {
+ return t.Count * t.Type.Size();
+}
+
// A VoidType represents the C void type.
type VoidType struct {
CommonType;
return t.Name;
}
-// A Type conventionally represents a pointer to any of the
-// specific Type structures (CharType, StructType, etc.).
-type Type interface {
- Common() *CommonType;
- String() string;
+func (t *TypedefType) Size() int64 {
+ return t.Type.Size();
}
func (d *Data) Type(off Offset) (Type, os.Error) {
goto Error;
}
- typ.Common().ByteSize, _ = e.Val(AttrByteSize).(int64);
+ b, ok := e.Val(AttrByteSize).(int64);
+ if !ok {
+ b = -1;
+ }
+ typ.Common().ByteSize = b;
return typ, nil;