소스 검색

Support 'if' without an 'else' branch in the JIT

jonathanvdc 8 년 전
부모
커밋
2d9c0fbfd2
1개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 10 3
      kernel/modelverse_jit/jit.py

+ 10 - 3
kernel/modelverse_jit/jit.py

@@ -174,13 +174,20 @@ class AnalysisState(object):
             ("RD", [instruction_id, "then"]),
             ("RD", [instruction_id, "else"])]
 
-        gen = self.analyze_all([cond, true, false])
+        gen = self.analyze_all(
+            [cond, true]
+            if false is None
+            else [cond, true, false])
         try:
             inp = None
             while True:
                 inp = yield gen.send(inp)
-        except primitive_functions.PrimitiveFinished as e:
-            cond_r, true_r, false_r = e.result
+        except primitive_functions.PrimitiveFinished as ex:
+            if false is None:
+                cond_r, true_r = ex.result
+                false_r = tree_ir.EmptyInstruction()
+            else:
+                cond_r, true_r, false_r = ex.result
             raise primitive_functions.PrimitiveFinished(
                 tree_ir.SelectInstruction(
                     tree_ir.ReadValueInstruction(cond_r),