|
@@ -150,8 +150,8 @@ class ModelverseJit(object):
|
|
|
if body_id in self.todo_entry_points:
|
|
|
self.todo_entry_points.remove(body_id)
|
|
|
|
|
|
- def generate_function_name(self, suggested_name=None):
|
|
|
- """Generates a new function name or picks the suggested name if it is still
|
|
|
+ def generate_name(self, infix, suggested_name=None):
|
|
|
+ """Generates a new name or picks the suggested name if it is still
|
|
|
available."""
|
|
|
if suggested_name is not None \
|
|
|
and suggested_name not in self.jit_globals \
|
|
@@ -159,10 +159,15 @@ class ModelverseJit(object):
|
|
|
self.jit_count += 1
|
|
|
return suggested_name
|
|
|
else:
|
|
|
- function_name = 'jit_func%d' % self.jit_count
|
|
|
+ function_name = 'jit_%s%d' % (infix, self.jit_count)
|
|
|
self.jit_count += 1
|
|
|
return function_name
|
|
|
|
|
|
+ def generate_function_name(self, suggested_name=None):
|
|
|
+ """Generates a new function name or picks the suggested name if it is still
|
|
|
+ available."""
|
|
|
+ return self.generate_name('func', suggested_name)
|
|
|
+
|
|
|
def register_compiled(self, body_id, compiled_function, function_name=None):
|
|
|
"""Registers a compiled entry point with the JIT."""
|
|
|
# Get the function's name.
|
|
@@ -173,6 +178,13 @@ class ModelverseJit(object):
|
|
|
if body_id in self.todo_entry_points:
|
|
|
self.todo_entry_points.remove(body_id)
|
|
|
|
|
|
+ def import_value(self, value, suggested_name=None):
|
|
|
+ """Imports the given value into the JIT's global scope, with the given suggested name.
|
|
|
+ The actual name of the value (within the JIT's global scope) is returned."""
|
|
|
+ actual_name = self.generate_name('import', suggested_name)
|
|
|
+ self.jit_globals[actual_name] = value
|
|
|
+ return actual_name
|
|
|
+
|
|
|
def lookup_compiled_function(self, name):
|
|
|
"""Looks up a compiled function by name. Returns a matching function,
|
|
|
or None if no function was found."""
|