1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00

Add FunctionCall.Otto

This commit is contained in:
Robert Krimen 2013-05-19 14:57:01 -07:00
parent 0b8a079525
commit 791a2c0c8e
4 changed files with 14 additions and 7 deletions

View File

@ -111,9 +111,9 @@ JavaScript considers a vertical tab (\000B <VT>) to be part of the whitespace cl
```go
type FunctionCall struct {
This Value
This Value
ArgumentList []Value
Otto *Otto
}
```

View File

@ -120,6 +120,7 @@ func New() *Otto {
self := &Otto{
runtime: newContext(),
}
self.runtime.Otto = self
self.Set("console", self.runtime.newConsole())
registry.Apply(func(entry registry.Entry) {

View File

@ -37,6 +37,8 @@ type _runtime struct {
_newError map[string]func(Value) *_object
eval *_object // The builtin eval, for determine indirect versus direct invocation
Otto *Otto
}
func (self *_runtime) EnterGlobalExecutionContext() {

View File

@ -155,10 +155,12 @@ func newNativeCallFunction(native _nativeFunction, name string) *_nativeCallFunc
func (self _nativeCallFunction) Dispatch(_ *_object, _ *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, evalHint bool) Value {
return self.Native(FunctionCall{
runtime: runtime,
runtime: runtime,
evalHint: evalHint,
This: this,
ArgumentList: argumentList,
evalHint: evalHint,
Otto: runtime.Otto,
})
}
@ -217,11 +219,13 @@ func (self _boundCallFunction) Source() string {
// FunctionCall is an enscapulation of a JavaScript function call.
type FunctionCall struct {
runtime *_runtime
runtime *_runtime
_thisObject *_object
evalHint bool
This Value
_thisObject *_object
ArgumentList []Value
evalHint bool
Otto *Otto
}
// Argument will return the value of the argument at the given index.