Browse Source

Added in new metamodel basics in test

Yentl Van Tendeloo 8 years ago
parent
commit
8d544a7e78

BIN
bootstrap/bootstrap.m.gz


+ 3 - 1
bootstrap/conformance_scd.alc

@@ -71,7 +71,7 @@ Element function precompute_cardinalities(model : Element):
 		if (list_len(tmp_dict) > 0):
 			dict_add(cardinalities, key, tmp_dict)
 
-	keys = allInstances(metamodel, "Attribute")
+	keys = allInstances(metamodel, "AttributeLink")
 	while (0 < list_len(keys)):
 		key = set_pop(keys)
 		tmp_dict = create_node()
@@ -147,6 +147,8 @@ String function conformance_scd(model : Element):
 				dst_metamodel = reverseKeyLookup(metamodel["model"], read_edge_dst(metamodel["model"][typing[model_name]]))
 
 				if (bool_not(is_nominal_instance(model, src_model, src_metamodel))):
+					log("got: " + src_model)
+					log("expected: " + src_metamodel)
 					return "Source of model edge not typed by source of type: " + model_info(model, model_name)!
 
 				if (bool_not(is_nominal_instance(model, dst_model, dst_metamodel))):

+ 21 - 21
bootstrap/metamodels.alc

@@ -155,45 +155,51 @@ Element function initialize_SCD(location : String):
 	if (element_neq(import_node(location), read_root())):
 		return import_node(location)!
 
+	// Temporarily disable during tests
+	return create_node()!
+
 	Element scd
 	scd = instantiate_bottom()
 
 	model_add_node(scd, "Element")
 	model_add_node(scd, "Class")
-	model_add_node(scd, "AttributeValue")
+	model_add_node(scd, "Attribute")
+	model_add_node(scd, "SimpleAttribute")
 	model_add_node(scd, "String")
 	model_add_value(scd, "name_value", "name")
 	model_add_edge(scd, "Association", "Class", "Class")
 	model_add_edge(scd, "Inheritance", "Element", "Element")
-	model_add_edge(scd, "Attribute", "Element", "AttributeValue")
-	model_add_edge(scd, "attr_name", "Attribute", "String")
+	model_add_edge(scd, "AttributeLink", "Element", "Attribute")
+	model_add_edge(scd, "attr_name", "AttributeLink", "String")
 	model_add_edge(scd, "attr_name_name", "attr_name", "name_value")
 	model_add_edge(scd, "class_inh_element", "Class", "Element")
-	model_add_edge(scd, "attributevalue_inh_element", "AttributeValue", "Element")
-	model_add_edge(scd, "association_inh_class", "Association", "Class")
-	model_add_edge(scd, "attribute_inh_attributevalue", "Attribute", "AttributeValue")
+	model_add_edge(scd, "attribute_inh_element", "Attribute", "Element")
+	model_add_edge(scd, "association_inh_element", "Association", "Element")
+	model_add_edge(scd, "attributelink_inh_element", "AttributeLink", "Element")
 
 	// Retype to self
 	retype_model(scd, scd)
 	retype(scd, "Element", "Class")
 	retype(scd, "Class", "Class")
-	retype(scd, "AttributeValue", "Class")
-	retype(scd, "String", "AttributeValue")
+	retype(scd, "Attribute", "Class")
+	retype(scd, "SimpleAttribute", "Class")
+	retype(scd, "String", "Attribute")
 	retype(scd, "name_value", "String")
 	retype(scd, "Association", "Association")
 	retype(scd, "Inheritance", "Association")
-	retype(scd, "Attribute", "Association")
+	retype(scd, "AttributeLink", "Association")
 	retype(scd, "attr_name", "Attribute")
 	retype(scd, "attr_name_name", "attr_name")
 	retype(scd, "class_inh_element", "Inheritance")
-	retype(scd, "attributevalue_inh_element", "Inheritance")
-	retype(scd, "association_inh_class", "Inheritance")
-	retype(scd, "attribute_inh_attributevalue", "Inheritance")
+	retype(scd, "attribute_inh_element", "Inheritance")
+	retype(scd, "association_inh_element", "Inheritance")
+	retype(scd, "attributelink_inh_element", "Inheritance")
 
 	// Add some attributes, now that it is an ordinary model
