private Object CallASTFunc(Object[] args, Object thisob, ScriptObject enclosing_scope, Closure calleeClosure, Binder binder, CultureInfo culture){
Object saved_caller = calleeClosure.caller;
calleeClosure.caller = this.globals.caller;
this.globals.caller = calleeClosure;
Object saved_args = calleeClosure.arguments;
ScriptObject calling_scope = globals.ScopeStack.Peek();
ArgumentsObject caller_arguments = (calling_scope is StackFrame) ? ((StackFrame)calling_scope).caller_arguments : null;
StackFrame sf = new StackFrame(enclosing_scope, this.fields, new Object[this.fields.Length], thisob);
if (this.isMethod && !this.isStatic)
sf.closureInstance = thisob;
globals.ScopeStack.GuardedPush(sf);
try{
this.own_scope.CloseNestedFunctions(sf);
ArgumentsObject arguments = null;
if (this.hasArgumentsObject){
arguments = new ArgumentsObject(this.globals.globalObject.originalObjectPrototype, args, this, calleeClosure, sf, caller_arguments);
sf.localVars[this.argumentsSlotNumber] = arguments;
}
sf.caller_arguments = arguments;
calleeClosure.arguments = arguments;
this.ConvertArguments(args, sf.localVars, 0, args.Length, this.formal_parameters.Length, binder, culture);
Completion result = (Completion)(this.body.Evaluate());
if (result.Return)
return result.value;
else
return null;
}finally{
this.globals.ScopeStack.Pop();
calleeClosure.arguments = saved_args;
this.globals.caller = calleeClosure.caller;
calleeClosure.caller = saved_caller;
}
}