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

Set callee property of Arguments object

This commit is contained in:
Robert Krimen 2013-03-05 09:08:46 -08:00
parent fef122900f
commit 299495ba0a
2 changed files with 8 additions and 7 deletions

View File

@ -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))
// function(abc, def, ghi)
@ -140,6 +140,7 @@ func (self *_runtime) _callNode(environment *_functionEnvironment, node *_functi
if !node.ArgumentsIsParameter {
arguments := self.newArgumentsObject(indexOfParameterName, environment, len(argumentList))
arguments.stash.set("callee", toValue(function), 0101)
environment.arguments = arguments
self.localSet("arguments", toValue(arguments))
for index, _ := range argumentList {
@ -181,7 +182,7 @@ func (self *_runtime) Call(function *_object, this Value, argumentList []Value,
if evalHint {
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
}

View File

@ -102,7 +102,7 @@ type _constructFunction func(*_object, Value, []Value) Value
// _callFunction
type _callFunction interface {
Dispatch(*_functionEnvironment, *_runtime, Value, []Value, bool) Value
Dispatch(*_object, *_functionEnvironment, *_runtime, Value, []Value, bool) Value
Source() string
ScopeEnvironment() _environment
name() string
@ -135,7 +135,7 @@ func newNativeCallFunction(native _nativeFunction, name string) *_nativeCallFunc
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{
runtime: runtime,
This: this,
@ -162,8 +162,8 @@ func newNodeCallFunction(node *_functionNode, scopeEnvironment _environment) *_n
return self
}
func (self _nodeCallFunction) Dispatch(environment *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, _ bool) Value {
return runtime._callNode(environment, self.node, this, argumentList)
func (self _nodeCallFunction) Dispatch(function *_object, environment *_functionEnvironment, runtime *_runtime, this Value, argumentList []Value, _ bool) Value {
return runtime._callNode(function, environment, self.node, this, argumentList)
}
func (self _nodeCallFunction) Source() string {
@ -186,7 +186,7 @@ func newBoundCallFunction(target *_object, this Value, argumentList []Value) *_b
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...)
return runtime.Call(self.target, self.this, argumentList, false)
}