コード例 #1
0
 public static GotoStatement NewGoto(LabelStatement label)
 {
     GotoStatement statement;
     GotoStatement statement1 = statement = new GotoStatement();
     statement.set_Label(new ReferenceExpression(label.get_Name()));
     return statement;
 }
コード例 #2
0
        /// <summary>
        /// Make a loop:
        /// $initializers
        /// goto converterGeneratedName#
        /// while true:
        ///     $iterators
        ///     :converterGeneratedName#
        ///     break $conditionType $condition
        ///     $body
        /// </summary>
        ArrayList MakeManualLoop(INode node, List <Statement> initializers, B.StatementModifierType conditionType, Expression condition, List <Statement> iterators, Statement body)
        {
            // we use this "while true" form because "continue" must not skip the iterator.

            ArrayList list = ConvertStatements(initializers);

            B.LabelStatement labelStatement = MakeLabel(GenerateName());
            B.GotoStatement  gotoStatement  = new B.GotoStatement();
            gotoStatement.Label = new B.ReferenceExpression(labelStatement.Name);
            list.Add(gotoStatement);

            B.WhileStatement w = new B.WhileStatement(GetLexicalInfo(node));
            w.Condition = new B.BoolLiteralExpression(true);
            list.Add(w);
            w.Block = ConvertBlock(iterators);
            B.BreakStatement breakStatement = new B.BreakStatement();
            breakStatement.Modifier = new B.StatementModifier(conditionType, ConvertExpression(condition));
            w.Block.Add(labelStatement);
            w.Block.Add(breakStatement);
            foreach (B.Statement st in ConvertBlock(body).Statements)
            {
                w.Block.Add(st);
            }
            return(list);
        }
コード例 #3
0
		public override void OnGotoStatement(GotoStatement node)
		{
			string name = node.Label.Name;
			if (!MatchName(name)) return;
			if (neededLabels.Contains(name)) return;
			neededLabels.Add(name);
			for (int i = 0; i < unneededLabels.Count; i++) {
				if (unneededLabels[i].Name == name)
					unneededLabels.RemoveAt(i--);
			}
		}
コード例 #4
0
ファイル: ProcessMethodBodies.cs プロジェクト: stuman08/boo
 public override void OnGotoStatement(GotoStatement node)
 {
     // don't try to resolve label references
 }
コード例 #5
0
ファイル: BooParserBase.cs プロジェクト: hlizard/boo
	protected GotoStatement  goto_stmt() //throws RecognitionException, TokenStreamException
{
		GotoStatement stmt;
		
		IToken  token = null;
		IToken  label = null;
		
				stmt = null;
			
		
		try {      // for error handling
			token = LT(1);
			match(GOTO);
			label = LT(1);
			match(ID);
			if (0==inputState.guessing)
			{
				
						stmt = new GotoStatement(ToLexicalInfo(token),
									new ReferenceExpression(ToLexicalInfo(label), label.getText()));
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "goto_stmt");
				recover(ex,tokenSet_21_);
			}
			else
			{
				throw ex;
			}
		}
		return stmt;
	}
コード例 #6
0
ファイル: EmitAssembly.cs プロジェクト: Bombadil77/boo
        public override void OnGotoStatement(GotoStatement node)
        {
            EmitDebugInfo(node);

            InternalLabel label = (InternalLabel)GetEntity(node.Label);
            int gotoDepth = AstAnnotations.GetTryBlockDepth(node);
            int targetDepth = AstAnnotations.GetTryBlockDepth(label.LabelStatement);

            if (targetDepth == gotoDepth)
            {
                _il.Emit(OpCodes.Br, label.Label);
            }
            else
            {
                _il.Emit(OpCodes.Leave, label.Label);
            }
        }
コード例 #7
0
ファイル: BranchChecking.cs プロジェクト: boo/boo-lang
        public override void OnGotoStatement(GotoStatement node)
        {
            AstAnnotations.SetTryBlockDepth(node, _state.TryBlockDepth);

            _state.AddLabelReference(node.Label);
        }
コード例 #8
0
		public override void OnBreakStatement(BreakStatement node)
		{
			GotoStatement gotoStatement = new GotoStatement(node.LexicalInfo);
			gotoStatement.Label = new ReferenceExpression(node.LexicalInfo, label);
			node.ReplaceBy(gotoStatement);
		}
