|
@@ -292,7 +292,7 @@ class ModelverseKernel(object):
|
|
|
str_value, = yield [("RV", [value])]
|
|
|
if str_value:
|
|
|
# Is a global
|
|
|
- prev = " " * nested_indent + "_globs, = yield [('RD', [kwargs['task_root'], 'globals'])]\n" + \
|
|
|
+ prev = \
|
|
|
" " * nested_indent + "%s, = yield [('RD', [_globs, '%s'])]\n" % (str_value, str_value) + \
|
|
|
" " * nested_indent + "%s, = yield [('RD', [%s, 'value'])]\n" % (str_value, str_value)
|
|
|
instruction = str_value
|
|
@@ -323,7 +323,6 @@ class ModelverseKernel(object):
|
|
|
# Got something to do before the variable is usable, so this is a global!
|
|
|
# Therefore we actually do the operation in the Modelverse as well!
|
|
|
instruction += \
|
|
|
- " " * nested_indent + "_globs, = yield [('RD', [kwargs['task_root'], 'globals'])]\n" + \
|
|
|
" " * nested_indent + "_var, = yield [('RD', [_globs, '%s'])]\n" % instruction_var + \
|
|
|
" " * nested_indent + "if _var is None:\n" + \
|
|
|
" " * (nested_indent + 1) + "_var, = yield [('CN', [])]\n" + \
|
|
@@ -405,12 +404,13 @@ class ModelverseKernel(object):
|
|
|
|
|
|
print("Reading function: %s" % suggested_name)
|
|
|
(prev, printed), = yield [("CALL_ARGS", [self.print_instruction, (inst, 1)])]
|
|
|
- printed = prev + printed
|
|
|
+ printed = " _globs, = yield [('RD', [kwargs['task_root'], 'globals'])]\n" + prev + printed
|
|
|
print("Total printed function: ")
|
|
|
if params:
|
|
|
func = "def " + suggested_name + "(" + ", ".join([chr(ord('a') + i) for i in range(len(params))]) + ", **kwargs):\n" + "".join([" var_%s = %s\n" % (param, chr(ord('a') + i)) for i, param in enumerate(params)]) + printed
|
|
|
else:
|
|
|
func = "def " + suggested_name + "(**kwargs):\n" + printed
|
|
|
+
|
|
|
print(func)
|
|
|
|
|
|
# To write out all generated functions
|