|
@@ -10,6 +10,7 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
dict_add(new_model, "model", 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
|
|
@@ -24,12 +25,18 @@ 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")
|
|
|
|
|
|
// Add in the complete AL metamodel
|
|
|
- add_AL_to_MM(new_model)
|
|
|
+ //TODO this is broken right now because of the use of Any in the AL MM
|
|
|
+ //add_AL_to_MM(new_model)
|
|
|
+ //TODO temporarily add them like this
|
|
|
+ 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 {
|
|
@@ -45,9 +52,11 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
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 {
|
|
@@ -66,14 +75,17 @@ 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"
|
|
|
|
|
@@ -91,6 +103,7 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
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 {
|
|
@@ -109,10 +122,12 @@ 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"
|
|
|
|
|
@@ -131,15 +146,19 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
String type_name
|
|
|
String old_source
|
|
|
String old_target
|
|
|
+ log("Iterate!")
|
|
|
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))
|
|
|
if (type_name == "Class"):
|
|
|
+ log("Class")
|
|
|
instantiate_node(new_model, type_name, append + key)
|
|
|
|
|
|
- elif (bool_or(type_name == "Association", type_name == "Inheritance")):
|
|
|
+ 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)
|
|
@@ -147,7 +166,14 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
// 1) Make it inherit from the Root Element (Pre_Element or Post_Element)
|
|
|
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")
|
|
|
// Primitive values themselves are not copied, so skip that here
|
|
|
|
|
|
// An instance link, so just copy over (don't make element of Root Element), and don't even copy if it is lower cardinality
|
|
@@ -159,6 +185,7 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
|
|
|
instantiate_attribute(new_model, append + old_source, append + name, read_edge_dst(entry))
|
|
|
|
|
|
+ log("Finished")
|
|
|
return new_model!
|
|
|
|
|
|
Element function ramify(model : Element):
|
|
@@ -166,9 +193,12 @@ 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!
|