typedump("struct {a int8; b int8; c int8; d int8; e int8; b int32}", "struct{a int8; b int8; c int8; d int8; e int8; b int32}");
typedump("struct {a int8 \"hi there\"; }", "struct{a int8 \"hi there\"}");
typedump("struct {a int8 \"hi \\x00there\\t\\n\\\"\\\\\"; }", "struct{a int8 \"hi \\x00there\\t\\n\\\"\\\\\"}");
+ typedump("struct {f *(args ...)}", "struct{f *(args ...)}");
valuedump("int8", "8");
valuedump("int16", "16");
switch(typ.Kind()) {
case MissingKind:
return "$missing$";
+ case DotDotDotKind:
+ return "...";
case IntKind, Int8Kind, Int16Kind, Int32Kind, Int64Kind,
UintKind, Uint8Kind, Uint16Kind, Uint32Kind, Uint64Kind,
FloatKind, Float32Kind, Float64Kind, Float80Kind:
ArrayKind;
BoolKind;
ChanKind;
+ DotDotDotKind;
FloatKind;
Float32Kind;
Float64Kind;
var interfacesize uint64
var MissingString = "$missing$" // syntactic name for undefined type names
+var DotDotDotString = "..."
export type Type interface {
Kind() int;
// Prebuilt basic types
export var (
Missing = NewBasicType(MissingString, MissingKind, 1);
+ DotDotDot = NewBasicType(DotDotDotString, DotDotDotKind, 16); // TODO(r): size of interface?
Bool = NewBasicType("bool", BoolKind, 1); // TODO: need to know how big a bool is
Int = NewBasicType("int", IntKind, 4); // TODO: need to know how big an int is
Int8 = NewBasicType("int8", Int8Kind, 1);
var basicstub *map[string] *StubType
var MissingStub *StubType;
+var DotDotDotStub *StubType;
// The database stored in the maps is global; use locking to guarantee safety.
var lockchan *chan bool // Channel with buffer of 1, used as a mutex
// Basics go into types table
types[MissingString] = &Missing;
+ types[DotDotDotString] = &DotDotDot;
types["int"] = ∬
types["int8"] = &Int8;
types["int16"] = &Int16;
// Basics get prebuilt stubs
MissingStub = NewStubType(MissingString, Missing);
+ DotDotDotStub = NewStubType(DotDotDotString, DotDotDot);
basicstub[MissingString] = MissingStub;
+ basicstub[DotDotDotString] = DotDotDotStub;
basicstub["int"] = NewStubType("int", Int);
basicstub["int8"] = NewStubType("int8", Int8);
basicstub["int16"] = NewStubType("int16", Int16);
return;
}
fallthrough; // shouldn't happen but let the parser figure it out
+ case c == '.':
+ if p.index < len(p.str)+2 && p.str[p.index-1:p.index+2] == DotDotDotString {
+ p.index += 2;
+ p.token = DotDotDotString;
+ return;
+ }
+ fallthrough; // shouldn't happen but let the parser figure it out
case special(uint8(c)):
p.token = string(c);
return;