aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/obscuren/otto/execution_context.go
blob: 07d891022dc901e6efa4021c2a6a7a106b12b9c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package otto

type _executionContext struct {
    LexicalEnvironment  _environment
    VariableEnvironment _environment
    this                *_object
    eval                bool // Replace this with kind?
}

func newExecutionContext(lexical _environment, variable _environment, this *_object) *_executionContext {
    return &_executionContext{
        LexicalEnvironment:  lexical,
        VariableEnvironment: variable,
        this:                this,
    }
}

func (self *_executionContext) getValue(name string) Value {
    strict := false
    return self.LexicalEnvironment.GetValue(name, strict)
}

func (self *_executionContext) setValue(name string, value Value, throw bool) {
    self.LexicalEnvironment.SetValue(name, value, throw)
}

func (self *_executionContext) newLexicalEnvironment(object *_object) (_environment, *_objectEnvironment) {
    // Get runtime from the object (for now)
    runtime := object.runtime
    previousLexical := self.LexicalEnvironment
    newLexical := runtime.newObjectEnvironment(object, self.LexicalEnvironment)
    self.LexicalEnvironment = newLexical
    return previousLexical, newLexical
}

func (self *_executionContext) newDeclarativeEnvironment(runtime *_runtime) _environment {
    previousLexical := self.LexicalEnvironment
    self.LexicalEnvironment = runtime.newDeclarativeEnvironment(self.LexicalEnvironment)
    return previousLexical
}