mirror of
https://github.com/robertkrimen/otto
synced 2025-10-19 19:55:30 +08:00
Get variable binding a bit closer to the specification
This commit is contained in:
parent
5f407353c2
commit
bc6cd2ef12
|
|
@ -236,11 +236,18 @@ func (self *_runtime) continueEvaluate(node _node, _labelSet map[string]bool) (r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *_runtime) declare(kind string, declarationList []_declaration) {
|
func (self *_runtime) declare(kind string, declarationList []_declaration) {
|
||||||
|
environment := self._executionContext(0).VariableEnvironment
|
||||||
for _, _declaration := range declarationList {
|
for _, _declaration := range declarationList {
|
||||||
self.localSet(_declaration.Name, UndefinedValue())
|
name := _declaration.Name
|
||||||
|
//self.localSet(_declaration.Name, UndefinedValue())
|
||||||
if kind == "function" {
|
if kind == "function" {
|
||||||
value := self.evaluate(_declaration.Definition)
|
value := self.evaluate(_declaration.Definition)
|
||||||
self.localSet(_declaration.Name, value)
|
self.localSet(_declaration.Name, value)
|
||||||
|
} else {
|
||||||
|
if !environment.HasBinding(name) {
|
||||||
|
environment.CreateMutableBinding(name, false) // TODO configurableBindings
|
||||||
|
environment.SetMutableBinding(name, UndefinedValue(), false) // TODO strict
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user