public override AstNode Visit(BlockNode node) { // Begin the node. builder.BeginNode(node); // Create the block lexical scope. LexicalScope blockScope = (LexicalScope) node.GetScope(); node.SetScope(blockScope); // Create the new basic block. BasicBlock block = CreateBasicBlock(); block.SetName("block"); // Jump into the basic block. builder.CreateJmp(block); builder.SetBlock(block); // Push the scope. PushScope(blockScope); // Visit the block children. VisitList(node.GetChildren()); // Pop the scope. PopScope(); // Create a merge block and jump into it. if(!builder.IsLastTerminator()) { BasicBlock mergeBlock = CreateBasicBlock(); mergeBlock.SetName("merge"); builder.CreateJmp(mergeBlock); builder.SetBlock(mergeBlock); } return builder.EndNode(); }
public override AstNode Visit(BlockNode node) { // Create the block lexical scope. LexicalScope blockScope = CreateLexicalScope(node); node.SetScope(blockScope); // Push the scope. PushScope(blockScope); // Visit the block children. VisitList(node.GetChildren()); // Restore the scope. PopScope(); return node; }