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

      interpreter.PushTarget(this);
      var i = 0;
      for (; i < CaseClauses.Count; ++i)
      {
        var caseClause = CaseClauses[i];
        if (caseClause.IsDefault)
          break;
        caseClause.Comparison.Execute(ref result, ref callFrame, interpreter);
        if (result.AsBoolean())
          break;
      }
      for (; i < CaseClauses.Count && interpreter.CompletionType == Interpreter.CompletionTypes.Normal; ++i)
      {
        var caseClause = CaseClauses[i];
        caseClause.Execute(ref result, ref callFrame, interpreter);
      }
      interpreter.PopTarget(this);

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

      interpreter.PushTarget(this);
      Target.Execute(ref result, ref callFrame, interpreter);
      interpreter.PopTarget(this);

      interpreter.PopLocation(this, ref result);
    }
示例#3
0
    public override void Execute(ref mdr.DValue result, ref mdr.CallFrame callFrame, Interpreter interpreter)
    {
      interpreter.PushLocation(this);

      interpreter.PushTarget(this);
      if (Initialization != null)
        Initialization.Execute(ref result, ref callFrame, interpreter);
      var tempCount = interpreter.GetTemporaryCount();
      //int backedgeCount = 0;

      while (true)
      {
        if (Condition != null)
        {
          Condition.Execute(ref result, ref callFrame, interpreter);
          if (!result.AsBoolean())
            break;
        }

        //backedgeCount++;
        Body.Execute(ref result, ref callFrame, interpreter);
        if (interpreter.CompletionType == Interpreter.CompletionTypes.Continue && interpreter.CompletionTargetStatement == this)
          interpreter.SetCompletion(Interpreter.CompletionTypes.Normal, null);
        else if (interpreter.CompletionType != Interpreter.CompletionTypes.Normal)
          break;

        if (Increment != null)
          Increment.Execute(ref result, ref callFrame, interpreter);
        interpreter.ReleaseTemporariesAfter(tempCount);
      }
      interpreter.PopTarget(this);

      //interpreter.IncrementBackedgeCount(backedgeCount);
      interpreter.PopLocation(this, ref result);
    }
示例#4
0
    public override void Execute(ref mdr.DValue result, ref mdr.CallFrame callFrame, Interpreter interpreter)
    {
      ///We try to do as much here as possible to avoid reaching the InternalCall and InternalNew
      ///See NodeFactory.MakeForEachInStatement to understand the logic
      interpreter.PushLocation(this);
      Expression.Execute(ref result, ref callFrame, interpreter);
      var iterator = new JSPropertyNameEnumerator(result.AsDObject());
      Debug.Assert(
        ExtendedBody.Statements.Count == 2
        && ExtendedBody.Statements[0] is ExpressionStatement
        , "Invalid situation! We must have a ExpressionStatement here!");
      var assignToLeft = (ExtendedBody.Statements[0] as ExpressionStatement).Expression;

      interpreter.PushTarget(this);
      var tempCount = interpreter.GetTemporaryCount();
      //int backedgeCount = 0;

      while (iterator.MoveNext())
      {
        var writeId = assignToLeft as WriteIdentifierExpression;
        if (writeId != null)
        {
          result.Set(iterator.GetCurrent());
          interpreter.WriteSymbol(writeId.Symbol, ref result, ref callFrame);
        }
        else
        {
          //This is an unlikely case anyways!
          var writeIndex = assignToLeft as WriteIndexerExpression;
          Debug.Assert(writeIndex != null, "Invalid situation! We must have a WriteIndexerExpression here!");
          writeIndex.Container.Execute(ref result, ref callFrame, interpreter);
          var obj = result.AsDObject();
          writeIndex.Index.Execute(ref result, ref callFrame, interpreter);
          obj.SetField(ref result, iterator.GetCurrent());
        }

        //backedgeCount++;
        OriginalBody.Execute(ref result, ref callFrame, interpreter);
        if (interpreter.CompletionType == Interpreter.CompletionTypes.Continue && interpreter.CompletionTargetStatement == this)
          interpreter.SetCompletion(Interpreter.CompletionTypes.Normal, null);
        else if (interpreter.CompletionType != Interpreter.CompletionTypes.Normal)
          break;
        interpreter.ReleaseTemporariesAfter(tempCount);
      }
      interpreter.PopTarget(this);

      //interpreter.IncrementBackedgeCount(backedgeCount);
      interpreter.PopLocation(this, ref result);
    }
示例#5
0
    public override void Execute(ref mdr.DValue result, ref mdr.CallFrame callFrame, Interpreter interpreter)
    {
      interpreter.PushLocation(this);

      interpreter.PushTarget(this);
      var tempCount = interpreter.GetTemporaryCount();
      //int backedgeCount = -1;
      do
      {
        //if (JSRuntime.Instance.Configuration.EnableProfiling)
          //backedgeCount++;
        Body.Execute(ref result, ref callFrame, interpreter);
        if (interpreter.CompletionType == Interpreter.CompletionTypes.Continue && interpreter.CompletionTargetStatement == this)
          interpreter.SetCompletion(Interpreter.CompletionTypes.Normal, null);
        else if (interpreter.CompletionType != Interpreter.CompletionTypes.Normal)
          break;

        Condition.Execute(ref result, ref callFrame, interpreter);
        interpreter.ReleaseTemporariesAfter(tempCount);
      } while (result.AsBoolean());
      interpreter.PopTarget(this);

      //interpreter.IncrementBackedgeCount(backedgeCount);
      interpreter.PopLocation(this, ref result);
    }