Add variable bindings and references to the evaluator.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
8514ead895
commit
500a058ff8
4 changed files with 97 additions and 20 deletions
19
pkg/object/environment.go
Normal file
19
pkg/object/environment.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package object
|
||||
|
||||
func NewEnvironment() *Environment {
|
||||
return &Environment{store: map[string]Object{}}
|
||||
}
|
||||
|
||||
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, obj Object) Object {
|
||||
e.store[name] = obj
|
||||
return obj
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue