Просмотр исходного кода

Minor tweaks to function printer

Yentl Van Tendeloo 8 лет назад
Родитель
Сommit
9253f04925
2 измененных файлов с 13 добавлено и 5 удалено
  1. 12 4
      kernel/modelverse_kernel/main.py
  2. 1 1
      wrappers/modelverse_SCCD.py

+ 12 - 4
kernel/modelverse_kernel/main.py

@@ -197,7 +197,7 @@ class ModelverseKernel(object):
             else:
                 false = ""
 
-            instruction = "  " * indent + "if(" + cond + "):\n" + true + "\n" + false
+            instruction = "  " * indent + "if (" + cond + "):\n" + true + "\n" + false
         elif inst_type["value"] == "constant":
             node, = yield [("RD", [inst, "node"])]
             node, = yield [("RV", [node])]
@@ -213,8 +213,11 @@ class ModelverseKernel(object):
             instruction = ""
         elif inst_type["value"] == "resolve":
             value, = yield [("RD", [inst, "var"])]
-            #instruction, = yield [("CALL_ARGS", [self.print_instruction, (value, 0)])]
-            instruction = "var_%s" % value
+            str_value, = yield [("RV", [value])]
+            if str_value:
+                instruction = str_value
+            else:
+                instruction = str(value)
         elif inst_type["value"] == "assign":
             var, val = yield [("RD", [inst, "var"]),
                               ("RD", [inst, "value"])]
@@ -222,9 +225,14 @@ class ModelverseKernel(object):
                               ("CALL_ARGS", [self.print_instruction, (val, 0)])]
             instruction = "  " * indent + var + " = " + val + "\n"
         elif inst_type["value"] == "call":
-            instruction = "  " * indent + "call(X)"
+            func_name, = yield [("RD", [inst, "func"])]
+            func_name, = yield [("CALL_ARGS", [self.print_instruction, (func_name, 0)])]
+            instruction = "  " * indent + func_name + "(X)"
             if indent:
                 instruction += "\n"
+        elif inst_type["value"] == "access":
+            value, = yield [("RD", [inst, "var"])]
+            instruction, = yield [("CALL_ARGS", [self.print_instruction, (value, 0)])]
         elif inst_type["value"] == "while":
             cond, body = yield [("RD", [inst, "cond"]),
                                 ("RD", [inst, "body"])]

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Fri Mar 23 08:56:39 2018
+Date:   Fri Mar 23 09:05:37 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server