git @ Cat's Eye Technologies SixtyPical / 070ffac
Don't generate code for empty `else` blocks. Chris Pressey 9 years ago
4 changed file(s) with 4 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
177177 context1 = context.clone()
178178 context2 = context.clone()
179179 analyze_block(instr.block1, context1, routines)
180 analyze_block(instr.block2, context2, routines)
180 if instr.block2 is not None:
181 analyze_block(instr.block2, context2, routines)
181182 for ref in context1.each_initialized():
182183 context2.assert_initialized(ref, exception_class=InconsistentInitializationError)
183184 for ref in context2.each_initialized():
175175 else_label = Label('else_label')
176176 self.emitter.emit(cls(Relative(else_label)))
177177 self.compile_block(instr.block1)
178 if instr.block2:
178 if instr.block2 is not None:
179179 end_label = Label('end_label')
180180 self.emitter.emit(JMP(Absolute(end_label)))
181181 self.emitter.resolve_label(else_label)
171171 block2 = None
172172 if self.scanner.consume('else'):
173173 block2 = self.block()
174 else:
175 block2 = Block(instrs=[])
176174 return Instr(opcode='if', dest=None, src=src, block1=block1, block2=block2)
177175 elif self.scanner.token in ("ld", "add", "sub", "cmp", "and", "or", "xor"):
178176 opcode = self.scanner.token
142142 | ld y, 1
143143 | }
144144 | }
145 = 00c0a900d005a0014c0bc0a00260
145 = 00c0a900d002a00160