-	instantiate_node(scd, "AttributeValue", "Natural")
-	instantiate_node(scd, "AttributeValue", "Boolean")
-	instantiate_link(scd, "Attribute", "attr_optional", "Attribute", "Boolean")
+	instantiate_node(scd, "SimpleAttribute", "Location")
+	instantiate_node(scd, "SimpleAttribute", "Natural")
+	instantiate_node(scd, "SimpleAttribute", "Boolean")
+	instantiate_link(scd, "AttributeLink", "attr_optional", "Attribute", "Boolean")
 	instantiate_attribute(scd, "attr_optional", "name", "optional")
 	instantiate_attribute(scd, "attr_optional", "optional", False)
 	instantiate_attribute(scd, "attr_name", "optional", False)
@@ -204,12 +210,6 @@ Element function initialize_SCD(location : String):
 	model_define_attribute(scd, "Association", "source_upper_cardinality", True, "Natural")
 	model_define_attribute(scd, "Association", "target_upper_cardinality", True, "Natural")
 
-	// Make all primitives inherit from primitive type
-	instantiate_node(scd, "AttributeValue", "PrimitiveType")
-	instantiate_link(scd, "Inheritance", "", "Natural", "PrimitiveType")
-	instantiate_link(scd, "Inheritance", "", "String", "PrimitiveType")
-	instantiate_link(scd, "Inheritance", "", "Boolean", "PrimitiveType")
-
 	// Add in the Action Language metamodel
 	add_AL_to_MM(scd)
 

+ 2 - 2
bootstrap/modelling.alc