コード例 #9
0
        void BranchError(GotoStatement node, LabelStatement target)
        {
            Node parent = AstUtil.GetParentTryExceptEnsure(target);
            switch (parent.NodeType)
            {
                case NodeType.TryStatement:
                {
                    Error(CompilerErrorFactory.CannotBranchIntoTry(node.Label));
                    break;
                }

                case NodeType.ExceptionHandler:
                {
                    Error(CompilerErrorFactory.CannotBranchIntoExcept(node.Label));
                    break;
                }

                case NodeType.Block:
                {
                    Error(CompilerErrorFactory.CannotBranchIntoEnsure(node.Label));
                    break;
                }
            }
        }
コード例 #10
0
        public override void OnGotoStatement(GotoStatement node)
        {
            LabelStatement target = ((InternalLabel)node.Label.Entity).LabelStatement;

            int gotoDepth = AstAnnotations.GetTryBlockDepth(node);
            int targetDepth = AstAnnotations.GetTryBlockDepth(target);
            if (gotoDepth < targetDepth)
            {
                BranchError(node, target);
            }
            else if (gotoDepth == targetDepth)
            {
                Node gotoParent = AstUtil.GetParentTryExceptEnsure(node);
                Node labelParent = AstUtil.GetParentTryExceptEnsure(target);
                if (gotoParent != labelParent)
                {
                    BranchError(node, target);
                }
            }
        }
コード例 #11
0
 public override void LeaveGotoStatement(GotoStatement node)
 {
     LeaveStatement(node);
 }
コード例 #12
0
		public override void OnGotoStatement(GotoStatement node)
		{
			_statements.Add(new CodeGotoStatement(node.Label.Name));
		}
コード例 #13
0
 public override void OnGotoStatement(GotoStatement node)
 {
     WriteIndented();
     WriteKeyword("goto ");
     Visit(node.Label);
     Visit(node.Modifier);
     WriteLine();
 }
コード例 #14
0
ファイル: GotoStatementImpl.cs プロジェクト: Rfvgyhn/boo
		override public object Clone()
		{
		
			GotoStatement clone = new GotoStatement();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			if (null != _modifier)
			{
				clone._modifier = _modifier.Clone() as StatementModifier;
				clone._modifier.InitializeParent(clone);
			}
			if (null != _label)
			{
				clone._label = _label.Clone() as ReferenceExpression;
				clone._label.InitializeParent(clone);
			}
			return clone;


		}
コード例 #15
0
		/// <summary>
		/// Make a loop:
		/// $initializers
		/// goto converterGeneratedName#
		/// while true:
		///     $iterators
		///     :converterGeneratedName#
		///     break $conditionType $condition
		/// 	$body
		/// </summary>
		ArrayList MakeManualLoop(INode node, List<Statement> initializers, B.StatementModifierType conditionType, Expression condition, List<Statement> iterators, Statement body)
		{
			// we use this "while true" form because "continue" must not skip the iterator.
			
			ArrayList list = ConvertStatements(initializers);
			B.LabelStatement labelStatement = MakeLabel(GenerateName());
			B.GotoStatement gotoStatement = new B.GotoStatement();
			gotoStatement.Label = new B.ReferenceExpression(labelStatement.Name);
			list.Add(gotoStatement);
			
			B.WhileStatement w = new B.WhileStatement(GetLexicalInfo(node));
			w.Condition = new B.BoolLiteralExpression(true);
			list.Add(w);
			w.Block = ConvertBlock(iterators);
			B.BreakStatement breakStatement = new B.BreakStatement();
			breakStatement.Modifier = new B.StatementModifier(conditionType, ConvertExpression(condition));
			w.Block.Add(labelStatement);
			w.Block.Add(breakStatement);
			foreach (B.Statement st in ConvertBlock(body).Statements) {
				w.Block.Add(st);
			}
			return list;
		}
コード例 #16
0
 public void continue_statement(Block b)
 {
     IToken token = null;
     try
     {
         token = this.LT(1);
         this.match(9);
         if (base.inputState.guessing == 0)
         {
             string currentLoopLabel = this.GetCurrentLoopLabel();
             if (currentLoopLabel != null)
             {
                 GotoStatement statement;
                 GotoStatement statement1 = statement = new GotoStatement(ToLexicalInfo(token));
                 statement.set_Label(new ReferenceExpression(currentLoopLabel));
                 b.Add(statement);
             }
             else
             {
                 b.Add(new ContinueStatement(ToLexicalInfo(token)));
             }
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_15_);
     }
 }