瀏覽代碼

Standardize the 'global not found' message between JIT and interpreter

jonathanvdc 8 年之前
父節點
當前提交
eb6b42526d
共有 3 個文件被更改,包括 6 次插入2 次删除
  1. 1 1
      kernel/modelverse_jit/bytecode_to_tree.py
  2. 3 0
      kernel/modelverse_jit/runtime.py
  3. 2 1
      kernel/modelverse_kernel/main.py

+ 1 - 1
kernel/modelverse_jit/bytecode_to_tree.py

@@ -436,7 +436,7 @@ class AnalysisState(object):
                 tree_ir.CallInstruction(
                     tree_ir.LoadGlobalInstruction('Exception'),
                     [tree_ir.LiteralInstruction(
-                        "Not found as global: %s" % instruction.variable.name)
+                        jit_runtime.GLOBAL_NOT_FOUND_MESSAGE_FORMAT % instruction.variable.name)
                     ])),
             tree_ir.EmptyInstruction())
 

+ 3 - 0
kernel/modelverse_jit/runtime.py

@@ -31,6 +31,9 @@ LOCALS_NODE_NAME = "jit_locals"
 LOCALS_EDGE_NAME = "jit_locals_edge"
 """The name of the edge that connects the LOCALS_NODE_NAME node to a user root."""
 
+GLOBAL_NOT_FOUND_MESSAGE_FORMAT = "Not found as global: %s"
+"""The format of the 'not found as global' message. Takes a single argument."""
+
 def call_function(function_id, named_arguments, **kwargs):
     """Runs the function with the given id, passing it the specified argument dictionary."""
     task_root = kwargs['task_root']

+ 2 - 1
kernel/modelverse_kernel/main.py

@@ -4,6 +4,7 @@ from modelverse_kernel.request_handler import RequestHandler
 import modelverse_jit.jit as jit
 import modelverse_jit.intrinsics as jit_intrinsics
 import modelverse_jit.jit_primitives as jit_primitives
+import modelverse_jit.runtime as jit_runtime
 from collections import defaultdict
 import sys
 import time
@@ -575,7 +576,7 @@ class ModelverseKernel(object):
                                    ("CNV", ["finish"]),
                                   ]
             if variable is None:
-                raise Exception("Not found as global: %s" % var_name)
+                raise Exception(jit_runtime.GLOBAL_NOT_FOUND_MESSAGE_FORMAT % var_name)
 
             # Resolved a global, so this is a string
             # Potentially, this might even be a function that we have precompiled already!