|
@@ -83,7 +83,7 @@ Void function retype(model : Element, element : String, type : String):
|
|
|
// Retype a model, deleting any previous type the element had
|
|
|
// The type string is evaluated in the metamodel previously specified
|
|
|
if (dict_in_node(model["type_mapping"], model["model"][element])):
|
|
|
- dict_delete(model["type_mapping"], model["model"][element])
|
|
|
+ dict_delete_node(model["type_mapping"], model["model"][element])
|
|
|
dict_add(model["type_mapping"], model["model"][element], model["metamodel"]["model"][type])
|
|
|
|
|
|
return!
|
|
@@ -165,7 +165,6 @@ Void function instantiate_attribute(model : Element, element : String, attribute
|
|
|
// Actually a bit more difficult than all the rest, as we need to find the attribute to instantiate
|
|
|
String attr_type
|
|
|
String attr_name
|
|
|
- log("Add attribute")
|
|
|
|
|
|
attr_type = find_attribute_type(model, element, attribute_name)
|
|
|
|
|
@@ -175,13 +174,10 @@ Void function instantiate_attribute(model : Element, element : String, attribute
|
|
|
|
|
|
if (set_in_node(model["model"], value)):
|
|
|
attr_name = reverseKeyLookup(model["model"], value)
|
|
|
- log("Reuse attribute " + attr_name)
|
|
|
else:
|
|
|
attr_name = model_add_value(model, (element + ".") + attribute_name, value)
|
|
|
retype(model, attr_name, reverseKeyLookup(model["metamodel"]["model"], read_edge_dst(model["metamodel"]["model"][attr_type])))
|
|
|
- log("Added attribute " + attr_name)
|
|
|
instantiate_link(model, attr_type, "", element, attr_name)
|
|
|
- log("instantiated link OK")
|
|
|
|
|
|
return!
|
|
|
|
|
@@ -203,7 +199,7 @@ Void function define_inheritance(model : Element, inheritance_name : String):
|
|
|
Void function model_delete_element(model : Element, name : String):
|
|
|
// Remove the link
|
|
|
// 1) from the type mapping
|
|
|
- dict_delete(model["type_mapping"], model["model"][name])
|
|
|
+ dict_delete_node(model["type_mapping"], model["model"][name])
|
|
|
|
|
|
// 2) from the model
|
|
|
delete_element(model["model"][name])
|
|
@@ -238,15 +234,16 @@ Void function unset_attribute(model : Element, element : String, attribute : Str
|
|
|
String attr_type
|
|
|
Element attr_links
|
|
|
String attr_link
|
|
|
+ log((("Unsetting attribute " + attribute) + " of element ") + element)
|
|
|
|
|
|
attr_type = find_attribute_type(model, element, attribute)
|
|
|
attr_links = allOutgoingAssociationInstances(model, element, attr_type)
|
|
|
|
|
|
while (list_len(attr_links) > 0):
|
|
|
attr_link = set_pop(attr_links)
|
|
|
- dict_delete(model["type_mapping"], read_edge_dst(model["model"][attr_link]))
|
|
|
- dict_delete(model["type_mapping"], model["model"][attr_link])
|
|
|
- dict_delete(model["model"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
|
|
|
+ dict_delete_node(model["type_mapping"], read_edge_dst(model["model"][attr_link]))
|
|
|
+ dict_delete_node(model["type_mapping"], model["model"][attr_link])
|
|
|
+ dict_delete_node(model["model"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
|
|
|
delete_element(model["model"][attr_link])
|
|
|
|
|
|
return!
|