Browse Source

Fixed object_operations, which weren't adapted to changed interface yet

Yentl Van Tendeloo 9 years ago
parent
commit
bc1c9b0e9c
2 changed files with 8 additions and 6 deletions
  1. 7 5
      bootstrap/object_operations.alc
  2. 1 1
      integration/code/pn_interface.alc

+ 7 - 5
bootstrap/object_operations.alc

@@ -16,9 +16,11 @@ Element function allInstances(model : Element, type_name : String):
 
 	while (0 < list_len(keys)):
 		key = set_pop(keys)
-		if (is_nominal_instance(model, model["model"][key], type)):
+		if (is_nominal_instance(model, key, type_name)):
+			log("Found instance of " + type_name)
 			set_add(result, key)
 
+	log("Finished searching for instances")
 	return result
 
 Element function selectPossibleIncoming(model : Element, target : String, limit_set : Element):
@@ -39,7 +41,7 @@ Element function selectPossibleIncoming(model : Element, target : String, limit_
 		type = set_pop(limit_set)
 		elem = metamodel_dict[type]
 		if (is_edge(elem)):
-			if (is_nominal_instance(model, target_element, read_edge_dst(elem))):
+			if (is_nominal_instance(model, target, reverseKeyLookup(metamodel_dict, read_edge_dst(elem)))):
 				set_add(result, type)
 	
 	return result
@@ -61,7 +63,7 @@ Element function selectPossibleOutgoing(model : Element, source : String, limit_
 		type = set_pop(limit_set)
 		elem = metamodel_dict[type]
 		if (is_edge(elem)):
-			if (is_nominal_instance(model, source_element, read_edge_src(elem))):
+			if (is_nominal_instance(model, source, reverseKeyLookup(metamodel_dict, read_edge_src(elem)))):
 				set_add(result, type)
 	
 	return result
@@ -83,7 +85,7 @@ Element function allOutgoingAssociationInstances(model : Element, source_name :
 		out = read_out(model["model"][source_name], i)
 		if (set_in_node(model["model"], out)):
 			out_name = reverseKeyLookup(model["model"], out)
-			if (is_nominal_instance(model, out, model["metamodel"]["model"][assoc_name])):
+			if (is_nominal_instance(model, out_name, assoc_name)):
 				set_add(result, out_name)
 		i = i + 1
 	return result
@@ -103,7 +105,7 @@ Element function allIncomingAssociationInstances(model : Element, target_name :
 		in = read_in(model["model"][target_name], i)
 		if (set_in_node(model["model"], in)):
 			in_name = reverseKeyLookup(model["model"], in)
-			if (is_nominal_instance(model, in, model["metamodel"]["model"][assoc_name])):
+			if (is_nominal_instance(model, in_name, assoc_name)):
 				set_add(result, in_name)
 		i = i + 1
 	return result

+ 1 - 1
integration/code/pn_interface.alc

@@ -47,7 +47,7 @@ Element function petrinet_enabled_set(model : Element):
 			Integer required_tokens
 			required_tokens = read_attribute(model, arc_under_study, "weight")
 			log("Weight: " + cast_i2s(required_tokens))
-			present_tokens = read_attribute(model, getName(model, read_edge_src(model["model"][arc_under_study])), "tokens")
+			present_tokens = read_attribute(model, reverseKeyLookup(model["model"], read_edge_src(model["model"][arc_under_study])), "tokens")
 			log("Tokens: " + cast_i2s(present_tokens))
 			if (present_tokens < required_tokens):
 				// Less tokens than required, so disable the transition completely