diff options
Diffstat (limited to 'src/pkg/exp/eval/value.go')
| -rw-r--r-- | src/pkg/exp/eval/value.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/pkg/exp/eval/value.go b/src/pkg/exp/eval/value.go index 1a64a6d96..8cbf0cc60 100644 --- a/src/pkg/exp/eval/value.go +++ b/src/pkg/exp/eval/value.go @@ -96,6 +96,17 @@ type FuncValue interface { Set(*Thread, Func); } +type Interface struct { + Type Type; + Value Value; +} + +type InterfaceValue interface { + Value; + Get(*Thread) Interface; + Set(*Thread, Interface); +} + type Slice struct { Base ArrayValue; Len, Cap int64; @@ -599,6 +610,33 @@ func (v *funcV) Set(t *Thread, x Func) { } /* + * Interfaces + */ + +type interfaceV struct { + Interface; +} + +func (v *interfaceV) String() string { + if v.Type == nil || v.Value == nil { + return "<nil>"; + } + return v.Value.String(); +} + +func (v *interfaceV) Assign(t *Thread, o Value) { + v.Interface = o.(InterfaceValue).Get(t); +} + +func (v *interfaceV) Get(*Thread) Interface { + return v.Interface; +} + +func (v *interfaceV) Set(t *Thread, x Interface) { + v.Interface = x; +} + +/* * Slices */ |