@@ -327,7 +327,7 @@ String function model_define_attribute(model : Element, elem : String, name : St
 		edge_name = edge_name + cast_id2s(model["model"][elem])
 		log("Name clash detected for attribute: try new name: " + edge_name)
 
-	edge_name = instantiate_link(model, "Attribute", edge_name, elem, type)
+	edge_name = instantiate_link(model, "AttributeLink", edge_name, elem, type)
 	instantiate_attribute(model, edge_name, "name", name)
 	instantiate_attribute(model, edge_name, "optional", optional)
 
@@ -446,7 +446,7 @@ String function add_AL(model : Element, element : Element):
 				if (is_physical_action(elem)):
 					type = cast_a2s(elem)
 				else:
-					type = "PrimitiveType"
+					type = "Element"
 
 			// Add the node itself
 			elem_name = "__" + cast_id2s(elem)

+ 4 - 4
bootstrap/ramify.alc

@@ -24,10 +24,10 @@ Element function ramify(model : Element):
 	mm = new_model["metamodel"]["model"]
 
 	// Add in some primitives
-	instantiate_node(new_model, "AttributeValue", "Natural")
-	instantiate_node(new_model, "AttributeValue", "String")
-	instantiate_node(new_model, "AttributeValue", "Boolean")
-	instantiate_node(new_model, "AttributeValue", "Element")
+	instantiate_node(new_model, "SimplAttribute", "Natural")
+	instantiate_node(new_model, "SimplAttribute", "String")
+	instantiate_node(new_model, "SimplAttribute", "Boolean")
+	instantiate_node(new_model, "SimplAttribute", "Element")
 
 	// Add in the complete AL metamodel
 	add_AL_to_MM(new_model)

+ 28 - 24
integration/test_constructors_models.py

@@ -9,52 +9,56 @@ bottom = [
         "instantiate_bottom", "1",
         "add_node", "1", "Element",
         "add_node", "1", "Class",
-        "add_node", "1", "AttributeValue",
+        "add_node", "1", "Attribute",
+        "add_node", "1", "SimpleAttribute",
         "add_node", "1", "String",
         "add_value", "1", "name_value", "name",
         "add_edge", "1", "Association", "Class", "Class",
         "add_edge", "1", "Inheritance", "Element", "Element",
-        "add_edge", "1", "Attribute", "Element", "AttributeValue",
-        "add_edge", "1", "attr_name", "Attribute", "String",
+        "add_edge", "1", "AttributeLink", "Element", "Attribute",
+        "add_edge", "1", "attr_name", "AttributeLink", "String",
         "add_edge", "1", "attr_name_name", "attr_name", "name_value",
         "add_edge", "1", "class_inh_element", "Class", "Element",
-        "add_edge", "1", "attributevalue_inh_element", "AttributeValue", "Element",
-        "add_edge", "1", "association_inh_class", "Association", "Class",
-        "add_edge", "1", "attribute_inh_attributevalue", "Attribute", "AttributeValue",
+        "add_edge", "1", "attribute_inh_element", "Attribute", "Element",
+        "add_edge", "1", "simple_inh_attribute", "SimpleAttribute", "Attribute",
+        "add_edge", "1", "association_inh_element", "Association", "Element",
+        "add_edge", "1", "attributelink_inh_element", "AttributeLink", "Element",
 
         "retype_model", "1", "1",
         "retype", "1", "Element", "Class",
         "retype", "1", "Class", "Class",
-        "retype", "1", "AttributeValue", "Class",
-        "retype", "1", "String", "AttributeValue",
+        "retype", "1", "Attribute", "Class",
+        "retype", "1", "SimpleAttribute", "Class",
+        "retype", "1", "String", "SimpleAttribute",
         "retype", "1", "name_value", "String",
         "retype", "1", "Association", "Association",
         "retype", "1", "Inheritance", "Association",
-        "retype", "1", "Attribute", "Association",
-        "retype", "1", "attr_name", "Attribute",
+        "retype", "1", "AttributeLink", "Association",
+        "retype", "1", "attr_name", "AttributeLink",
         "retype", "1", "attr_name_name", "attr_name",
         "retype", "1", "class_inh_element", "Inheritance",
-        "retype", "1", "attributevalue_inh_element", "Inheritance",
-        "retype", "1", "association_inh_class", "Inheritance",
-        "retype", "1", "attribute_inh_attributevalue", "Inheritance",
+        "retype", "1", "attribute_inh_element", "Inheritance",
+        "retype", "1", "simple_inh_attribute", "Inheritance",
+        "retype", "1", "association_inh_element", "Inheritance",
+        "retype", "1", "attributelink_inh_element", "Inheritance",
 
-        "instantiate_node", "1", "AttributeValue", "PrimitiveType",
-        "instantiate_node", "1", "AttributeValue", "Natural",
-        "instantiate_node", "1", "AttributeValue", "Boolean",
-        "instantiate_link", "1", "Attribute", "attr_optional", "Attribute", "Boolean",
+        "instantiate_node", "1", "SimpleAttribute", "Location",
+        "instantiate_node", "1", "SimpleAttribute", "Natural",
+        "instantiate_node", "1", "SimpleAttribute", "Boolean",
+        "instantiate_link", "1", "AttributeLink", "attr_optional", "AttributeLink", "Boolean",
         "instantiate_attribute", "1", "attr_optional", "name", "optional",
         "instantiate_attribute", "1", "attr_optional", "optional", False,
         "instantiate_attribute", "1", "attr_name", "optional", False,
         "model_define_attribute", "1", "Class", "lower_cardinality", True, "Natural",
         "model_define_attribute", "1", "Class", "upper_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Class", "source_lower_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Class", "source_upper_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Class", "target_lower_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Class", "target_upper_cardinality", True, "Natural",
+        "model_define_attribute", "1", "Association", "source_lower_cardinality", True, "Natural",
+        "model_define_attribute", "1", "Association", "source_upper_cardinality", True, "Natural",
+        "model_define_attribute", "1", "Association", "target_lower_cardinality", True, "Natural",
+        "model_define_attribute", "1", "Association", "target_upper_cardinality", True, "Natural",
 
-        "instantiate_link", "1", "Inheritance", "", "Natural", "PrimitiveType",
-        "instantiate_link", "1", "Inheritance", "", "Boolean", "PrimitiveType",
-        "instantiate_link", "1", "Inheritance", "", "String", "PrimitiveType",
+        "instantiate_node", "1", "Class", "ComplexAttribute",
+        "instantiate_link", "1", "", "Inheritance", "ComplexAttribute", "Attribute",
+        "model_define_attribute", "1", "ComplexAttribute", "type", False, "Location",
 
         "export_node", "1", "models/SimpleClassDiagrams_new",
         "exit",