Jelajahi Sumber

Bugfixes for compiled functions

Yentl Van Tendeloo 7 tahun lalu
induk
melakukan
730503e9c0

+ 0 - 10
bootstrap/core_algorithm.alc

@@ -951,19 +951,16 @@ Void function enact_PM(pm : Element, mapping : Element):
 			// Find the type (to see what to do with it)
 			//   this does not yet yield the type of transformation, if it is an Execution
 			type = read_type(pm, element)
-			log("Process type " + type)
 
 			// Some types have nothing to do, such as start and fork
 			// Therefore, they are not mentioned in the following conditional
 
 			if (type == "Finish"):
 				// We have finished, so terminate
-				log("Finish")
 				break!
 			elif (type == "Join"):
 				// Only do this if all dependencies are fullfilled
 				// So add to the counter of this Join
-				log("Join")
 				dict_overwrite(counters, element, integer_addition(counters[element], 1))
 
 				// Now check whether we have enough tokens to execute the Join itself
@@ -974,19 +971,15 @@ Void function enact_PM(pm : Element, mapping : Element):
 				if (got == required):
 					// Reset counter to 0
 					dict_overwrite(counters, element, 0)
-					log("Got all!")
 
 					// And continue
 				else:
 					// We haven't gotten all yet, so we wait (i.e., continue without adding Next link to worklist)
-					log("Insufficient: " + cast_value(got))
-					log("Required: " + cast_value(required))
 					continue!
 
 			elif (type == "Exec"):
 				// Execute a transformation
 				// This the difficult part!
-				log("Exec")
 
 				Element args
 				String taskname
@@ -1018,7 +1011,6 @@ Void function enact_PM(pm : Element, mapping : Element):
 				keys = dict_keys(task_to_result)
 				while (set_len(keys) > 0):
 					task = set_pop(keys)
-					log("Detected finished " + cast_value(task_to_activity[task]))
 					result = task_to_result[task]
 
 					Element all_next
@@ -1026,7 +1018,6 @@ Void function enact_PM(pm : Element, mapping : Element):
 					String next
 					while (set_len(all_next) > 0):
 						next = set_pop(all_next)
-						log("Next: " + cast_value(next))
 
 						if (read_type(pm, next) == "Decision"):
 							// Got decision node, so expand immediately
@@ -1043,7 +1034,6 @@ Void function enact_PM(pm : Element, mapping : Element):
 					dict_delete(task_to_activity, task)
 			else:
 				// No finished activities either, so we sleep for some time
-				log("No finished activities...")
 				sleep(0.1)
 
 	// Remove all mock locations again

+ 9 - 1
hybrid_server/classes/task.xml

@@ -46,7 +46,15 @@
                 import traceback
                 print("Error on requests: " + str(commands))
                 print("For taskname " + str(taskname))
-                print("Stack @ MvK:\n" + str("\n".join(['\t%s:%s' % (gen['generator'].__name__, gen['generator'].gi_frame.f_lineno) for gen in mvk.request_handlers[taskname][operation].generator_stack if gen['generator'].__name__ not in ['execute_rule', 'execute_jit', 'execute_jit_internal']])))
+                stack = [gen['generator'] for gen in mvk.request_handlers[taskname][operation].generator_stack if gen['generator'].__name__ not in ['execute_rule', 'execute_jit', 'execute_jit_internal']]
+                printed_stack = []
+                for gen in stack:
+                    try:
+                        line = getattr(getattr(gen, 'gi_frame', {}), 'f_lineno', None)
+                    except:
+                        line = "?"
+                    printed_stack.append("%s:%s" % (gen.__name__, line))
+                print("Stack @ MvK:\n" + str("\n".join(printed_stack)))
                 print(traceback.format_exc())
                 return (float('inf'), False)
             ]]>

+ 9 - 9
kernel/modelverse_kernel/compiled.py

@@ -20,6 +20,8 @@ def get_superclasses(a, b, **remainder):
         found.add(name)
 
         # Iterate over all outgoing links
+        if elem is None:
+            print("ERROR: " + str(locals()))
         outgoing, = yield [("RO", [elem])]
         outgoing = set(outgoing)
         while (outgoing):
@@ -38,8 +40,9 @@ def get_superclasses(a, b, **remainder):
                 # Look up dst's name and add it
                 if dst not in cache_value:
                     dst_name, = yield [("CALL_ARGS", [reverseKeyLookup, [{'id': model_dict}, {'id': dst}]])]
-                    dst_name_value, = yield [("RV", [dst_name])]
-                    cache_value[dst] = dst_name_value
+                    if 'value' not in dst_name:
+                        dst_name['value'], = yield [("RV", [dst_name['id']])]
+                    cache_value[dst] = dst_name['value']
                 dst_name_value = cache_value[dst]
                 worklist.add(dst_name_value)
 
@@ -86,13 +89,11 @@ def reverseKeyLookup(a, b, **remainder):
 def instantiated_name(a, b, **remainder):
     if "value" not in b:
         b['value'], = yield [("RV", [b["id"]])]
-    if "id" not in a:
-        a['id'], = yield [("CNV", [a['value']])]
 
     if b['value'] == "":
-        b['value'] = "__" + str(a['id'])
-
-    raise PrimitiveFinished(b)
+        raise PrimitiveFinished({'value': "__" + str(a['id'])})
+    else:
+        raise PrimitiveFinished(b)
 
 def set_merge(a, b, **remainder):
     keys, =         yield [("RDK", [b['id']])]
@@ -128,8 +129,7 @@ def dict_eq(a, b, **remainder):
     values = yield [("RV", [i]) for i in values]
     b_dict = dict(list(zip(key_values, values)))
 
-    result, = yield [("CNV", [a_dict == b_dict])]
-    raise PrimitiveFinished(result)
+    raise PrimitiveFinished({'value': a_dict == b_dict})
 
 def string_substr(a, b, c, **remainder):
     if "value" not in a:

+ 2 - 2
kernel/modelverse_kernel/main.py

@@ -349,8 +349,8 @@ class ModelverseKernel(object):
         #print(func)
 
         # To write out all generated functions
-        #with open('/tmp/junk/%s' % suggested_name, 'w') as f:
-        #    f.write(func)
+        with open('/tmp/junk/%s' % suggested_name, 'w') as f:
+            f.write(func)
 
         raise primitive_functions.PrimitiveFinished(func)
 

+ 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 Apr 26 11:05:03 2018
+Date:   Thu Apr 26 14:03:15 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server