public AbsynSwitch EmitSwitch(StructureNode node, Expression exp, List <AbsynStatement> stmts) { AbsynSwitch switchStm = new AbsynSwitch(exp, stmts); stms.Add(switchStm); return(switchStm); }
public override void GenerateCode(AbsynCodeGenerator codeGen, StructureNode node, StructureNode latchNode, AbsynStatementEmitter emitter) { codeGen.EmitLinearBlockStatements(node, emitter); Expression exp = ((SwitchInstruction)node.Instructions.Last.Instruction).Expression; AbsynSwitch switchStm = emitter.EmitSwitch(node, exp, new List <AbsynStatement>()); AbsynStatementEmitter emitSwitchBranches = new AbsynStatementEmitter(switchStm.Statements); if (Follow == null) { throw new NotSupportedException(string.Format("Null follow node for case statement at {0} is not supported.", node.Name)); } codeGen.PushFollow(Follow); for (int i = 0; i < node.OutEdges.Count; i++) { emitSwitchBranches.EmitCaseLabel(node, i); StructureNode succ = node.OutEdges[i]; if (codeGen.IsVisited(succ)) { codeGen.EmitGotoAndForceLabel(node, succ, emitSwitchBranches); } else { codeGen.GenerateCode(succ, latchNode, emitSwitchBranches); emitSwitchBranches.EmitBreak(); } } codeGen.PopFollow(); codeGen.GenerateCode(Follow, latchNode, emitter); }
public AbsynStatement VisitSwitch(AbsynSwitch absynSwitch) { for (int i = 0; i < absynSwitch.Statements.Count; ++i) { absynSwitch.Statements[i] = absynSwitch.Statements[i].Accept(this); } return(absynSwitch); }
public void VisitSwitch(AbsynSwitch s) { writer.Indent(); writer.WriteKeyword("switch"); writer.Write(" ("); WriteExpression(s.Expression); writer.Terminate(")"); WriteIndentedStatements(s.Statements, false); }
public void VisitSwitch(AbsynSwitch absynSwitch) { stms.Add(absynSwitch); }
public bool VisitSwitch(AbsynSwitch absynSwitch) { return(false); }