func (self *Ident) Eval(env *scope.Scope) value.Value { if obj := env.Lookup(self.Name, true); obj != nil { //fmt.Println(reflect.TypeOf(obj.Data)) return obj.Data.(value.Value) } return nil }
// This is a set manipulation. func (self *Define) Eval(env *scope.Scope) value.Value { fmt.Println("Define#Eval") var_ := self.var_.(*Ident) val := self.expr.Eval(env) env.Insert(var_.Name, scope.NewObj(val)) // Define does not have return val. return nil }
// This is a set manipulation. func (self *Set) Eval(env *scope.Scope) value.Value { fmt.Println("Set#Eval") var_ := self.var_.(*Ident) val := self.expr.Eval(env) if obj := env.Lookup(var_.Name, true); obj == nil { panic("set!: assignment disallowed.") } env.Insert(var_.Name, scope.NewObj(val)) // Define does not have return val. return nil }