diff options
Diffstat (limited to 'src/lib/reflect/value.go')
-rw-r--r-- | src/lib/reflect/value.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/reflect/value.go b/src/lib/reflect/value.go index ef6ddce7a..65d4b5ca9 100644 --- a/src/lib/reflect/value.go +++ b/src/lib/reflect/value.go @@ -36,14 +36,13 @@ func AddrToPtrString(Addr) *string func AddrToPtrBool(Addr) *bool func AddrToPtrRuntimeArray(Addr) *RuntimeArray func PtrRuntimeArrayToAddr(*RuntimeArray) Addr - -export type Empty interface {} // TODO(r): Delete when no longer needed? +func AddrToPtrInterface(Addr) *interface{} export type Value interface { Kind() int; Type() Type; Addr() Addr; - Interface() Empty; + Interface() interface {}; } // Common fields and functionality for all values @@ -66,7 +65,7 @@ func (c *Common) Addr() Addr { return c.addr } -func (c *Common) Interface() Empty { +func (c *Common) Interface() interface {} { return sys.unreflect(*AddrToPtrAddr(c.addr), c.typ.String()); } @@ -714,12 +713,17 @@ func StructCreator(typ Type, addr Addr) Value { export type InterfaceValue interface { Kind() int; Type() Type; + Get() interface {}; } type InterfaceValueStruct struct { Common } +func (v *InterfaceValueStruct) Get() interface{} { + return *AddrToPtrInterface(v.addr); +} + func InterfaceCreator(typ Type, addr Addr) Value { return &InterfaceValueStruct{ Common{InterfaceKind, typ, addr} } } @@ -824,7 +828,7 @@ export func NewOpenArrayValue(typ ArrayType, len, cap int) ArrayValue { return NewValueAddr(typ, PtrRuntimeArrayToAddr(array)); } -export func NewValue(e Empty) Value { +export func NewValue(e interface {}) Value { value, typestring := sys.reflect(e); p, ok := typecache[typestring]; if !ok { |