|
@@ -247,8 +247,13 @@ class ModelverseKernel(object):
|
|
|
value, = yield [("RD", [inst, "var"])]
|
|
|
str_value, = yield [("RV", [value])]
|
|
|
if str_value:
|
|
|
+ # Is a global
|
|
|
+ prev = " " * nested_indent + "_globs, = yield [('RD', [kwargs['root'], '__globals'])]\n" + \
|
|
|
+ " " * nested_indent + "%s, = yield [('RD', [_globs, '%s'])]\n" % (str_value, str_value)
|
|
|
instruction = str_value
|
|
|
+ print("Resolving global: " + str(str_value))
|
|
|
else:
|
|
|
+ # Is a local
|
|
|
instruction = "var_%s" % value
|
|
|
|
|
|
elif inst_type["value"] == "assign":
|
|
@@ -259,9 +264,17 @@ class ModelverseKernel(object):
|
|
|
("CALL_ARGS", [self.print_instruction, (val, 0, indent)])]
|
|
|
instruction = prev_val + " " * indent + instruction_var + " = " + instruction_val + "\n"
|
|
|
|
|
|
+ if prev_var:
|
|
|
+ # 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!
|
|
|
+ prev = " " * nested_indent + "_globs = yield [('RD', [kwargs['root'], '__globals'])]\n" + \
|
|
|
+ " " * nested_indent + "_old_edge = yield [('RDE', [_globs, '%s'])]\n" % (instruction_var) + \
|
|
|
+ " " * nested_indent + "yield [('DE', [_old_edge])]\n" + \
|
|
|
+ " " * nested_indent + "yield [('CD', [_globs, '%s', %s])]\n" % (instruction_var, instruction_val)
|
|
|
+
|
|
|
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)])]
|
|
|
+ (prev_func_name, func_name), = yield [("CALL_ARGS", [self.print_instruction, (func_name, nested_indent, nested_indent)])]
|
|
|
param_list = {}
|
|
|
|
|
|
param, = yield [("RD", [inst, "params"])]
|
|
@@ -289,15 +302,15 @@ class ModelverseKernel(object):
|
|
|
if indent == 0:
|
|
|
# No indent, meaning that we use it inline
|
|
|
# Therefore, we output the prev and value individually
|
|
|
- prev, instruction = computation + " " * nested_indent + actual_computation, value
|
|
|
+ prev, instruction = prev_func_name + computation + " " * nested_indent + actual_computation, value
|
|
|
else:
|
|
|
# Some indentation, meaning that we don't even use the return value
|
|
|
# Therefore, we only do the yield
|
|
|
- prev, instruction = computation, " " * indent + actual_computation
|
|
|
+ prev, instruction = prev_func_name + computation, " " * indent + actual_computation
|
|
|
|
|
|
elif inst_type["value"] == "access":
|
|
|
value, = yield [("RD", [inst, "var"])]
|
|
|
- (prev_instruction, instruction), = yield [("CALL_ARGS", [self.print_instruction, (value, 0, indent)])]
|
|
|
+ (prev, instruction), = yield [("CALL_ARGS", [self.print_instruction, (value, 0, indent)])]
|
|
|
|
|
|
elif inst_type["value"] == "while":
|
|
|
cond, body = yield [("RD", [inst, "cond"]),
|