|
@@ -30,7 +30,7 @@ class AnalysisState(object):
|
|
|
# Check if the instruction has a 'next' instruction. If so, analyze it!
|
|
|
if instruction.next_instruction is not None:
|
|
|
next_result = self.analyze(instruction.next_instruction)
|
|
|
- if next_result.has_result() or (not result.has_result()):
|
|
|
+ if next_result.value.has_value() or (not result.value.has_value()):
|
|
|
result = next_result
|
|
|
|
|
|
return result
|
|
@@ -83,7 +83,10 @@ class AnalysisState(object):
|
|
|
return self.emit_select(
|
|
|
lambda: self.analyze(instruction.condition),
|
|
|
lambda: self.analyze(instruction.if_clause),
|
|
|
- lambda: self.analyze(instruction.else_clause))
|
|
|
+ lambda:
|
|
|
+ self.current_block.append_definition(cfg_ir.Literal(None))
|
|
|
+ if instruction.else_clause is None
|
|
|
+ else self.analyze(instruction.else_clause))
|
|
|
|
|
|
def analyze_while(self, instruction):
|
|
|
"""Analyzes a 'while' instruction."""
|
|
@@ -131,10 +134,11 @@ class AnalysisState(object):
|
|
|
return_value = self.analyze(instruction.value)
|
|
|
self.current_block.flow = cfg_ir.ReturnFlow(return_value)
|
|
|
self.current_block = cfg_ir.BasicBlock(self.counter)
|
|
|
+ return self.current_block.append_definition(cfg_ir.Literal(None))
|
|
|
|
|
|
def analyze_constant(self, instruction):
|
|
|
"""Analyzes a 'constant' instruction."""
|
|
|
- return self.current_block.append_definition(cfg_ir.Literal(instruction.node_id))
|
|
|
+ return self.current_block.append_definition(cfg_ir.Literal(instruction.constant_id))
|
|
|
|
|
|
def analyze_resolve(self, instruction):
|
|
|
"""Analyzes a 'resolve' instruction."""
|
|
@@ -186,6 +190,8 @@ class AnalysisState(object):
|
|
|
|
|
|
_, exit_block = self.loop_instructions[instruction.loop]
|
|
|
self.current_block.flow = cfg_ir.create_jump(exit_block)
|
|
|
+ self.current_block = cfg_ir.BasicBlock(self.counter)
|
|
|
+ return self.current_block.append_definition(cfg_ir.Literal(None))
|
|
|
|
|
|
def analyze_continue(self, instruction):
|
|
|
"""Analyzes a 'continue' instruction."""
|
|
@@ -195,6 +201,8 @@ class AnalysisState(object):
|
|
|
|
|
|
cond_block, _ = self.loop_instructions[instruction.loop]
|
|
|
self.current_block.flow = cfg_ir.create_jump(cond_block)
|
|
|
+ self.current_block = cfg_ir.BasicBlock(self.counter)
|
|
|
+ return self.current_block.append_definition(cfg_ir.Literal(None))
|
|
|
|
|
|
def analyze_call(self, instruction):
|
|
|
"""Analyzes the given 'call' instruction."""
|
|
@@ -203,7 +211,7 @@ class AnalysisState(object):
|
|
|
for key, arg_instruction in instruction.argument_list:
|
|
|
arg_list.append((key, self.analyze(arg_instruction)))
|
|
|
|
|
|
- return cfg_ir.JitFunctionCall(target, arg_list)
|
|
|
+ return self.current_block.append_definition(cfg_ir.JitFunctionCall(target, arg_list))
|
|
|
|
|
|
instruction_analyzers = {
|
|
|
bytecode_ir.SelectInstruction : analyze_if,
|