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

Provide shortcut for evaluation of dict_read operation

Yentl Van Tendeloo 7 лет назад
Родитель
Сommit
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)
                 self.jit.register_compiled(inst, compiled_func, suggested_name)
 
 
         # Run the compiled function.
         # 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:
         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:
         if store:
             # Clean up the current stack, as if a return happened
             # 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)
 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 author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server