浏览代码

Make used inheritance link hardcoded

Yentl Van Tendeloo 8 年之前
父节点
当前提交
ed364ab8ef

二进制
bootstrap/bootstrap.m.gz


+ 0 - 3
bootstrap/metamodels.alc

@@ -164,7 +164,6 @@ Element function initialize_SCD(location : String):
 
 	// Retype to a "real" LTM, which happens to be itself
 	retype_model(scd, scd)
-	define_inheritance(scd, "Inheritance")
 	retype(scd, "Class", "Class")
 	retype(scd, "Any", "Class")
 	retype(scd, "String", "Class")
@@ -230,7 +229,6 @@ Element function initialize_PN(location_SCD : String, location_PN : String):
 	scd = import_node(location_SCD)
 
 	pn = instantiate_model(scd)
-	define_inheritance(pn, "Inheritance")
 	instantiate_node(pn, "Class", "Place")
 	instantiate_node(pn, "Class", "Transition")
 	instantiate_node(pn, "Class", "Natural")
@@ -265,7 +263,6 @@ Element function initialize_bottom(location_bottom : String):
 	model_add_edge(ltm_bottom, "__inh", "Edge", "Node")
 
 	retype_model(ltm_bottom, ltm_bottom)
-	define_inheritance(ltm_bottom, "inheritance")
 	retype(ltm_bottom, "Node", "Node")
 	retype(ltm_bottom, "Edge", "Edge")
 	retype(ltm_bottom, "inheritance", "Edge")

二进制
bootstrap/minimal.m.gz


+ 0 - 2
bootstrap/model_management.alc

