|
@@ -21,10 +21,10 @@ Element function set_copy(elem_to_copy : Element):
|
|
|
|
|
|
Boolean function is_direct_instance(model : Element, instance : Element, type : Element):
|
|
|
// Just check whether or not the type mapping specifies the type as the type of the instance
|
|
|
- return dict_read_node(dict_read(model, "type_mapping"), instance) == type
|
|
|
+ return dict_read_node(model["type_mapping"], instance) == type
|
|
|
|
|
|
Boolean function is_nominal_instance(model : Element, instance : Element, type : Element):
|
|
|
- return is_nominal_subtype(type, dict_read_node(dict_read(model, "type_mapping"), instance), dict_read(dict_read(model, "metamodel"), "type_mapping"), dict_read(model, "inheritance"))
|
|
|
+ return is_nominal_subtype(type, dict_read_node(model["type_mapping"], instance), model["metamodel"]["type_mapping"], model["inheritance"])
|
|
|
|
|
|
Boolean function is_nominal_subtype(superclass : Element, subclass : Element, types : Element, inheritance_link : Element):
|
|
|
Integer counter
|
|
@@ -56,7 +56,7 @@ Boolean function is_nominal_subtype(superclass : Element, subclass : Element, ty
|
|
|
return False
|
|
|
|
|
|
Boolean function is_structural_instance(model : Element, instance : Element, type : Element):
|
|
|
- return is_structural_subtype(dict_read_node(dict_read(model, "type_mapping"), instance), type)
|
|
|
+ return is_structural_subtype(dict_read_node(model["type_mapping"], instance), type)
|
|
|
|
|
|
Boolean function is_structural_subtype(subtype : Element, supertype : Element):
|
|
|
// Determine whether it is just the exact type or not
|
|
@@ -84,7 +84,7 @@ Boolean function is_structural_subtype(subtype : Element, supertype : Element):
|
|
|
// TODO
|
|
|
|
|
|
// Still check whether the types match
|
|
|
- if (bool_not(is_structural_subtype(dict_read(subtype, key), dict_read(supertype, key)))):
|
|
|
+ if (bool_not(is_structural_subtype(subtype[key], supertype[key]))):
|
|
|
return False
|
|
|
|
|
|
// All clear, so pass on to the next attribute
|
|
@@ -104,15 +104,15 @@ String function conformance_scd(model : Element):
|
|
|
Element metamodel_dst
|
|
|
Element models
|
|
|
Element metamodels
|
|
|
- models = set_copy(dict_read(model, "model"))
|
|
|
+ models = set_copy(model["model"])
|
|
|
|
|
|
Element typing
|
|
|
- typing = dict_read(model, "type_mapping")
|
|
|
- metamodels = set_copy(dict_read(dict_read(model, "metamodel"), "model"))
|
|
|
+ typing = model["type_mapping"]
|
|
|
+ metamodels = set_copy(model["metamodel"]["model"])
|
|
|
Element inheritance
|
|
|
- inheritance = dict_read(dict_read(model, "metamodel"), "inheritance")
|
|
|
+ inheritance = model["metamodel"]["inheritance"]
|
|
|
Element metamodel_typing
|
|
|
- metamodel_typing = dict_read(dict_read(model, "metamodel"), "type_mapping")
|
|
|
+ metamodel_typing = model["metamodel"]["type_mapping"]
|
|
|
|
|
|
// Iterate over all model elements and check if they are typed (in "typing") and their type is in the metamodel
|
|
|
while (dict_len(models) > 0):
|
|
@@ -145,9 +145,9 @@ String function conformance_scd(model : Element):
|
|
|
return "Destination of model edge not typed by destination of type: " + getName(model, work_node)
|
|
|
|
|
|
// Structure seems fine, now do static semantics
|
|
|
- if (dict_in(dict_read(model, "metamodel"), "constraints")):
|
|
|
+ if (dict_in(model["metamodel"], "constraints")):
|
|
|
Element constraint_function
|
|
|
- constraint_function = dict_read(dict_read(model, "metamodel"), "constraints")
|
|
|
+ constraint_function = model["metamodel"]["constraints"]
|
|
|
return constraint_function(model)
|
|
|
else:
|
|
|
return "OK"
|
|
@@ -173,9 +173,9 @@ Element function retype(model : Element, metamodel : Element, inheritance : Elem
|
|
|
Element function add_to_model(model : Element, name : String, element : Element):
|
|
|
if (name == ""):
|
|
|
// No name desired
|
|
|
- dict_add(dict_read(model, "model"), "__" + cast_id2s(element), element)
|
|
|
+ dict_add(model["model"], "__" + cast_id2s(element), element)
|
|
|
else:
|
|
|
- dict_add(dict_read(model, "model"), name, element)
|
|
|
+ dict_add(model["model"], name, element)
|
|
|
return element
|
|
|
|
|
|
Element function instantiate_bottom_node(model : Element, name : String):
|
|
@@ -211,7 +211,7 @@ Element function instantiate_model_lib(model : Element, type : Element, name : S
|
|
|
new_element = instantiate_bottom_node(model, name)
|
|
|
|
|
|
// Add it to the type mapping
|
|
|
- dict_add(dict_read(model, "type_mapping"), new_element, type)
|
|
|
+ dict_add(model["type_mapping"], new_element, type)
|
|
|
|
|
|
// Add all attribute types at this level
|
|
|
Integer counter
|
|
@@ -226,27 +226,32 @@ Element function instantiate_model_lib(model : Element, type : Element, name : S
|
|
|
Element created_attr
|
|
|
Element created_edge
|
|
|
Element metamodel
|
|
|
- metamodel = dict_read(dict_read(model, "metamodel"), "model")
|
|
|
+ metamodel = model["metamodel"]["model"]
|
|
|
|
|
|
// For all new attributes
|
|
|
while (counter < max):
|
|
|
attr_name = set_pop(keys)
|
|
|
- attr_type = dict_read(attribute_types, attr_name)
|
|
|
+ attr_type = attribute_types[attr_name]
|
|
|
|
|
|
created_attr = create_edge(new_element, attr_type)
|
|
|
created_edge = create_edge(created_attr, attr_name)
|
|
|
|
|
|
+ Element m
|
|
|
+ Element tm
|
|
|
+ m = model["model"]
|
|
|
+ tm = model["type_mapping"]
|
|
|
+
|
|
|
// Add it to the model
|
|
|
- dict_add(dict_read(model, "model"), "__" + cast_id2s(attr_name), attr_name)
|
|
|
- dict_add(dict_read(model, "model"), "__" + cast_id2s(attr_type), attr_type)
|
|
|
- dict_add(dict_read(model, "model"), "__" + cast_id2s(created_attr), created_attr)
|
|
|
- dict_add(dict_read(model, "model"), "__" + cast_id2s(created_edge), created_edge)
|
|
|
+ dict_add(m, "__" + cast_id2s(attr_name), attr_name)
|
|
|
+ dict_add(m, "__" + cast_id2s(attr_type), attr_type)
|
|
|
+ dict_add(m, "__" + cast_id2s(created_attr), created_attr)
|
|
|
+ dict_add(m, "__" + cast_id2s(created_edge), created_edge)
|
|
|
|
|
|
// And add the typing
|
|
|
- dict_add(dict_read(model, "type_mapping"), attr_name, dict_read(metamodel, "__String"))
|
|
|
- dict_add(dict_read(model, "type_mapping"), attr_type, dict_read(metamodel, "Type"))
|
|
|
- dict_add(dict_read(model, "type_mapping"), created_attr, dict_read(metamodel, "Attribute"))
|
|
|
- dict_add(dict_read(model, "type_mapping"), created_edge, dict_read(metamodel, "__Name"))
|
|
|
+ dict_add(tm, attr_name, metamodel["__String"])
|
|
|
+ dict_add(tm, attr_type, metamodel["Type"])
|
|
|
+ dict_add(tm, created_attr, metamodel["Attribute"])
|
|
|
+ dict_add(tm, created_edge, metamodel["__Name"])
|
|
|
|
|
|
// Increase while loop counter
|
|
|
counter = counter + 1
|
|
@@ -263,19 +268,19 @@ Element function instantiate_model_lib(model : Element, type : Element, name : S
|
|
|
while (counter < max):
|
|
|
// Look it up
|
|
|
attr_name = set_pop(keys)
|
|
|
- attr_value = dict_read(attribute_instances, attr_name)
|
|
|
- attr_definer_class = find_attribute(type, attr_name, dict_read(dict_read(model, "metamodel"), "type_mapping"), dict_read(model, "inheritance"))
|
|
|
- attr_type = dict_read(attr_definer_class, attr_name)
|
|
|
+ attr_value = attribute_instances[attr_name]
|
|
|
+ attr_definer_class = find_attribute(type, attr_name, model["metamodel"]["type_mapping"], model["inheritance"])
|
|
|
+ attr_type = attr_definer_class[attr_name]
|
|
|
attr_type_edge = dict_read_edge(attr_definer_class, attr_name)
|
|
|
attr_edge = create_edge(new_element, attr_value)
|
|
|
|
|
|
// Add to model
|
|
|
- dict_add(dict_read(model, "model"), "__" + cast_id2s(attr_value), attr_value)
|
|
|
- dict_add(dict_read(model, "model"), "__" + cast_id2s(attr_edge), attr_edge)
|
|
|
+ dict_add(model["model"], "__" + cast_id2s(attr_value), attr_value)
|
|
|
+ dict_add(model["model"], "__" + cast_id2s(attr_edge), attr_edge)
|
|
|
|
|
|
// Type the new elements
|
|
|
- dict_add(dict_read(model, "type_mapping"), attr_value, attr_type)
|
|
|
- dict_add(dict_read(model, "type_mapping"), attr_edge, attr_type_edge)
|
|
|
+ dict_add(model["type_mapping"], attr_value, attr_type)
|
|
|
+ dict_add(model["type_mapping"], attr_edge, attr_type_edge)
|
|
|
|
|
|
counter = counter + 1
|
|
|
|
|
@@ -292,7 +297,7 @@ Element function instantiate_new_model(metamodel : Element, inheritance : Elemen
|
|
|
|
|
|
Element function generate_bottom_type_mapping(model : Element):
|
|
|
Element mm
|
|
|
- mm = dict_read(dict_read(model, "metamodel"), "model")
|
|
|
+ mm = model["metamodel"]["model"]
|
|
|
dict_delete(model, "type_mapping")
|
|
|
Element tm
|
|
|
tm = create_node()
|
|
@@ -301,15 +306,15 @@ Element function generate_bottom_type_mapping(model : Element):
|
|
|
// Iterate over every element
|
|
|
Element elem_keys
|
|
|
Element elem
|
|
|
- elem_keys = dict_keys(dict_read(model, "model"))
|
|
|
+ elem_keys = dict_keys(model["model"])
|
|
|
while (0 < read_nr_out(elem_keys)):
|
|
|
- elem = dict_read(dict_read(model, "model"), set_pop(elem_keys))
|
|
|
+ elem = model["model"][set_pop(elem_keys)]
|
|
|
if (is_edge(elem)):
|
|
|
- dict_add(tm, elem, dict_read(mm, "Edge"))
|
|
|
+ dict_add(tm, elem, mm["Edge"])
|
|
|
else:
|
|
|
if (cast_v2s(elem) != "None"):
|
|
|
- dict_add(tm, elem, dict_read(mm, cast_v2s(typeof(elem))))
|
|
|
+ dict_add(tm, elem, mm[cast_v2s(typeof(elem))])
|
|
|
else:
|
|
|
- dict_add(tm, elem, dict_read(mm, "Node"))
|
|
|
+ dict_add(tm, elem, mm["Node"])
|
|
|
|
|
|
return model
|