package value type TypeKind int const ( NullType TypeKind = iota IntType FloatType StringType BoolType ArrayType FunctionType TypeRefType ObjectType ) func (t TypeKind) String() string { switch t { case IntType: return "int" case FloatType: return "float" case StringType: return "string" case BoolType: return "bool" case ArrayType: return "array" case NullType: return "null" case FunctionType: return "function" case TypeRefType: return "type" case ObjectType: return "object" } panic("invalid type kind") } type Type struct { Kind TypeKind Name string Methods map[string]FunctionData Statics map[string]Value } func (t *Type) GetMethod(name string) (FunctionData, bool) { if t.Methods == nil { return FunctionData{}, false } method, ok := t.Methods[name] return method, ok }