示例#1
0
 public override void Visit(GotoStatement node)
 {
   Visit((Statement)node);
 }
示例#2
0
      protected override void Jump(GotoStatement node, bool isContinue)
      {
        var labelInfo = _labelInfos.GetLabelInfo(node.Target);
        string error = null;
        if (labelInfo == null)
        {
          if (node.Target == null)
            if (isContinue)
              error = "SyntaxError: Illegal continue statement";
            else
              error = "SyntaxError: Illegal break statement";
          else
            error = string.Format("SyntaxError: Undefined label '{0}'", node.Target);
        }
        else
          if (isContinue && !labelInfo.HasContinueTarget)
            error = string.Format("SyntaxError: Undefined label '{0}'", node.Target);

        if (error != null)
        {
          var tmpException = new ThrowStatement(new StringLiteral(error));
          VisitNode(tmpException); //We call visit here to have the proper override of it get called.
          //TODO: var ErrorCall = new InternalCall(CodeGen.Types.Operations.Error.SemanticError, null);
        }
        else
        {
          var targetLabel = isContinue ? labelInfo.ContinueTarget : labelInfo.BreakTarget;
          bool isLeavingProtectedRegion = labelInfo.ProtectedRegion != _labelInfos.CurrProtectedRegion;
          if (isLeavingProtectedRegion)
            _ilGen.Leave(targetLabel);
          else
            _ilGen.Br(targetLabel);
        }
      }
示例#3
0
      public override void Visit(ReturnStatement node)
      {
        var gotoEnd = new GotoStatement(_returnLabelName);
        if (node.Expression != null)
        {
          //We have a return value as well
          var cloned = new BlockStatement(new List<Statement>());

          var returnValue = GetCloneOf(node.Expression);

          var retAssign = new WriteIdentifierExpression(_returnValueSymbol, returnValue);
          cloned.Statements.Add(gotoEnd);
          cloned.Statements.Add(new ExpressionStatement(retAssign));
          result = cloned;
        }
        else
        {
          result = gotoEnd;
        }
      }
      protected override void Jump(GotoStatement node, bool isContinue)
      {
        var labelInfo = _labelInfos.GetLabelInfo(node.Target);
        string error = null;
        if (labelInfo == null)
        {
          if (node.Target == null)
            if (isContinue)
              error = "SyntaxError: Illegal continue statement";
            else
              error = "SyntaxError: Illegal break statement";
          else
            error = string.Format("SyntaxError: Undefined label '{0}'", node.Target);
        }
        else
          if (isContinue && !labelInfo.HasContinueTarget)
            error = string.Format("SyntaxError: Undefined label '{0}'", node.Target);

        if (error != null)
        {
          var tmpException = new ThrowStatement(new StringLiteral(error));
          VisitNode(tmpException); //We call visit here to have the proper override of it get called.
          //TODO: var ErrorCall = new InternalCall(CodeGen.Types.Operations.Error.SemanticError, null);
        }
        else
        {
          //We reserve one slot in the _ics and later back fill these jumps. 
          (isContinue ? labelInfo.ContinueTarget : labelInfo.BreakTarget).AddLast(ReserveNewICIndex());
        }
      }
示例#5
0
 public override void Visit(GotoStatement node)
 {
     Visit((Statement)node);
 }
示例#6
0
 public abstract void Visit(GotoStatement node);
示例#7
0
 public override void Visit(GotoStatement node)
 {
   Jump(node, false);
 }
示例#8
0
 protected virtual void Jump(GotoStatement node, bool isContinue)
 {
   throw new NotImplementedException();
 }
示例#9
0
 public override void Visit(GotoStatement node) { }