|
@@ -9,9 +9,9 @@ Element global_models = ?
|
|
|
|
|
|
String function instantiated_name(element : Element, original : String):
|
|
|
if (original == ""):
|
|
|
- return "__" + cast_id2s(element)
|
|
|
+ return "__" + cast_id2s(element)!
|
|
|
else:
|
|
|
- return original
|
|
|
+ return original!
|
|
|
|
|
|
Element function instantiate_bottom():
|
|
|
// Just create a new node that serves as the basis for everything
|
|
@@ -26,7 +26,7 @@ Element function instantiate_bottom():
|
|
|
dict_add(new_model, "type_mapping", create_node())
|
|
|
|
|
|
// Return the created model
|
|
|
- return new_model
|
|
|
+ return new_model!
|
|
|
|
|
|
String function model_add_node(model : Element, name : String):
|
|
|
// Adds a new node to the specified model with the desired name
|
|
@@ -38,7 +38,7 @@ String function model_add_node(model : Element, name : String):
|
|
|
actual_name = instantiated_name(new_node, name)
|
|
|
dict_add(model["model"], actual_name, new_node)
|
|
|
|
|
|
- return actual_name
|
|
|
+ return actual_name!
|
|
|
|
|
|
String function model_add_value(model : Element, name : String, value : Element):
|
|
|
// Similar to model_add_node, but add a value as well
|
|
@@ -47,7 +47,7 @@ String function model_add_value(model : Element, name : String, value : Element)
|
|
|
actual_name = instantiated_name(value, name)
|
|
|
dict_add(model["model"], actual_name, value)
|
|
|
|
|
|
- return actual_name
|
|
|
+ return actual_name!
|
|
|
|
|
|
String function model_add_edge(model : Element, name : String, source : String, destination : String):
|
|
|
// Add an edge between the source and destination nodes
|
|
@@ -59,25 +59,25 @@ String function model_add_edge(model : Element, name : String, source : String,
|
|
|
log("In link " + name)
|
|
|
log("ERROR: source of link unknown: " + source)
|
|
|
log("Destination: " + destination)
|
|
|
- return ""
|
|
|
+ return ""!
|
|
|
if (bool_not(dict_in(model["model"], destination))):
|
|
|
log("In link " + name)
|
|
|
log("ERROR: destination of link unknown: " + destination)
|
|
|
log("Source: " + source)
|
|
|
- return ""
|
|
|
+ return ""!
|
|
|
|
|
|
new_edge = create_edge(model["model"][source], model["model"][destination])
|
|
|
actual_name = instantiated_name(new_edge, name)
|
|
|
dict_add(model["model"], actual_name, new_edge)
|
|
|
|
|
|
- return actual_name
|
|
|
+ return actual_name!
|
|
|
|
|
|
Void function retype_model(model : Element, metamodel : Element):
|
|
|
// Remove the type mapping and add a new one for the specified metamodel
|
|
|
dict_delete(model, "type_mapping")
|
|
|
dict_add(model, "type_mapping", create_node())
|
|
|
dict_add(model, "metamodel", metamodel)
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
Void function retype(model : Element, element : String, type : String):
|
|
|
// Retype a model, deleting any previous type the element had
|
|
@@ -86,7 +86,7 @@ Void function retype(model : Element, element : String, type : String):
|
|
|
dict_delete(model["type_mapping"], model["model"][element])
|
|
|
dict_add(model["type_mapping"], model["model"][element], model["metamodel"]["model"][type])
|
|
|
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
Element function instantiate_model(metamodel : Element):
|
|
|
// Instantiate a model
|
|
@@ -94,7 +94,7 @@ Element function instantiate_model(metamodel : Element):
|
|
|
Element model
|
|
|
model = instantiate_bottom()
|
|
|
retype_model(model, metamodel)
|
|
|
- return model
|
|
|
+ return model!
|
|
|
|
|
|
String function instantiate_node(model : Element, type_name : String, instance_name : String):
|
|
|
// Create a node typed by a node from the metamodel
|
|
@@ -104,7 +104,7 @@ String function instantiate_node(model : Element, type_name : String, instance_n
|
|
|
actual_name = model_add_node(model, instance_name)
|
|
|
retype(model, instance_name, type_name)
|
|
|
|
|
|
- return actual_name
|
|
|
+ return actual_name!
|
|
|
|
|
|
String function find_attribute_type(model : Element, elem : String, name : String):
|
|
|
String mm_elem
|
|
@@ -115,9 +115,9 @@ String function find_attribute_type(model : Element, elem : String, name : Strin
|
|
|
|
|
|
if (value_eq(mm_elem, "")):
|
|
|
// Couldn't find element, so is not allowed!
|
|
|
- return ""
|
|
|
+ return ""!
|
|
|
else:
|
|
|
- return reverseKeyLookup(model["metamodel"]["model"], dict_read_edge(model["metamodel"]["model"][mm_elem], name))
|
|
|
+ return reverseKeyLookup(model["metamodel"]["model"], dict_read_edge(model["metamodel"]["model"][mm_elem], name))!
|
|
|
|
|
|
Element function get_superclasses(model : Element, name : String):
|
|
|
Element result
|
|
@@ -147,7 +147,7 @@ Element function get_superclasses(model : Element, name : String):
|
|
|
set_add(nodes, read_edge_dst(edge))
|
|
|
j = j + 1
|
|
|
|
|
|
- return result
|
|
|
+ return result!
|
|
|
|
|
|
String function find_attribute_definer(model : Element, elem_name : String, name : String):
|
|
|
Element superclasses
|
|
@@ -157,8 +157,8 @@ String function find_attribute_definer(model : Element, elem_name : String, name
|
|
|
while (list_len(superclasses) > 0):
|
|
|
current = set_pop(superclasses)
|
|
|
if (dict_in(model["model"][current], name)):
|
|
|
- return current
|
|
|
- return ""
|
|
|
+ return current!
|
|
|
+ return ""!
|
|
|
|
|
|
Void function instantiate_attribute(model : Element, element : String, attribute_name : String, value : Element):
|
|
|
// Instantiate an attribute of something that needs to be instantiated
|
|
@@ -170,13 +170,13 @@ Void function instantiate_attribute(model : Element, element : String, attribute
|
|
|
|
|
|
if (attr_type == ""):
|
|
|
log("Could not find attribute!")
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
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])))
|
|
|
instantiate_link(model, attr_type, "", element, attr_name)
|
|
|
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
String function instantiate_link(model : Element, type : String, name : String, source : String, destination : String):
|
|
|
// Create a typed link between two nodes
|
|
@@ -185,13 +185,13 @@ String function instantiate_link(model : Element, type : String, name : String,
|
|
|
actual_name = model_add_edge(model, name, source, destination)
|
|
|
retype(model, actual_name, type)
|
|
|
|
|
|
- return actual_name
|
|
|
+ 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
|
|
|
+ return!
|
|
|
|
|
|
Void function model_delete_element(model : Element, name : String):
|
|
|
// Remove the link
|
|
@@ -201,7 +201,7 @@ Void function model_delete_element(model : Element, name : String):
|
|
|
// 2) from the model
|
|
|
delete_element(model["model"][name])
|
|
|
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
Element function read_attribute(model : Element, element : String, attribute : String):
|
|
|
Integer i
|
|
@@ -221,10 +221,10 @@ Element function read_attribute(model : Element, element : String, attribute : S
|
|
|
if (dict_in_node(typing, edge)):
|
|
|
edge_type = dict_read_node(typing, edge)
|
|
|
if (element_eq(edge_type, dict_read_edge(read_edge_src(edge_type), attribute))):
|
|
|
- return read_edge_dst(edge)
|
|
|
+ return read_edge_dst(edge)!
|
|
|
i = i + 1
|
|
|
|
|
|
- return read_root()
|
|
|
+ return read_root()!
|
|
|
|
|
|
Void function unset_attribute(model : Element, element : String, attribute : String):
|
|
|
// Removes an attribute if it exists
|
|
@@ -241,11 +241,11 @@ Void function unset_attribute(model : Element, element : String, attribute : Str
|
|
|
dict_delete(model["type_mapping"], model["model"][attr_link])
|
|
|
delete_element(read_edge_dst(model["model"][attr_link]))
|
|
|
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
Void function add_AL_links(model : Element, list : Element, element : Element, type: String, linkname : String, expected_type : String):
|
|
|
if (bool_not(dict_in(element, linkname))):
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
Element link
|
|
|
link = dict_read_edge(element, linkname)
|
|
@@ -272,7 +272,7 @@ Void function add_AL_links(model : Element, list : Element, element : Element, t
|
|
|
list_append(node, expected_type)
|
|
|
set_add(list, node)
|
|
|
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
String function add_AL(model : Element, element : Element):
|
|
|
log("Adding constraint: " + cast_e2s(element))
|
|
@@ -353,7 +353,7 @@ String function add_AL(model : Element, element : Element):
|
|
|
else:
|
|
|
log("Already in there")
|
|
|
|
|
|
- return reverseKeyLookup(model["model"], element)
|
|
|
+ return reverseKeyLookup(model["model"], element)!
|
|
|
|
|
|
Void function add_constraint(model : Element, element : String, constraint : Action):
|
|
|
// Add local constraints to an element
|
|
@@ -365,7 +365,7 @@ Void function add_constraint(model : Element, element : String, constraint : Act
|
|
|
attr_type = find_attribute_type(model, element, "constraint")
|
|
|
instantiate_link(model, attr_type, "", element, constraint_name)
|
|
|
|
|
|
- return
|
|
|
+ return!
|
|
|
|
|
|
Void function construct_model():
|
|
|
String command
|
|
@@ -382,7 +382,7 @@ Void function construct_model():
|
|
|
elif (command == "add_edge"):
|
|
|
model_add_edge(global_models[input()], input(), input(), input())
|
|
|
elif (command == "exit"):
|
|
|
- return
|
|
|
+ return!
|
|
|
elif (command == "retype_model"):
|
|
|
retype_model(global_models[input()], global_models[input()])
|
|
|
elif (command == "retype"):
|