소스 검색

Minor tweaks to function printer

Yentl Van Tendeloo 8 년 전
부모
커밋
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:
             else:
                 false = ""
                 false = ""
 
 
-            instruction = "  " * indent + "if(" + cond + "):\n" + true + "\n" + false
+            instruction = "  " * indent + "if (" + cond + "):\n" + true + "\n" + false
         elif inst_type["value"] == "constant":
         elif inst_type["value"] == "constant":
             node, = yield [("RD", [inst, "node"])]
             node, = yield [("RD", [inst, "node"])]
             node, = yield [("RV", [node])]
             node, = yield [("RV", [node])]
@@ -213,8 +213,11 @@ class ModelverseKernel(object):
             instruction = ""
             instruction = ""
         elif inst_type["value"] == "resolve":
         elif inst_type["value"] == "resolve":
             value, = yield [("RD", [inst, "var"])]
             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":
         elif inst_type["value"] == "assign":
             var, val = yield [("RD", [inst, "var"]),
             var, val = yield [("RD", [inst, "var"]),
                               ("RD", [inst, "value"])]
                               ("RD", [inst, "value"])]
@@ -222,9 +225,14 @@ class ModelverseKernel(object):
                               ("CALL_ARGS", [self.print_instruction, (val, 0)])]
                               ("CALL_ARGS", [self.print_instruction, (val, 0)])]
             instruction = "  " * indent + var + " = " + val + "\n"
             instruction = "  " * indent + var + " = " + val + "\n"
         elif inst_type["value"] == "call":
         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:
             if indent:
                 instruction += "\n"
                 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":
         elif inst_type["value"] == "while":
             cond, body = yield [("RD", [inst, "cond"]),
             cond, body = yield [("RD", [inst, "cond"]),
                                 ("RD", [inst, "body"])]
                                 ("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)
 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 author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server