瀏覽代碼

Handle the case where reverseKeyLookup receives non-existing element

Yentl Van Tendeloo 8 年之前
父節點
當前提交
a17c84daf3
共有 3 個文件被更改,包括 13 次插入10 次删除
  1. 10 8
      bootstrap/object_operations.alc
  2. 2 1
      kernel/modelverse_kernel/compiled.py
  3. 1 1
      wrappers/modelverse_SCCD.py

+ 10 - 8
bootstrap/object_operations.alc

@@ -77,11 +77,12 @@ Element function allOutgoingAssociationInstances(model : Element, source_name :
 	i = 0
 	i = 0
 	while (i < all_out):
 	while (i < all_out):
 		option = reverseKeyLookup(model["model"], read_out(source, i))
 		option = reverseKeyLookup(model["model"], read_out(source, i))
-		if (assoc_name != ""):
-			if (is_nominal_instance(model, option, assoc_name)):
+		if (option != ""):
+			if (assoc_name != ""):
+				if (is_nominal_instance(model, option, assoc_name)):
+					set_add(result, option)
+			else:
 				set_add(result, option)
 				set_add(result, option)
-		else:
-			set_add(result, option)
 		i = i + 1
 		i = i + 1
 
 
 	return result!
 	return result!
@@ -100,11 +101,12 @@ Element function allIncomingAssociationInstances(model : Element, target_name :
 	i = 0
 	i = 0
 	while (i < all_out):
 	while (i < all_out):
 		option = reverseKeyLookup(model["model"], read_in(source, i))
 		option = reverseKeyLookup(model["model"], read_in(source, i))
-		if (assoc_name != ""):
-			if (is_nominal_instance(model, option, assoc_name)):
+		if (option != ""):
+			if (assoc_name != ""):
+				if (is_nominal_instance(model, option, assoc_name)):
+					set_add(result, option)
+			else:
 				set_add(result, option)
 				set_add(result, option)
-		else:
-			set_add(result, option)
 		i = i + 1
 		i = i + 1
 
 
 	return result!
 	return result!

+ 2 - 1
kernel/modelverse_kernel/compiled.py

@@ -22,7 +22,8 @@ def reverseKeyLookupMulti(a, b, **remainder):
 
 
 def reverseKeyLookup(a, b, **remainder):
 def reverseKeyLookup(a, b, **remainder):
     if a is None or b is None:
     if a is None or b is None:
-        print("ERROR @ reverseKeyLookup: " + str(locals()))
+        result, = yield [("CNV", [""])]
+        raise PrimitiveFinished(result)
     edges_out, edges_in = yield [("RO", [a]), ("RI", [b])]
     edges_out, edges_in = yield [("RO", [a]), ("RI", [b])]
     options = set(edges_out) & set(edges_in)
     options = set(edges_out) & set(edges_in)
     if options:
     if options:

+ 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 Nov 23 11:56:08 2017
+Date:   Fri Nov 24 09:21:18 2017
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server