private StackEntry?LowerNode(StackEntry node) { var visitorAdapter = new GenericStackEntryAdapter(this); _nextNode = null; node.Accept(visitorAdapter); if (_nextNode != null) { return(_nextNode); } return(node.Next); }
public IList <Instruction> Generate(IList <BasicBlock> blocks, IList <LocalVariableDescriptor> localVariableTable, Z80MethodCodeNode methodCodeNode) { _context = new CodeGeneratorContext(localVariableTable, methodCodeNode, _configuration); AssignFrameOffsets(); var methodInstructions = new List <Instruction>(); GenerateStringMap(blocks); GenerateStringData(_context.Assembler); _context.Assembler.AddInstruction(new LabelInstruction(_nameMangler.GetMangledMethodName(_context.Method))); GenerateProlog(_context.Assembler); methodInstructions.AddRange(_context.Assembler.Instructions); foreach (var block in blocks) { _context.Assembler.Reset(); _context.Assembler.AddInstruction(new LabelInstruction(block.Label)); var visitorAdapter = new GenericStackEntryAdapter(this); var currentNode = block.FirstNode; while (currentNode != null) { currentNode.Accept(visitorAdapter); currentNode = currentNode.Next; } Optimize(_context.Assembler.Instructions); methodInstructions.AddRange(_context.Assembler.Instructions); } return(methodInstructions); }