浏览代码

Provide shortcut for evaluation of dict_read operation

Yentl Van Tendeloo 7 年之前
父节点
当前提交
70550d2b0b
共有 2 个文件被更改,包括 15 次插入9 次删除
  1. 14 8
      kernel/modelverse_kernel/main.py
  2. 1 1
      wrappers/modelverse_SCCD.py

+ 14 - 8
kernel/modelverse_kernel/main.py

@@ -452,15 +452,21 @@ class ModelverseKernel(object):
                 self.jit.register_compiled(inst, compiled_func, suggested_name)
 
         # Run the compiled function.
-        results = yield [("CALL_KWARGS", [compiled_func, params])]
-        if results is None:
-            raise Exception("%s: primitive finished without returning a value!" % (self.debug_info[taskname]))
+        if compiled_func == primitive_functions.dict_read:
+            a = params['a']
+            b = params['b']
+            if "value" not in b:
+                b['value'], = yield [("RV", [b['id']])]
+            result, = yield [("RD", [a['id'], b['value']])]
+            result = {'id': result}
         else:
-            result, = results
-
-        #print("Got result: " + str(result))
-        if result is None:
-            result = {'id': None, 'value': None}
+            results = yield [("CALL_KWARGS", [compiled_func, params])]
+            if results is None:
+                raise Exception("%s: primitive finished without returning a value!" % (self.debug_info[taskname]))
+            else:
+                result, = results
+            if result is None:
+                result = {'id': None, 'value': None}
 
         if store:
             # Clean up the current stack, as if a return happened

+ 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:   Thu May 24 10:31:08 2018
+Date:   Thu May 24 10:47:51 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server