Quellcode durchsuchen

Potentially fix concurrency bug (?) by checking input of reverseKeyLookup more carefully and keeping errors in mind in allOutgoingAssociations/allIncomingAssociations

Yentl Van Tendeloo vor 7 Jahren
Ursprung
Commit
7fe5fa3321

+ 8 - 2
bootstrap/object_operations.alc

@@ -203,24 +203,30 @@ String function readAssociationDestination(model : Element, name : String):
 Element function allAssociationDestinations(model : Element, name : String, association_type : String):
 	Element tmp
 	Element result
+	String val
 
 	result = set_create()
 	tmp = allOutgoingAssociationInstances(model, name, association_type)
 
 	while (set_len(tmp) > 0):
-		set_add(result, readAssociationDestination(model, set_pop(tmp)))
+		val = readAssociationDestination(model, set_pop(tmp))
+		if (val != ""):
+			set_add(result, val)
 
 	return result!
 
 Element function allAssociationOrigins(model : Element, name : String, association_type : String):
 	Element tmp
 	Element result
+	String val
 
 	result = set_create()
 	tmp = allIncomingAssociationInstances(model, name, association_type)
 
 	while (set_len(tmp) > 0):
-		set_add(result, readAssociationSource(model, set_pop(tmp)))
+		val = readAssociationSource(model, set_pop(tmp))
+		if (val != ""):
+			set_add(result, val)
 
 	return result!
 

+ 4 - 0
kernel/modelverse_kernel/compiled.py

@@ -73,6 +73,10 @@ def reverseKeyLookupMulti(a, b, **remainder):
 
 def reverseKeyLookup(a, b, **remainder):
     edges_out, edges_in = yield [("RO", [a['id']]), ("RI", [b['id']])]
+
+    if edges_out is None or edges_in is None:
+        yield [("RETURN", [{'value': ""}])]
+
     options = set(edges_out) & set(edges_in)
     if options:
         # Select one option randomly

+ 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:   Tue May 22 16:39:01 2018
+Date:   Wed May 23 09:03:12 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server