Explorar o código

Fixed some problems in AL type model now that there is an actual model

Yentl Van Tendeloo %!s(int64=9) %!d(string=hai) anos
pai
achega
863ccb163f

+ 19 - 6
bootstrap/conformance_scd.alc

@@ -48,15 +48,17 @@ String function conformance_scd(model : Element):
 	Element metamodel
 	Element typing
 	String model_name
-	Element src_model
-	Element dst_model
-	Element src_metamodel
-	Element dst_metamodel
+	String src_model
+	String dst_model
+	String src_metamodel
+	String dst_metamodel
 	Element element
 	Element check_list
 	String check_type
 	Element cardinalities
 	Element scd
+	String error_msg
+	error_msg = ""
 
 	// Load in variables
 	scd = import_node("models/SimpleClassDiagrams")
@@ -122,6 +124,18 @@ String function conformance_scd(model : Element):
 					return "Source of model edge not typed by source of type: " + model_name
 
 				if (bool_not(is_nominal_instance(model, dst_model, dst_metamodel))):
+					log("ERROR!")
+					log("DMM_name: " + dst_metamodel)
+					log("DM_name : " + dst_model)
+					log("SMM_name: " + src_metamodel)
+					log("SM_name : " + src_model)
+					log("M_name : " + model_name)
+					log("S_name : " + cast_e2s(model["model"][dst_model]))
+					log("D_type : " + cast_v2s(reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], model["model"][dst_model]))))
+					log("LS_name: " + cast_v2s(reverseKeyLookup(model["model"], read_edge_src(model["model"][src_model]))))
+					log("LD_name: " + cast_v2s(reverseKeyLookup(model["model"], read_edge_dst(model["model"][dst_model]))))
+					log("LSTname: " + cast_v2s(reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], read_edge_src(model["model"][src_model])))))
+					log("LDTname: " + cast_v2s(reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], read_edge_dst(model["model"][src_model])))))
 					return "Destination of model edge not typed by source of type: " + model_name
 
 			if (dict_in(cardinalities, model_name)):
@@ -171,12 +185,11 @@ String function conformance_scd(model : Element):
 								return "Upper cardinality violation for incoming edge at " + model_name
 
 			Element constraint_function
-			log("Constraint")
 			constraint_function = read_attribute(model, model_name, "constraint")
 			if (element_neq(constraint_function, read_root())):
 				String result
 				// TODO define the local_constraint execution function
-				log("Exec")
+				log("Exec constraint!")
 				result = execute_local_constraint(model, model_name)
 				log("Result: " + result)
 				if (result != "OK"):

+ 9 - 4
bootstrap/modelling.alc

