public static GotoStatement NewGoto(LabelStatement label) { GotoStatement statement; GotoStatement statement1 = statement = new GotoStatement(); statement.set_Label(new ReferenceExpression(label.get_Name())); return statement; }
/// <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); }
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--); } }
public override void OnGotoStatement(GotoStatement node) { // don't try to resolve label references }
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; }
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); } }
public override void OnGotoStatement(GotoStatement node) { AstAnnotations.SetTryBlockDepth(node, _state.TryBlockDepth); _state.AddLabelReference(node.Label); }
public override void OnBreakStatement(BreakStatement node) { GotoStatement gotoStatement = new GotoStatement(node.LexicalInfo); gotoStatement.Label = new ReferenceExpression(node.LexicalInfo, label); node.ReplaceBy(gotoStatement); }
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; } } }
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); } } }
public override void LeaveGotoStatement(GotoStatement node) { LeaveStatement(node); }
public override void OnGotoStatement(GotoStatement node) { _statements.Add(new CodeGotoStatement(node.Label.Name)); }
public override void OnGotoStatement(GotoStatement node) { WriteIndented(); WriteKeyword("goto "); Visit(node.Label); Visit(node.Modifier); WriteLine(); }
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; }
/// <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; }
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_); } }