Example #1
0
    public override void Execute(ref mdr.DValue result, ref mdr.CallFrame callFrame, Interpreter interpreter)
    {
      interpreter.PushLocation(this);

      var tmpCallFrame = new mdr.CallFrame();

      Function.Execute(ref result, ref callFrame, interpreter);

      if (ThisArg != null)
      {
        var thisValue = new mdr.DValue();
        ThisArg.Execute(ref thisValue, ref callFrame, interpreter);
        tmpCallFrame.This = thisValue.AsDObject();
      }
      else if (IsDirectEvalCall)
      {
        tmpCallFrame.CallerFunction = callFrame.Function;
        tmpCallFrame.CallerContext = interpreter.Context;
        tmpCallFrame.This = callFrame.This;
      }
      else
      {
        tmpCallFrame.This = mdr.Runtime.Instance.GlobalContext;
      }

      interpreter.LoadArguments(this.Arguments, ref tmpCallFrame, ref callFrame);

      tmpCallFrame.Function = result.AsDFunction();
      JSRuntime.StopTimer(interpreter.Timer);
      tmpCallFrame.Function.Call(ref tmpCallFrame);
      JSRuntime.StartTimer(interpreter.Timer);
      result = tmpCallFrame.Return;

      interpreter.PopLocation(this, tmpCallFrame.Function);
    }
Example #2
0
    public override void Execute(ref mdr.DValue result, ref mdr.CallFrame callFrame, Interpreter interpreter)
    {
      interpreter.PushLocation(this);

      var tmpCallFrame = new mdr.CallFrame();

      Function.Execute(ref result, ref callFrame, interpreter);

      interpreter.LoadArguments(this.Arguments, ref tmpCallFrame, ref callFrame);

      tmpCallFrame.Function = result.AsDFunction();
      
      JSRuntime.StopTimer(interpreter.Timer);
      tmpCallFrame.Function.Construct(ref tmpCallFrame);
      JSRuntime.StartTimer(interpreter.Timer);
      result.Set(tmpCallFrame.This);

      interpreter.PopLocation(this, tmpCallFrame.Function);
    }