|
@@ -181,6 +181,14 @@ class ModelverseKernel(object):
|
|
|
function_names[i])
|
|
|
|
|
|
def print_instruction(self, inst, indent=0):
|
|
|
+ intrinsics = {"integer_addition": (lambda x, y: "(%s + %s)" % (x, y)),
|
|
|
+ #"string_join": (lambda x, y: "(str(%s) + str(%s))" % (x, y)),
|
|
|
+ #"dict_read": (lambda x, y: "(%s[%s])" % (x, y)),
|
|
|
+ #"dict_overwrite": (lambda x, y, z: "(%s[%s] = %s)" % (x, y, z)),
|
|
|
+ #"dict_add_fast": (lambda x, y, z: "(%s[%s] = %s)" % (x, y, z)),
|
|
|
+ #"dict_add_fast": (lambda x, y, z: "(%s[%s] = %s)" % (x, y, z)),
|
|
|
+ }
|
|
|
+
|
|
|
inst_type, = yield [("RV", [inst])]
|
|
|
instruction = "(no_printer_for_%s)" % inst_type["value"]
|
|
|
|
|
@@ -238,7 +246,10 @@ class ModelverseKernel(object):
|
|
|
("RD", [param, "next_param"])]
|
|
|
param_list.append(res)
|
|
|
|
|
|
- instruction = " " * indent + func_name + "(" + ", ".join(param_list) + ")"
|
|
|
+ if func_name in intrinsics:
|
|
|
+ instruction = " " * indent + intrinsics[func_name](*param_list)
|
|
|
+ else:
|
|
|
+ instruction = " " * indent + func_name + "(" + ", ".join(param_list) + ")"
|
|
|
if indent:
|
|
|
instruction += "\n"
|
|
|
elif inst_type["value"] == "access":
|
|
@@ -271,9 +282,8 @@ class ModelverseKernel(object):
|
|
|
print("Reading function: %s" % suggested_name)
|
|
|
printed, = yield [("CALL_ARGS", [self.print_instruction, (inst, 1)])]
|
|
|
print("Total printed function: ")
|
|
|
- signature = "def " + suggested_name + "(" + ",".join(["var_%s" % param for param in params]) + "):\n"
|
|
|
- print(signature)
|
|
|
- print(printed)
|
|
|
+ func = "def " + suggested_name + "(" + ",".join(["var_%s" % param for param in params]) + "):\n" + printed
|
|
|
+ print(func)
|
|
|
|
|
|
def jit_compile(self, task_root, inst):
|
|
|
# Try to retrieve the suggested name.
|