mirror of
https://github.com/robertkrimen/otto
synced 2025-10-26 20:28:49 +08:00
Set callee property of Arguments object
This commit is contained in:
parent
fef122900f
commit
299495ba0a
|
|
@ -120,7 +120,7 @@ func (self *_runtime) PutValue(reference _reference, value Value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *_runtime) _callNode(environment *_functionEnvironment, node *_functionNode, this Value, argumentList []Value) Value {
|
func (self *_runtime) _callNode(function *_object, environment *_functionEnvironment, node *_functionNode, this Value, argumentList []Value) Value {
|
||||||
|
|
||||||
indexOfParameterName := make([]string, len(node.ParameterList))
|
indexOfParameterName := make([]string, len(node.ParameterList))
|
||||||
// function(abc, def, ghi)
|
// function(abc, def, ghi)
|
||||||
|
|
@ -140,6 +140,7 @@ func (self *_runtime) _callNode(environment *_functionEnvironment, node *_functi
|
||||||
|
|
||||||
if !node.ArgumentsIsParameter {
|
if !node.ArgumentsIsParameter {
|
||||||
arguments := self.newArgumentsObject(indexOfParameterName, environment, len(argumentList))
|
arguments := self.newArgumentsObject(indexOfParameterName, environment, len(argumentList))
|
||||||
|
arguments.stash.set("callee", toValue(function), 0101)
|
||||||
environment.arguments = arguments
|
environment.arguments = arguments
|
||||||
self.localSet("arguments", toValue(arguments))
|
self.localSet("arguments", toValue(arguments))
|
||||||
for index, _ := range argumentList {
|
for index, _ := range argumentList {
|
||||||
|
|
@ -181,7 +182,7 @@ func (self *_runtime) Call(function *_object, this Value, argumentList []Value,
|
||||||
if evalHint {
|
if evalHint {
|
||||||
evalHint = function == self.eval // If evalHint is true, then it IS a direct eval
|
evalHint = function == self.eval // If evalHint is true, then it IS a direct eval
|
||||||
}
|
}
|
||||||
returnValue = function._Function.Call.Dispatch(_functionEnvironment, self, this, argumentList, evalHint)
|
returnValue = function._Function.Call.Dispatch(function, _functionEnvironment, self, this, argumentList, evalHint)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ type _constructFunction func(*_object, Value, []Value) Value
|
||||||
|
|
||||||
// _callFunction
|
// _callFunction
|
||||||
type _callFunction interface {
|
type _callFunction interface {
|
||||||
Dispatch(*_functionEnvironment, *_runtime, Value, []Value, bool) Value
|
Dispatch(*_object, *_functionEnvironment, *_runtime, Value, []Value, bool) Value
|
||||||
Source() string
|
Source() string
|
||||||
ScopeEnvironment() _environment
|
ScopeEnvironment() _environment
|
||||||
name() string
|
name() string
|
||||||
|
|
@ -135,7 +135,7 @@ func newNativeCallFunction(native _nativeFunction, name string) *_nativeCallFunc
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self _nativeCallFunction) Dispatch(_ *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, evalHint bool) Value {
|
func (self _nativeCallFunction) Dispatch(_ *_object, _ *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, evalHint bool) Value {
|
||||||
return self.Native(FunctionCall{
|
return self.Native(FunctionCall{
|
||||||
runtime: runtime,
|
runtime: runtime,
|
||||||
This: this,
|
This: this,
|
||||||
|
|
@ -162,8 +162,8 @@ func newNodeCallFunction(node *_functionNode, scopeEnvironment _environment) *_n
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self _nodeCallFunction) Dispatch(environment *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, _ bool) Value {
|
func (self _nodeCallFunction) Dispatch(function *_object, environment *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, _ bool) Value {
|
||||||
return runtime._callNode(environment, self.node, this, argumentList)
|
return runtime._callNode(function, environment, self.node, this, argumentList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self _nodeCallFunction) Source() string {
|
func (self _nodeCallFunction) Source() string {
|
||||||
|
|
@ -186,7 +186,7 @@ func newBoundCallFunction(target *_object, this Value, argumentList []Value) *_b
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self _boundCallFunction) Dispatch(_ *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, _ bool) Value {
|
func (self _boundCallFunction) Dispatch(_ *_object, _ *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, _ bool) Value {
|
||||||
argumentList = append(self.argumentList, argumentList...)
|
argumentList = append(self.argumentList, argumentList...)
|
||||||
return runtime.Call(self.target, self.this, argumentList, false)
|
return runtime.Call(self.target, self.this, argumentList, false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user