diff options
Diffstat (limited to 'src/lib/reflect/value.go')
-rw-r--r-- | src/lib/reflect/value.go | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/src/lib/reflect/value.go b/src/lib/reflect/value.go index 5c9c727f8..527f1ff00 100644 --- a/src/lib/reflect/value.go +++ b/src/lib/reflect/value.go @@ -11,12 +11,35 @@ import ( "reflect"; ) - type Addr uint64 // TODO: where are ptrint/intptr etc? +// Conversion functions, implemented in assembler +func AddrToPtrAddr(Addr) *Addr +func AddrToPtrInt(Addr) *int +func AddrToPtrInt8(Addr) *int8 +func AddrToPtrInt16(Addr) *int16 +func AddrToPtrInt32(Addr) *int32 +func AddrToPtrInt64(Addr) *int64 +func AddrToPtrUint(Addr) *uint +func AddrToPtrUint8(Addr) *uint8 +func PtrUint8ToAddr(*uint8) Addr +func AddrToPtrUint16(Addr) *uint16 +func AddrToPtrUint32(Addr) *uint32 +func AddrToPtrUint64(Addr) *uint64 +func PtrUint64ToAddr(*uint64) Addr +func AddrToPtrFloat(Addr) *float +func AddrToPtrFloat32(Addr) *float32 +func AddrToPtrFloat64(Addr) *float64 +func AddrToPtrFloat80(Addr) *float80 +func AddrToPtrString(Addr) *string +func AddrToPtrBool(Addr) *bool + +export type Empty interface {} // TODO(r): Delete when no longer needed? + export type Value interface { Kind() int; Type() Type; + Unreflect() Empty; } // Common fields and functionality for all values @@ -35,30 +58,14 @@ func (c *Common) Type() Type { return c.typ } +func (c *Common) Unreflect() Empty { + return sys.unreflect(*AddrToPtrAddr(c.addr), c.typ.String()); +} + func NewValueAddr(typ Type, addr Addr) Value type Creator *(typ Type, addr Addr) Value -// Conversion functions, implemented in assembler -func AddrToPtrAddr(Addr) *Addr -func AddrToPtrInt(Addr) *int -func AddrToPtrInt8(Addr) *int8 -func AddrToPtrInt16(Addr) *int16 -func AddrToPtrInt32(Addr) *int32 -func AddrToPtrInt64(Addr) *int64 -func AddrToPtrUint(Addr) *uint -func AddrToPtrUint8(Addr) *uint8 -func PtrUint8ToAddr(*uint8) Addr -func AddrToPtrUint16(Addr) *uint16 -func AddrToPtrUint32(Addr) *uint32 -func AddrToPtrUint64(Addr) *uint64 -func PtrUint64ToAddr(*uint64) Addr -func AddrToPtrFloat(Addr) *float -func AddrToPtrFloat32(Addr) *float32 -func AddrToPtrFloat64(Addr) *float64 -func AddrToPtrFloat80(Addr) *float80 -func AddrToPtrString(Addr) *string -func AddrToPtrBool(Addr) *bool // -- Missing @@ -743,8 +750,6 @@ export func NewInitValue(typ Type) Value { return NewValueAddr(typ, PtrUint8ToAddr(&data[0])); } -export type Empty interface {} - export func NewValue(e Empty) Value { value, typestring := sys.reflect(e); typ := ParseTypeString("", typestring); |