Browse Source

Merge branch 'testing'

Yentl Van Tendeloo 7 years ago
parent
commit
782a741116

+ 8 - 3
bootstrap/modelling.alc

@@ -417,15 +417,20 @@ Element function read_attribute(model : Element, element : String, attribute : S
 		Element elem
 		Element elem
 		String name
 		String name
 
 
-		elem = model["model"][element]
+		Element model_dict
+		Element mm_dict
+		model_dict = model["model"]
+		mm_dict = model["metamodel"]["model"]
+
+		elem = model_dict[element]
 		count = read_nr_out(elem)
 		count = read_nr_out(elem)
 
 
 		i = 0
 		i = 0
 		while (i < count):
 		while (i < count):
 			edge = read_out(elem, i)
 			edge = read_out(elem, i)
-			name = reverseKeyLookup(model["model"], edge)
+			name = reverseKeyLookup(model_dict, edge)
 			if (name != ""):
 			if (name != ""):
-				edge_type = model["metamodel"]["model"][read_type(model, name)]
+				edge_type = mm_dict[read_type(model, name)]
 				if (element_eq(edge_type, dict_read_edge(read_edge_src(edge_type), attribute))):
 				if (element_eq(edge_type, dict_read_edge(read_edge_src(edge_type), attribute))):
 					return read_edge_dst(edge)!
 					return read_edge_dst(edge)!
 			i = i + 1
 			i = i + 1

+ 6 - 2
hybrid_server/classes/mvkcontroller.xml

@@ -298,7 +298,11 @@
                     </state>
                     </state>
                 </state>
                 </state>
 
 
-                <state id="mvs_GC" initial="suspend_tasks">
+                <state id="mvs_GC" initial="waiting">
+                    <state id="waiting">
+                        <transition after="self.sccd_yield() + 600" target="../suspend_tasks"/>
+                    </state>
+
                     <state id="suspend_tasks">
                     <state id="suspend_tasks">
                         <onentry>
                         <onentry>
                             <raise scope="broad" event="pause_task"/>
                             <raise scope="broad" event="pause_task"/>
@@ -321,7 +325,7 @@
                             </script>
                             </script>
                             <raise scope="broad" event="resume_task"/>
                             <raise scope="broad" event="resume_task"/>
                         </onentry>
                         </onentry>
-                        <transition after="self.sccd_yield() + 600" target="."/>
+                        <transition target="../waiting"/>
                     </state>
                     </state>
                 </state>
                 </state>
             </parallel>
             </parallel>

+ 18 - 0
kernel/modelverse_kernel/compiled.py

@@ -369,3 +369,21 @@ def set_in_node(a, b, **remainder):
     value, = yield [("RDN", [a['id'], b['id']])]
     value, = yield [("RDN", [a['id'], b['id']])]
     yield [("RETURN", [{'value': value is not None}])]
     yield [("RETURN", [{'value': value is not None}])]
 
 
+def read_type(a, b, **remainder):
+    if "value" not in b:
+        b['value'], = yield [("RV", [b['id']])]
+
+    model, type_mapping, metamodel = yield [("RD", [a['id'], 'model']), ("RD", [a['id'], 'type_mapping']), ("RD", [a['id'], 'metamodel'])]
+    metamodel, in_model, type_value = yield [("RD", [metamodel, 'model']), ("RD", [model, b['value']]), ("RD", [type_mapping, b['value']])]
+
+    if in_model is None:
+        yield [("RETURN", [{'value': ""}])]
+    elif type_value is None:
+        yield [("RETURN", [{'value': ""}])]
+    else:
+        type_value, = yield [("RV", [type_value])]
+        in_metamodel, = yield [("RD", [metamodel, type_value])]
+        if in_metamodel is None:
+            yield [("RETURN", [{'value': ""}])]
+        else:
+            yield [("RETURN", [{'value': type_value}])]

+ 15 - 10
kernel/modelverse_kernel/main.py

@@ -102,6 +102,7 @@ class ModelverseKernel(object):
     def execute_rule(self, taskname):
     def execute_rule(self, taskname):
         task_root, =    yield [("RD", [self.root, taskname])]
         task_root, =    yield [("RD", [self.root, taskname])]
         if task_root is None:
         if task_root is None:
+            yield [("SLEEP", [0.01, False])]
             yield None
             yield None
         else:
         else:
             task_frame, = yield [("RD", [task_root, "frame"])]
             task_frame, = yield [("RD", [task_root, "frame"])]
@@ -128,7 +129,6 @@ class ModelverseKernel(object):
                 elif inst_v is None:
                 elif inst_v is None:
                     raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[taskname], inst_v, self.phase_v))
                     raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[taskname], inst_v, self.phase_v))
                 else:
                 else:
-                    #print("%-30s(%s) -- %s" % (inst_v["value"], self.phase_v, taskname))
                     gen = self.get_inst_phase_generator(inst_v, self.phase_v, task_root)
                     gen = self.get_inst_phase_generator(inst_v, self.phase_v, task_root)
             elif inst_v is None:
             elif inst_v is None:
                 raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[taskname], inst_v, self.phase_v))
                 raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[taskname], inst_v, self.phase_v))
@@ -324,7 +324,7 @@ class ModelverseKernel(object):
 
 
             param_list = "{" + ", ".join(["'%s': %s" % (k, v) for k, v in param_list.items()]) + "}"
             param_list = "{" + ", ".join(["'%s': %s" % (k, v) for k, v in param_list.items()]) + "}"
             actual_computation = "$$INDENT$$%s, = yield [('CALL_ARGS', [_mvk.execute_jit, (_root, %s['id'], _taskname, %s)])]\n" % (value, func_name, param_list)
             actual_computation = "$$INDENT$$%s, = yield [('CALL_ARGS', [_mvk.execute_jit, (_root, %s['id'], _taskname, %s)])]\n" % (value, func_name, param_list)
-
+                
             if indent == 0:
             if indent == 0:
                 # No indent, meaning that we use it inline
                 # No indent, meaning that we use it inline
                 # Therefore, we output the prev and value individually
                 # Therefore, we output the prev and value individually
@@ -334,6 +334,7 @@ class ModelverseKernel(object):
                 # Therefore, we only do the yield
                 # Therefore, we only do the yield
                 prev, instruction = prev_func_name + computation, actual_computation.replace("$$INDENT$$", "  " * indent)
                 prev, instruction = prev_func_name + computation, actual_computation.replace("$$INDENT$$", "  " * indent)
 
 
+
         elif inst_type["value"] == "access":
         elif inst_type["value"] == "access":
             value, = yield [("RD", [inst, "var"])]
             value, = yield [("RD", [inst, "var"])]
             (prev, instruction), = yield [("CALL_ARGS", [self.print_instruction, (value, 0, nested_indent)])]
             (prev, instruction), = yield [("CALL_ARGS", [self.print_instruction, (value, 0, nested_indent)])]
@@ -452,15 +453,19 @@ 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:
+            if "value" not in params['b']:
+                params['b']['value'], = yield [("RV", [params['b']['id']])]
+            result, = yield [("RD", [params['a']['id'], params['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

+ 4 - 0
wrappers/modelverse_SCCD.py

@@ -1,7 +1,11 @@
 """
 """
 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)
 
 
+<<<<<<< HEAD
 Date:   Thu May 24 08:44:23 2018
 Date:   Thu May 24 08:44:23 2018
+=======
+Date:   Thu May 24 11:42:22 2018
+>>>>>>> testing
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server