|
|
@@ -262,17 +262,19 @@ class ModelverseKernel(object):
|
|
|
elif inst_type["value"] == "call":
|
|
|
func_name, = yield [("RD", [inst, "func"])]
|
|
|
(prev_func_name, func_name), = yield [("CALL_ARGS", [self.print_instruction, (func_name, 0, nested_indent)])]
|
|
|
- param_list = []
|
|
|
+ param_list = {}
|
|
|
|
|
|
param, = yield [("RD", [inst, "params"])]
|
|
|
computation = ""
|
|
|
while param:
|
|
|
value, = yield [("RD", [param, "value"])]
|
|
|
+ name, = yield [("RD", [param, "name"])]
|
|
|
+ name, = yield [("RV", [name])]
|
|
|
(prev_res, instruction_res), param = \
|
|
|
yield [("CALL_ARGS", [self.print_instruction, (value, 0, nested_indent)]),
|
|
|
("RD", [param, "next_param"])]
|
|
|
computation += prev_res
|
|
|
- param_list.append(instruction_res)
|
|
|
+ param_list[name] = instruction_res
|
|
|
|
|
|
if func_name in intrinsics:
|
|
|
#instruction = " " * indent + intrinsics[func_name](*param_list)
|
|
|
@@ -281,10 +283,8 @@ class ModelverseKernel(object):
|
|
|
else:
|
|
|
value = "func_result_" + str(ModelverseKernel.counter)
|
|
|
ModelverseKernel.counter += 1
|
|
|
- if len(param_list) == 1:
|
|
|
- actual_computation = "%s, = yield [('CALL_ARGS', [%s, (%s,)])]\n" % (value, func_name, param_list[0])
|
|
|
- else:
|
|
|
- actual_computation = "%s, = yield [('CALL_ARGS', [%s, (%s)])]\n" % (value, func_name, ", ".join(param_list))
|
|
|
+ param_list = "{" + ", ".join(["'%s': %s" % (k, v) for k, v in param_list.items()]) + "}"
|
|
|
+ actual_computation = "%s, = yield [('CALL_KWARGS', [%s, %s])]\n" % (value, func_name, param_list)
|
|
|
|
|
|
if indent == 0:
|
|
|
# No indent, meaning that we use it inline
|
|
|
@@ -331,7 +331,10 @@ class ModelverseKernel(object):
|
|
|
print("Reading function: %s" % suggested_name)
|
|
|
(_, printed), = yield [("CALL_ARGS", [self.print_instruction, (inst, 1)])]
|
|
|
print("Total printed function: ")
|
|
|
- func = "def " + suggested_name + "(" + ", ".join(["var_%s" % param for param in params]) + "):\n" + printed
|
|
|
+ if params:
|
|
|
+ func = "def " + suggested_name + "(" + ", ".join(["var_%s" % param for param in params]) + ", **kwargs):\n" + printed
|
|
|
+ else:
|
|
|
+ func = "def " + suggested_name + "(**kwargs):\n" + printed
|
|
|
print(func)
|
|
|
raise primitive_functions.PrimitiveFinished(func)
|
|
|
|
|
|
@@ -357,11 +360,15 @@ class ModelverseKernel(object):
|
|
|
|
|
|
#raise jit.JitCompilationFailedException("FAIL")
|
|
|
|
|
|
+ raise primitive_functions.PrimitiveFinished(compiled_func)
|
|
|
+
|
|
|
+ """
|
|
|
try:
|
|
|
raise primitive_functions.PrimitiveFinished(compiled_func)
|
|
|
except Exception as e:
|
|
|
print("Exception: " + str(e))
|
|
|
raise jit.JitCompilationFailedException("FAIL")
|
|
|
+ """
|
|
|
|
|
|
def execute_jit(self, task_root, inst, taskname):
|
|
|
# execute_jit
|