Environment and identifiers
This commit is contained in:
20
object/environment.go
Normal file
20
object/environment.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package object
|
||||
|
||||
func NewEnvironment() *Environment {
|
||||
s := make(map[string]Object)
|
||||
return &Environment{store: s}
|
||||
}
|
||||
|
||||
type Environment struct {
|
||||
store map[string]Object
|
||||
}
|
||||
|
||||
func (e *Environment) Get(name string) (Object, bool) {
|
||||
obj, ok := e.store[name]
|
||||
return obj, ok
|
||||
}
|
||||
|
||||
func (e *Environment) Set(name string, val Object) Object {
|
||||
e.store[name] = val
|
||||
return val
|
||||
}
|
||||
Reference in New Issue
Block a user