Example #1
0
        public AbsynSwitch EmitSwitch(StructureNode node, Expression exp, List <AbsynStatement> stmts)
        {
            AbsynSwitch switchStm = new AbsynSwitch(exp, stmts);

            stms.Add(switchStm);
            return(switchStm);
        }
Example #2
0
        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);
        }
Example #3
0
 public AbsynStatement VisitSwitch(AbsynSwitch absynSwitch)
 {
     for (int i = 0; i < absynSwitch.Statements.Count; ++i)
     {
         absynSwitch.Statements[i] = absynSwitch.Statements[i].Accept(this);
     }
     return(absynSwitch);
 }
Example #4
0
 public void VisitSwitch(AbsynSwitch s)
 {
     writer.Indent();
     writer.WriteKeyword("switch");
     writer.Write(" (");
     WriteExpression(s.Expression);
     writer.Terminate(")");
     WriteIndentedStatements(s.Statements, false);
 }
Example #5
0
 public void VisitSwitch(AbsynSwitch absynSwitch)
 {
     stms.Add(absynSwitch);
 }
Example #6
0
 public bool VisitSwitch(AbsynSwitch absynSwitch)
 {
     return(false);
 }