@@ -243,20 +243,21 @@ Void function add_AL_links(model : Element, list : Element, element : Element, l
 
 	Element link
 	link = dict_read_edge(element, linkname)
+	log(((("LINK with name " + linkname) + " == ") + cast_e2s(link)))
 
 	// The link
-	dict_add(model["model"], "__" + cast_id2s(link), link)
+	dict_add(model["model"], "LNK__" + cast_id2s(link), link)
 	dict_add(model["type_mapping"], link, model["metamodel"]["model"]["dict_link"])
 
 	// The name link
 	link = read_out(link, 0)
-	dict_add(model["model"], "__" + cast_id2s(link), link)
+	dict_add(model["model"], "NLNK__" + cast_id2s(link), link)
 	dict_add(model["type_mapping"], link, model["metamodel"]["model"]["to_str"])
 
 	// The name node
 	link = read_edge_dst(link)
 	if (bool_not(set_in_node(model["model"], link))):
-		dict_add(model["model"], "__" + cast_id2s(link), link)
+		dict_add(model["model"], "NAME__" + cast_id2s(link), link)
 		dict_add(model["type_mapping"], link, model["metamodel"]["model"]["String"])
 
 	// Now add the destination to the worker list
@@ -295,7 +296,7 @@ String function add_AL(model : Element, element : Element):
 					type = "Any"
 
 			// Add the node itself
-			dict_add(model["model"], "__" + cast_id2s(elem), elem)
+			dict_add(model["model"], (type + "__") + cast_id2s(elem), elem)
 			dict_add(model["type_mapping"], elem, model["metamodel"]["model"][type])
 
 			// Now add its edges
@@ -326,18 +327,22 @@ String function add_AL(model : Element, element : Element):
 				add_AL_links(model, todo, elem, "node", "")
 			elif (type == "output"):
 				add_AL_links(model, todo, elem, "node", "")
+				add_AL_links(model, todo, elem, "next", "")
 			elif (type == "global"):
 				add_AL_links(model, todo, elem, "var", "String")
+				add_AL_links(model, todo, elem, "next", "")
 			elif (type == "param"):
 				add_AL_links(model, todo, elem, "name", "String")
 				add_AL_links(model, todo, elem, "value", "")
 				add_AL_links(model, todo, elem, "next_param", "param")
 			elif (type == "funcdef"):
 				add_AL_links(model, todo, elem, "body", "")
+				add_AL_links(model, todo, elem, "next", "")
 			elif (type == "call"):
 				add_AL_links(model, todo, elem, "func", "")
 				add_AL_links(model, todo, elem, "params", "param")
 				add_AL_links(model, todo, elem, "last_param", "param")
+				add_AL_links(model, todo, elem, "next", "")
 			else:
 				log("Unknown type found in AL parser: " + type)
 

+ 6 - 7
integration/test_constructors_models.py

@@ -17,7 +17,6 @@ bottom = [
         '"model"',
         '"instantiate_bottom"', 1,
         '"add_node"', 1, '"Class"', 
-        '"add_node"', 1, '"Type"',
         '"add_node"', 1, '"Any"',
         '"add_node"', 1, '"String"',
         '"add_node"', 1, '"Integer"',
@@ -25,7 +24,7 @@ bottom = [
         '"add_value"', 1, '"link"', '"link"',
         '"add_value"', 1, '"name"', '"name"',
         '"add_edge"', 1, '"l1"', '"Class"', '"Any"',
-        '"add_edge"', 1, '"l2"', '"Type"', '"Any"',
+        '"add_edge"', 1, '"l2"', '"String"', '"Any"',
         '"add_edge"', 1, '"Inheritance"', '"Any"', '"Any"',
         '"add_edge"', 1, '"l4"', '"Inheritance"', '"inheritance"',
         '"add_edge"', 1, '"Association"', '"Any"', '"Any"',
@@ -33,6 +32,7 @@ bottom = [
         '"add_edge"', 1, '"l7"', '"Association"', '"link"',
         '"add_edge"', 1, '"l8"', '"Association"', '"String"',
         '"add_edge"', 1, '"l9"', '"l8"', '"name"',
+        '"add_edge"', 1, '"l10"', '"Integer"', '"Any"',
         '"exit"',
     ]
 
@@ -41,10 +41,9 @@ retype = [
         '"retype_model"', 1, 1,
         '"define_inheritance"', 1, '"Inheritance"',
         '"retype"', 1, '"Class"', '"Class"',
-        '"retype"', 1, '"Type"', '"Class"',
+        '"retype"', 1, '"String"', '"Class"',
         '"retype"', 1, '"Any"', '"Class"',
-        '"retype"', 1, '"String"', '"Type"',
-        '"retype"', 1, '"Integer"', '"Type"',
+        '"retype"', 1, '"Integer"', '"Class"',
         '"retype"', 1, '"inheritance"', '"String"',
         '"retype"', 1, '"link"', '"String"',
         '"retype"', 1, '"name"', '"String"',
@@ -81,7 +80,7 @@ action_language = [
         '"instantiate_node"', 1, '"Class"', '"input"',
         '"instantiate_node"', 1, '"Class"', '"resolve"',
         '"instantiate_node"', 1, '"Class"', '"call"',
-        '"instantiate_link"', 1, '"Association"', '"dict_link"', '"Action"', '"Action"',
+        '"instantiate_link"', 1, '"Association"', '"dict_link"', '"Action"', '"Any"',
         '"instantiate_link"', 1, '"Association"', '"to_str"', '"dict_link"', '"String"',
         '"instantiate_attribute"', 1, '"to_str"', '"name"', '"name"',
         '"instantiate_link"', 1, '"Inheritance"', '""', '"Action"', '"Any"',
@@ -200,7 +199,7 @@ instantiate_scd = [
         '"define_inheritance"', 2, '"Inheritance"',
         '"instantiate_node"', 2, '"Class"', '"Place"',
         '"instantiate_node"', 2, '"Class"', '"Transition"',
-        '"instantiate_node"', 2, '"Type"', '"Integer"',
+        '"instantiate_node"', 2, '"Class"', '"Integer"',
         '"instantiate_link"', 2, '"Association"', '"P2T"', '"Place"', '"Transition"',
         '"instantiate_link"', 2, '"Association"', '"T2P"', '"Transition"', '"Place"',
         '"instantiate_link"', 2, '"Association"', '"Place_tokens"', '"Place"', '"Integer"',