@@ -20,7 +20,6 @@ Element function model_fuse(name1 : String, model1 : Element, name2 : String, mo
 	// Read out some data first
 	selected_MM = model1["metamodel"]
 	new_model = instantiate_model(selected_MM)
-	dict_add(new_model, "inheritance", model1["inheritance"])
 
 	// Create a list to nicely iterate over it
 	models = create_node()
@@ -68,7 +67,6 @@ Element function model_copy(src_model : Element):
 	String type
 
 	dst_model = instantiate_model(src_model["metamodel"])
-	dict_add(dst_model, "inheritance", src_model["inheritance"])
 	dict_add(dst_model, "model", create_node())
 	dict_add(dst_model, "type_mapping", create_node())
 

+ 3 - 9
bootstrap/modelling.alc

@@ -137,9 +137,11 @@ Element function get_superclasses(model : Element, name : String):
 	Element edge
 	Element elem
 	Element nodes
+	Element inheritance
 
 	nodes = create_node()
 	set_add(nodes, model["model"][name])
+	inheritance = model["metamodel"]["model"]["Inheritance"]
 
 	// Initialize empty set
 	result = create_node()
@@ -154,7 +156,7 @@ Element function get_superclasses(model : Element, name : String):
 			j = 0
 			while (j < num_edges):
 				edge = read_out(elem, j)
-				if (element_eq(dict_read_node(model["type_mapping"], edge), model["inheritance"])):
+				if (element_eq(dict_read_node(model["type_mapping"], edge), inheritance)):
 					set_add(nodes, read_edge_dst(edge))
 				j = j + 1
 
@@ -269,12 +271,6 @@ String function instantiate_link(model : Element, type : String, name : String,
 	retype(model, actual_name, type)
 	return actual_name!
 
-Void function define_inheritance(model : Element, inheritance_name : String):
-	// Set the inheritance link to the one defined in our own metamodel, given by the specified name
-	dict_add(model, "inheritance", model["metamodel"]["model"][inheritance_name])
-
-	return!
-
 Void function model_delete_element(model : Element, name : String):
 	// Remove the link
 	// 1) from the type mapping
@@ -489,8 +485,6 @@ Void function construct_model():
 			instantiate_attribute_code(global_models[input()], input(), input(), construct_function())
 		elif (command == "instantiate_link"):
 			instantiate_link(global_models[input()], input(), input(), input(), input())
-		elif (command == "define_inheritance"):
-			define_inheritance(global_models[input()], input())
 		elif (command == "add_constraint"):
 			add_constraint(global_models[input()], input(), construct_function())
 		elif (command == "initialize_SCD"):

+ 0 - 1
bootstrap/ramify.alc

@@ -11,7 +11,6 @@ Element function ramify(model : Element):
 	dict_add(new_model, "model", create_node())
 	dict_add(new_model, "type_mapping", create_node())
 	dict_add(new_model, "metamodel", model["metamodel"])
-	dict_add(new_model, "inheritance", model["inheritance"])
 
 	dict_add(new_model, "source", model)
 	dict_add(new_model, "target", model)

+ 0 - 3
integration/test_constructors_models.py

@@ -19,7 +19,6 @@ bottom = [
         "add_edge", "1", "class_inh_any", "Class", "Any",
         "add_edge", "1", "string_inh_any", "String", "Any",
         "retype_model", "1", "1",
-        "define_inheritance", "1", "Inheritance",
         "retype", "1", "Class", "Class",
         "retype", "1", "Any", "Class",
         "retype", "1", "String", "Class",
@@ -211,7 +210,6 @@ def add_constraints(model):
 instantiate_scd = [
         "model",
         "instantiate_model", "1", "2",
-        "define_inheritance", "2", "Inheritance",
         "instantiate_node", "2", "Class", "Place",
         "instantiate_node", "2", "Class", "Transition",
         "instantiate_node", "2", "Class", "Integer",
@@ -251,7 +249,6 @@ instantiate_pn = [
 instantiate_example = [
         "model",
         "instantiate_model", "1", "2",
-        "define_inheritance", "2", "Inheritance",
         "instantiate_node", "2", "Class", "A",
         "instantiate_node", "2", "Class", "B",
         "instantiate_node", "2", "Class", "C",

+ 3 - 3
integration/test_pn_interface.py

@@ -569,7 +569,7 @@ Element function constraint(model : Element, name : String):
             """
             import models/SimpleClassDiagrams as SimpleClassDiagrams
 
-            SimpleClassDiagrams (Inheritance) PetriNets_Runtime{
+            SimpleClassDiagrams PetriNets_Runtime{
                 Class Natural {}
                 Class Boolean {}
                 Class Place {
@@ -835,7 +835,7 @@ Element function constraint(model : Element, name : String):
             """
             import models/SimpleClassDiagrams as SimpleClassDiagrams
 
-            SimpleClassDiagrams (Inheritance) PetriNets_Design{
+            SimpleClassDiagrams PetriNets_Design{
                 Class Natural {}
                 Class Place {
                     tokens : Natural
@@ -849,7 +849,7 @@ Element function constraint(model : Element, name : String):
                 }
             }
 
-            SimpleClassDiagrams (Inheritance) PetriNets_Runtime{
+            SimpleClassDiagrams PetriNets_Runtime{
                 Class Natural {}
                 Class Boolean {}
                 Class String {}

+ 1 - 1
interface/HUTN/grammars/modelling.g

@@ -5,7 +5,7 @@ grammar{
     export: EXPORT MODEL_ID TO MV_URL;
     include_files: INCLUDE STRVALUE NEWLINE;
 
-    model: MODEL_ID (LPAR MODEL_ID RPAR)? MODEL_ID NEWLINE? LCURLY NEWLINE? (model_element)* RCURLY;
+    model: MODEL_ID MODEL_ID NEWLINE? LCURLY NEWLINE? (model_element)* RCURLY;
 
     model_element: MODEL_ID MODEL_ID? inheritance? (LPAR MODEL_ID COMMA MODEL_ID RPAR)? NEWLINE? LCURLY NEWLINE? (model_attribute)* RCURLY NEWLINE?;
 

+ 0 - 2
interface/HUTN/hutn_compiler/model_visitor.py

@@ -46,8 +46,6 @@ class ModelVisitor(Visitor):
         model_type = children[0].get_text()
         model_name = children[-1].get_text()
         self.constructors.extend(["instantiate_model", model_type, model_name])
-        if tree.get_children("LPAR"):
-            self.constructors.extend(["define_inheritance", model_name, tree.get_children("MODEL_ID")[1].get_text()])
         self.current_model = model_name
         for element in tree.get_children("model_element"):
             self.visit(element)

+ 0 - 1
interface/HUTN/includes/modelling.alh

@@ -15,7 +15,6 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 Void function instantiate_attribute_code(model : Element, element : String, attribute_name : String, code : Element)
 Void function instantiate_existing_attribute(model : Element, element : String, attribute_name : String, attribute_ref : String)
 String function instantiate_link(model : Element, type : String, name : String, source : String, destination : String)
-Void function define_inheritance(model : Element, inheritance_name : String)
 Void function unset_attribute(model : Element, elem : String, name : String)
 Void function construct_model()
 Element function read_attribute(model : Element, elem : String, name : String)

文件差异内容过多而无法显示
+ 1 - 1
interface/HUTN/test/modelling_language/expected/my_petrinet


文件差异内容过多而无法显示
+ 1 - 1
interface/HUTN/test/modelling_language/expected/my_petrinet_with_MM


文件差异内容过多而无法显示
+ 1 - 1
interface/HUTN/test/modelling_language/expected/petrinets


文件差异内容过多而无法显示
+ 1 - 1
interface/HUTN/test/modelling_language/expected/petrinets_constraints


文件差异内容过多而无法显示
+ 1 - 1
interface/HUTN/test/modelling_language/expected/simpleclassdiagrams


+ 3 - 1
kernel/modelverse_kernel/compiled.py

@@ -288,7 +288,9 @@ def add_AL(a, b, **remainder):
     raise PrimitiveFinished(result)
 
 def get_superclasses(a, b, **remainder):
-    inheritance, =   yield [("RD", [a, "inheritance"])]
+    mm, =            yield [("RD", [a, "metamodel"])]
+    m, =             yield [("RD", [mm, "model"])]
+    inheritance, =   yield [("RD", [m, "Inheritance"])]
     model_dict, =    yield [("RD", [a, "model"])]
     b_v, =           yield [("RV", [b])]
     subclass, =      yield [("RD", [model_dict, b_v])]