public void EmitLinearBlockStatements(StructureNode node, AbsynStatementEmitter emitter) { foreach (Statement stm in node.Instructions) { if (stm.Instruction.IsControlFlow) return; emitter.EmitStatement(stm); } }
public void GenerateCode( StructureNode node, StructureNode latchNode, AbsynStatementEmitter emitter) { if (followStack.Contains(node) && followStack.Peek() == node) return; if (IsVisited(node)) return; visited.Add(node); if (NeedsLabel(node)) GenerateLabel(node,emitter); if (node.IsLoopHeader()) { node.Loop.GenerateCode(this, node, latchNode, emitter); } else if (node.Conditional != null) { node.Conditional.GenerateCode(this, node, latchNode, emitter); } else { EmitLinearBlockStatements(node, emitter); if (EndsWithReturnInstruction(node)) { emitter.EmitStatement(node.Instructions.Last); return; } if (node.IsLatchNode()) return; if (node.OutEdges.Count == 1) { StructureNode succ = node.OutEdges[0]; if (ShouldJumpFromSequentialNode(node, succ)) EmitGotoAndForceLabel(node, succ, emitter); else GenerateCode(succ, latchNode, emitter); } } }
private AbsynIf EmitIfCondition(Expression exp, Conditional cond, AbsynStatementEmitter emitter) { if (cond is IfElse || cond is IfThenElse) { exp = exp.Invert(); } AbsynIf ifStm = new AbsynIf(); ifStm.Condition = exp; emitter.EmitStatement(ifStm); return ifStm; }