public override void Visit(GotoStatement node) { Visit((Statement)node); }
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); } }
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()); } }
public abstract void Visit(GotoStatement node);
public override void Visit(GotoStatement node) { Jump(node, false); }
protected virtual void Jump(GotoStatement node, bool isContinue) { throw new NotImplementedException(); }
public override void Visit(GotoStatement node) { }