eval: Introduce a MapLike interface.

This commit is contained in:
Qi Xiao 2016-02-19 12:21:55 +01:00
parent 50af039e16
commit 65a0ab4e83
2 changed files with 10 additions and 0 deletions

View File

@ -10,6 +10,11 @@ type Map struct {
inner *map[Value]Value inner *map[Value]Value
} }
type MapLike interface {
Lener
IndexOneer
}
// NewMap creates a new Map. // NewMap creates a new Map.
func NewMap(inner map[Value]Value) Map { func NewMap(inner map[Value]Value) Map {
return Map{&inner} return Map{&inner}

View File

@ -17,6 +17,11 @@ type Struct struct {
Fields []Variable Fields []Variable
} }
var (
_ Value = (*Struct)(nil)
_ MapLike = (*Struct)(nil)
)
func (*Struct) Kind() string { func (*Struct) Kind() string {
return "map" return "map"
} }