|
@@ -11,7 +11,6 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
dict_add(new_model, "type_mapping", create_node())
|
|
|
dict_add(new_model, "metamodel", model["metamodel"])
|
|
|
dict_add(new_model, "inheritance", model["inheritance"])
|
|
|
- log("Copied basic data")
|
|
|
|
|
|
// Get local variables for parts
|
|
|
Element old_m
|
|
@@ -26,7 +25,6 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
is_pre = (prepost == "pre")
|
|
|
|
|
|
// Add in Natural and String
|
|
|
- log("Adding Natural and String")
|
|
|
instantiate_node(new_model, "Class", "Natural")
|
|
|
instantiate_node(new_model, "Class", "String")
|
|
|
|
|
@@ -37,7 +35,6 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
instantiate_node(new_model, "Class", "Expression")
|
|
|
instantiate_node(new_model, "Class", "FuncDef")
|
|
|
|
|
|
- log("Adding default elements")
|
|
|
// Add some default elements
|
|
|
if (is_pre):
|
|
|
// Class LHS {
|
|
@@ -47,18 +44,15 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
// upper_cardinality = 1
|
|
|
// lower_cardinality = 1
|
|
|
// }
|
|
|
- log("LHS")
|
|
|
instantiate_node(new_model, "Class", "LHS")
|
|
|
instantiate_attribute(new_model, "LHS", "lower_cardinality", 1)
|
|
|
instantiate_attribute(new_model, "LHS", "upper_cardinality", 1)
|
|
|
instantiate_link(new_model, "Association", "LHS_constraint", "LHS", "Expression")
|
|
|
instantiate_attribute(new_model, "LHS_constraint", "name", "constraint")
|
|
|
instantiate_attribute(new_model, "LHS_constraint", "target_upper_cardinality", 1)
|
|
|
- log("LHS OK")
|
|
|
|
|
|
// Class NAC {}
|
|
|
instantiate_node(new_model, "Class", "NAC")
|
|
|
- log("NAC OK")
|
|
|
|
|
|
// Class Pre_Element {
|
|
|
// label : String {
|
|
@@ -77,17 +71,14 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
instantiate_link(new_model, "Association", "Pre_Element_constraint", "Pre_Element", "Expression")
|
|
|
instantiate_attribute(new_model, "Pre_Element_constraint", "name", "constraint")
|
|
|
instantiate_attribute(new_model, "Pre_Element_constraint", "target_upper_cardinality", 1)
|
|
|
- log("Pre_Element OK")
|
|
|
|
|
|
// Association LHS_contains (LHS, Pre_Element) {}
|
|
|
instantiate_link(new_model, "Association", "LHS_contains", "LHS", "Pre_Element")
|
|
|
instantiate_attribute(new_model, "LHS_contains", "name", "contains")
|
|
|
- log("LHS_contains OK")
|
|
|
|
|
|
// Association NAC_contains (NAC, Pre_Element) {}
|
|
|
instantiate_link(new_model, "Association", "NAC_contains", "NAC", "Pre_Element")
|
|
|
instantiate_attribute(new_model, "NAC_contains", "name", "contains")
|
|
|
- log("NAC_contains OK")
|
|
|
|
|
|
inheritor = "Pre_Element"
|
|
|
|
|
@@ -99,14 +90,12 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
// upper_cardinality = 1
|
|
|
// lower_cardinality = 1
|
|
|
// }
|
|
|
- log("RHS")
|
|
|
instantiate_node(new_model, "Class", "RHS")
|
|
|
instantiate_attribute(new_model, "RHS", "lower_cardinality", 1)
|
|
|
instantiate_attribute(new_model, "RHS", "upper_cardinality", 1)
|
|
|
instantiate_link(new_model, "Association", "RHS_action", "RHS", "FuncDef")
|
|
|
instantiate_attribute(new_model, "RHS_action", "name", "action")
|
|
|
instantiate_attribute(new_model, "RHS_action", "target_upper_cardinality", 1)
|
|
|
- log("RHS OK")
|
|
|
|
|
|
// Class Post_Element {
|
|
|
// label : String {
|
|
@@ -125,12 +114,10 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
instantiate_link(new_model, "Association", "Post_Element_value", "Post_Element", "Expression")
|
|
|
instantiate_attribute(new_model, "Post_Element_value", "name", "value")
|
|
|
instantiate_attribute(new_model, "Post_Element_value", "target_upper_cardinality", 1)
|
|
|
- log("Post_Element OK")
|
|
|
|
|
|
// Association RHS_contains (RHS, Post_Element) {}
|
|
|
instantiate_link(new_model, "Association", "RHS_contains", "RHS", "Post_Element")
|
|
|
instantiate_attribute(new_model, "RHS_contains", "name", "contains")
|
|
|
- log("RHS_contains OK")
|
|
|
|
|
|
inheritor = "Post_Element"
|
|
|
|
|
@@ -149,26 +136,21 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
String type_name
|
|
|
String old_source
|
|
|
String old_target
|
|
|
- log("Iterate!")
|
|
|
Element to_link
|
|
|
to_link = create_node()
|
|
|
|
|
|
while (read_nr_out(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
entry = old_m[key]
|
|
|
- log("Try " + key)
|
|
|
|
|
|
type_name = reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], entry))
|
|
|
- log("Type Name: " + cast_e2s(type_name))
|
|
|
if (type_name == "Class"):
|
|
|
- log("Class")
|
|
|
instantiate_node(new_model, type_name, append + key)
|
|
|
|
|
|
// Also make it inherit from the "root element"
|
|
|
instantiate_link(new_model, "Inheritance", "", append + key, inheritor)
|
|
|
|
|
|
elif (type_name == "Association"):
|
|
|
- log("Association")
|
|
|
old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
|
|
|
old_target = reverseKeyLookup(model["model"], read_edge_dst(entry))
|
|
|
instantiate_link(new_model, type_name, append + key, append + old_source, append + old_target)
|
|
@@ -177,13 +159,11 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
instantiate_link(new_model, "Inheritance", "", append + key, inheritor)
|
|
|
|
|
|
elif (type_name == "Inheritance"):
|
|
|
- log("Inheritance")
|
|
|
old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
|
|
|
old_target = reverseKeyLookup(model["model"], read_edge_dst(entry))
|
|
|
instantiate_link(new_model, type_name, append + key, append + old_source, append + old_target)
|
|
|
|
|
|
elif (bool_not(has_value(entry))):
|
|
|
- log("Attribute")
|
|
|
create_edge(to_link, entry)
|
|
|
|
|
|
while (read_nr_out(to_link) > 0):
|
|
@@ -205,7 +185,6 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
// Rename the attributes as well
|
|
|
instantiate_attribute(new_model, append + old_source, append + name, read_edge_dst(entry))
|
|
|
|
|
|
- log("Finished")
|
|
|
return new_model!
|
|
|
|
|
|
Element function ramify(model : Element):
|
|
@@ -213,12 +192,9 @@ Element function ramify(model : Element):
|
|
|
rv = create_node()
|
|
|
|
|
|
// Create Pre part
|
|
|
- log("PRE")
|
|
|
dict_add(rv, "pre", ramify_func(model, "pre"))
|
|
|
|
|
|
// Create Post part
|
|
|
- log("POST")
|
|
|
dict_add(rv, "post", ramify_func(model, "post"))
|
|
|
|
|
|
- log("FINISHED")
|
|
|
return rv!
|