|
@@ -13,15 +13,15 @@ Element function set_copy(elem_to_copy : Element):
|
|
// Expand the provided list by including all elements that need to be checked
|
|
// Expand the provided list by including all elements that need to be checked
|
|
counter_copy = 0
|
|
counter_copy = 0
|
|
max = read_nr_out(elem_to_copy)
|
|
max = read_nr_out(elem_to_copy)
|
|
- while (integer_lt(counter_copy, max)):
|
|
|
|
|
|
+ while (counter_copy < max):
|
|
set_add(result, read_edge_dst(read_out(elem_to_copy, counter_copy)))
|
|
set_add(result, read_edge_dst(read_out(elem_to_copy, counter_copy)))
|
|
- counter_copy = integer_addition(counter_copy, 1)
|
|
|
|
|
|
+ counter_copy = counter_copy + 1
|
|
|
|
|
|
return result
|
|
return result
|
|
|
|
|
|
Boolean function is_direct_instance(model_idi : Element, instance_idi : Element, type_idi : Element):
|
|
Boolean function is_direct_instance(model_idi : Element, instance_idi : Element, type_idi : Element):
|
|
// Just check whether or not the type mapping specifies the type as the type of the instance
|
|
// Just check whether or not the type mapping specifies the type as the type of the instance
|
|
- return element_eq(dict_read_node(dict_read(model_idi, "type_mapping"), instance_idi), type_idi)
|
|
|
|
|
|
+ return dict_read_node(dict_read(model_idi, "type_mapping"), instance_idi) == type_idi
|
|
|
|
|
|
Boolean function is_nominal_instance(model_ini : Element, instance_ini : Element, type_ini : Element):
|
|
Boolean function is_nominal_instance(model_ini : Element, instance_ini : Element, type_ini : Element):
|
|
return is_nominal_subtype(type_ini, dict_read_node(dict_read(model_ini, "type_mapping"), instance_ini), dict_read(dict_read(model_ini, "metamodel"), "type_mapping"), dict_read(model_ini, "inheritance"))
|
|
return is_nominal_subtype(type_ini, dict_read_node(dict_read(model_ini, "type_mapping"), instance_ini), dict_read(dict_read(model_ini, "metamodel"), "type_mapping"), dict_read(model_ini, "inheritance"))
|
|
@@ -33,24 +33,24 @@ Boolean function is_nominal_subtype(superclass : Element, subclass : Element, ty
|
|
Element destination_iso
|
|
Element destination_iso
|
|
|
|
|
|
// End of recursion
|
|
// End of recursion
|
|
- if (element_eq(superclass, subclass)):
|
|
|
|
|
|
+ if (superclass == subclass):
|
|
return True
|
|
return True
|
|
|
|
|
|
// Iterate over all superclasses of the found class
|
|
// Iterate over all superclasses of the found class
|
|
counter_iso = read_nr_out(subclass)
|
|
counter_iso = read_nr_out(subclass)
|
|
i_iso = 0
|
|
i_iso = 0
|
|
- while (integer_lt(i_iso, counter_iso)):
|
|
|
|
|
|
+ while (i_iso < counter_iso):
|
|
edge_iso = read_out(subclass, i_iso)
|
|
edge_iso = read_out(subclass, i_iso)
|
|
// Check if it even has a type (to prevent errors)
|
|
// Check if it even has a type (to prevent errors)
|
|
if (dict_in_node(types, edge_iso)):
|
|
if (dict_in_node(types, edge_iso)):
|
|
// Check whether it is an inheritance edge, as there is no other distinction between them
|
|
// Check whether it is an inheritance edge, as there is no other distinction between them
|
|
- if (element_eq(dict_read_node(types, edge_iso), inheritance_link)):
|
|
|
|
|
|
+ if (dict_read_node(types, edge_iso) == inheritance_link):
|
|
// It is an inheritance edge, so follow it to its destination
|
|
// It is an inheritance edge, so follow it to its destination
|
|
destination_iso = read_edge_dst(edge_iso)
|
|
destination_iso = read_edge_dst(edge_iso)
|
|
// Found a new superclass to test
|
|
// Found a new superclass to test
|
|
if (is_nominal_subtype(superclass, destination_iso, types, inheritance_link)):
|
|
if (is_nominal_subtype(superclass, destination_iso, types, inheritance_link)):
|
|
return True
|
|
return True
|
|
- i_iso = integer_addition(i_iso, 1)
|
|
|
|
|
|
+ i_iso = i_iso + 1
|
|
|
|
|
|
// No link seems to have been found, so it is False
|
|
// No link seems to have been found, so it is False
|
|
return False
|
|
return False
|
|
@@ -60,7 +60,7 @@ Boolean function is_structural_instance(model_isi : Element, instance_isi : Elem
|
|
|
|
|
|
Boolean function is_structural_subtype(subtype_isi : Element, supertype_isi : Element):
|
|
Boolean function is_structural_subtype(subtype_isi : Element, supertype_isi : Element):
|
|
// Determine whether it is just the exact type or not
|
|
// Determine whether it is just the exact type or not
|
|
- if (element_eq(subtype_isi, supertype_isi)):
|
|
|
|
|
|
+ if (subtype_isi == supertype_isi):
|
|
return True
|
|
return True
|
|
|
|
|
|
// Find all links that are required (name and type) from the specified type
|
|
// Find all links that are required (name and type) from the specified type
|
|
@@ -75,7 +75,7 @@ Boolean function is_structural_subtype(subtype_isi : Element, supertype_isi : El
|
|
i_isi = 0
|
|
i_isi = 0
|
|
|
|
|
|
// Go over all keys that we require
|
|
// Go over all keys that we require
|
|
- while (integer_lt(i_isi, required_keys_len_isi)):
|
|
|
|
|
|
+ while (i_isi < required_keys_len_isi):
|
|
key_isi = set_pop(required_keys_isi)
|
|
key_isi = set_pop(required_keys_isi)
|
|
// Check whether they exist in the instance
|
|
// Check whether they exist in the instance
|
|
if (dict_in(subtype_isi, key_isi)):
|
|
if (dict_in(subtype_isi, key_isi)):
|
|
@@ -88,7 +88,7 @@ Boolean function is_structural_subtype(subtype_isi : Element, supertype_isi : El
|
|
return False
|
|
return False
|
|
|
|
|
|
// All clear, so pass on to the next attribute
|
|
// All clear, so pass on to the next attribute
|
|
- i_isi = integer_addition(i_isi, 1)
|
|
|
|
|
|
+ i_isi = i_isi + 1
|
|
else:
|
|
else:
|
|
return False
|
|
return False
|
|
|
|
|
|
@@ -115,34 +115,34 @@ String function conformance_scd(model : Element):
|
|
metamodel_typing = dict_read(dict_read(model, "metamodel"), "type_mapping")
|
|
metamodel_typing = dict_read(dict_read(model, "metamodel"), "type_mapping")
|
|
|
|
|
|
// Iterate over all model elements and check if they are typed (in "typing") and their type is in the metamodel
|
|
// Iterate over all model elements and check if they are typed (in "typing") and their type is in the metamodel
|
|
- while (integer_gt(dict_len(models), 0)):
|
|
|
|
|
|
+ while (dict_len(models) > 0):
|
|
work_conf = set_pop(models)
|
|
work_conf = set_pop(models)
|
|
// Basic check: does the element have a type
|
|
// Basic check: does the element have a type
|
|
if (bool_not(dict_in_node(typing, work_conf))):
|
|
if (bool_not(dict_in_node(typing, work_conf))):
|
|
- return string_join("Model has no type specified: ", getName(model, work_conf))
|
|
|
|
|
|
+ return "Model has no type specified: " + getName(model, work_conf)
|
|
|
|
|
|
// Basic check: is the type of the element part of the metamodel
|
|
// Basic check: is the type of the element part of the metamodel
|
|
if (bool_not(set_in_node(metamodels, dict_read_node(typing, work_conf)))):
|
|
if (bool_not(set_in_node(metamodels, dict_read_node(typing, work_conf)))):
|
|
- return string_join("Type of element not in specified metamodel: ", getName(model, work_conf))
|
|
|
|
|
|
+ return "Type of element not in specified metamodel: " + getName(model, work_conf)
|
|
|
|
|
|
// Basic check: type of the value agrees with the actual type
|
|
// Basic check: type of the value agrees with the actual type
|
|
// this is always checked, as it falls back to a sane default for non-values
|
|
// this is always checked, as it falls back to a sane default for non-values
|
|
if (bool_not(type_eq(dict_read_node(typing, work_conf), typeof(work_conf)))):
|
|
if (bool_not(type_eq(dict_read_node(typing, work_conf), typeof(work_conf)))):
|
|
- return string_join("Primitive type does not agree with actual type: ", getName(model, work_conf))
|
|
|
|
|
|
+ return "Primitive type does not agree with actual type: " + getName(model, work_conf)
|
|
|
|
|
|
// For edges only: check whether the source is typed according to the metamodel
|
|
// For edges only: check whether the source is typed according to the metamodel
|
|
if (is_edge(work_conf)):
|
|
if (is_edge(work_conf)):
|
|
model_src = read_edge_src(work_conf)
|
|
model_src = read_edge_src(work_conf)
|
|
metamodel_src = read_edge_src(dict_read_node(typing, work_conf))
|
|
metamodel_src = read_edge_src(dict_read_node(typing, work_conf))
|
|
if (bool_not(is_nominal_instance(model, model_src, metamodel_src))):
|
|
if (bool_not(is_nominal_instance(model, model_src, metamodel_src))):
|
|
- return string_join("Source of model edge not typed by source of type: ", getName(model, work_conf))
|
|
|
|
|
|
+ return "Source of model edge not typed by source of type: " + getName(model, work_conf)
|
|
|
|
|
|
// For edges only: check whether the destination is typed according to the metamodel
|
|
// For edges only: check whether the destination is typed according to the metamodel
|
|
if (is_edge(work_conf)):
|
|
if (is_edge(work_conf)):
|
|
model_dst = read_edge_dst(work_conf)
|
|
model_dst = read_edge_dst(work_conf)
|
|
metamodel_dst = read_edge_dst(dict_read_node(typing, work_conf))
|
|
metamodel_dst = read_edge_dst(dict_read_node(typing, work_conf))
|
|
if (bool_not(is_nominal_instance(model, model_dst, metamodel_dst))):
|
|
if (bool_not(is_nominal_instance(model, model_dst, metamodel_dst))):
|
|
- return string_join("Destination of model edge not typed by destination of type: ", getName(model, work_conf))
|
|
|
|
|
|
+ return "Destination of model edge not typed by destination of type: " + getName(model, work_conf)
|
|
|
|
|
|
// Structure seems fine, now do static semantics
|
|
// Structure seems fine, now do static semantics
|
|
if (dict_in(dict_read(model, "metamodel"), "constraints")):
|
|
if (dict_in(dict_read(model, "metamodel"), "constraints")):
|
|
@@ -171,9 +171,9 @@ Element function retype(model_rt : Element, metamodel_rt : Element, inheritance_
|
|
return model_rt
|
|
return model_rt
|
|
|
|
|
|
Element function add_to_model(model_atm : Element, name_atm : String, element_atm : Element):
|
|
Element function add_to_model(model_atm : Element, name_atm : String, element_atm : Element):
|
|
- if (string_eq(name_atm, "")):
|
|
|
|
|
|
+ if (name_atm == ""):
|
|
// No name desired
|
|
// No name desired
|
|
- dict_add(dict_read(model_atm, "model"), string_join("__", cast_id2s(element_atm)), element_atm)
|
|
|
|
|
|
+ dict_add(dict_read(model_atm, "model"), "__" + cast_id2s(element_atm), element_atm)
|
|
else:
|
|
else:
|
|
dict_add(dict_read(model_atm, "model"), name_atm, element_atm)
|
|
dict_add(dict_read(model_atm, "model"), name_atm, element_atm)
|
|
return element_atm
|
|
return element_atm
|
|
@@ -205,7 +205,7 @@ Element function instantiate_model_lib(model_mo : Element, type_mo : Element, na
|
|
// Create a new edge from "optionals[0]" to "optionals[1]"
|
|
// Create a new edge from "optionals[0]" to "optionals[1]"
|
|
new_element_mo = instantiate_bottom_edge(model_mo, name_mo, list_read(optionals, 0), list_read(optionals, 1))
|
|
new_element_mo = instantiate_bottom_edge(model_mo, name_mo, list_read(optionals, 0), list_read(optionals, 1))
|
|
else:
|
|
else:
|
|
- if (type_eq(typeof(type_mo), Type)):
|
|
|
|
|
|
+ if (typeof(type_mo) == Type):
|
|
new_element_mo = instantiate_bottom_value(model_mo, name_mo, list_read(optionals, 0))
|
|
new_element_mo = instantiate_bottom_value(model_mo, name_mo, list_read(optionals, 0))
|
|
else:
|
|
else:
|
|
new_element_mo = instantiate_bottom_node(model_mo, name_mo)
|
|
new_element_mo = instantiate_bottom_node(model_mo, name_mo)
|
|
@@ -229,7 +229,7 @@ Element function instantiate_model_lib(model_mo : Element, type_mo : Element, na
|
|
metamodel_mo = dict_read(dict_read(model_mo, "metamodel"), "model")
|
|
metamodel_mo = dict_read(dict_read(model_mo, "metamodel"), "model")
|
|
|
|
|
|
// For all new attributes
|
|
// For all new attributes
|
|
- while (integer_lt(counter_mo, max_mo)):
|
|
|
|
|
|
+ while (counter_mo < max_mo):
|
|
attr_name_mo = set_pop(keys_mo)
|
|
attr_name_mo = set_pop(keys_mo)
|
|
attr_type_mo = dict_read(attribute_types, attr_name_mo)
|
|
attr_type_mo = dict_read(attribute_types, attr_name_mo)
|
|
|
|
|
|
@@ -237,10 +237,10 @@ Element function instantiate_model_lib(model_mo : Element, type_mo : Element, na
|
|
created_edge_mo = create_edge(created_attr_mo, attr_name_mo)
|
|
created_edge_mo = create_edge(created_attr_mo, attr_name_mo)
|
|
|
|
|
|
// Add it to the model
|
|
// Add it to the model
|
|
- dict_add(dict_read(model_mo, "model"), string_join("__", cast_id2s(attr_name_mo)), attr_name_mo)
|
|
|
|
- dict_add(dict_read(model_mo, "model"), string_join("__", cast_id2s(attr_type_mo)), attr_type_mo)
|
|
|
|
- dict_add(dict_read(model_mo, "model"), string_join("__", cast_id2s(created_attr_mo)), created_attr_mo)
|
|
|
|
- dict_add(dict_read(model_mo, "model"), string_join("__", cast_id2s(created_edge_mo)), created_edge_mo)
|
|
|
|
|
|
+ dict_add(dict_read(model_mo, "model"), "__" + cast_id2s(attr_name_mo), attr_name_mo)
|
|
|
|
+ dict_add(dict_read(model_mo, "model"), "__" + cast_id2s(attr_type_mo), attr_type_mo)
|
|
|
|
+ dict_add(dict_read(model_mo, "model"), "__" + cast_id2s(created_attr_mo), created_attr_mo)
|
|
|
|
+ dict_add(dict_read(model_mo, "model"), "__" + cast_id2s(created_edge_mo), created_edge_mo)
|
|
|
|
|
|
// And add the typing
|
|
// And add the typing
|
|
dict_add(dict_read(model_mo, "type_mapping"), attr_name_mo, dict_read(metamodel_mo, "__String"))
|
|
dict_add(dict_read(model_mo, "type_mapping"), attr_name_mo, dict_read(metamodel_mo, "__String"))
|
|
@@ -249,7 +249,7 @@ Element function instantiate_model_lib(model_mo : Element, type_mo : Element, na
|
|
dict_add(dict_read(model_mo, "type_mapping"), created_edge_mo, dict_read(metamodel_mo, "__Name"))
|
|
dict_add(dict_read(model_mo, "type_mapping"), created_edge_mo, dict_read(metamodel_mo, "__Name"))
|
|
|
|
|
|
// Increase while loop counter
|
|
// Increase while loop counter
|
|
- counter_mo = integer_addition(counter_mo, 1)
|
|
|
|
|
|
+ counter_mo = counter_mo + 1
|
|
|
|
|
|
// Similarly for instantiated attributes
|
|
// Similarly for instantiated attributes
|
|
counter_mo = 0
|
|
counter_mo = 0
|
|
@@ -260,7 +260,7 @@ Element function instantiate_model_lib(model_mo : Element, type_mo : Element, na
|
|
Element attr_value_mo
|
|
Element attr_value_mo
|
|
Element attr_edge_mo
|
|
Element attr_edge_mo
|
|
|
|
|
|
- while (integer_lt(counter_mo, max_mo)):
|
|
|
|
|
|
+ while (counter_mo < max_mo):
|
|
// Look it up
|
|
// Look it up
|
|
attr_name_mo = set_pop(keys_mo)
|
|
attr_name_mo = set_pop(keys_mo)
|
|
attr_value_mo = dict_read(attribute_instances, attr_name_mo)
|
|
attr_value_mo = dict_read(attribute_instances, attr_name_mo)
|
|
@@ -270,14 +270,14 @@ Element function instantiate_model_lib(model_mo : Element, type_mo : Element, na
|
|
attr_edge_mo = create_edge(new_element_mo, attr_value_mo)
|
|
attr_edge_mo = create_edge(new_element_mo, attr_value_mo)
|
|
|
|
|
|
// Add to model
|
|
// Add to model
|
|
- dict_add(dict_read(model_mo, "model"), string_join("__", cast_id2s(attr_value_mo)), attr_value_mo)
|
|
|
|
- dict_add(dict_read(model_mo, "model"), string_join("__", cast_id2s(attr_edge_mo)), attr_edge_mo)
|
|
|
|
|
|
+ dict_add(dict_read(model_mo, "model"), "__" + cast_id2s(attr_value_mo), attr_value_mo)
|
|
|
|
+ dict_add(dict_read(model_mo, "model"), "__" + cast_id2s(attr_edge_mo), attr_edge_mo)
|
|
|
|
|
|
// Type the new elements
|
|
// Type the new elements
|
|
dict_add(dict_read(model_mo, "type_mapping"), attr_value_mo, attr_type_mo)
|
|
dict_add(dict_read(model_mo, "type_mapping"), attr_value_mo, attr_type_mo)
|
|
dict_add(dict_read(model_mo, "type_mapping"), attr_edge_mo, attr_type_edge_mo)
|
|
dict_add(dict_read(model_mo, "type_mapping"), attr_edge_mo, attr_type_edge_mo)
|
|
|
|
|
|
- counter_mo = integer_addition(counter_mo, 1)
|
|
|
|
|
|
+ counter_mo = counter_mo + 1
|
|
|
|
|
|
return new_element_mo
|
|
return new_element_mo
|
|
|
|
|
|
@@ -302,12 +302,12 @@ Element function generate_bottom_type_mapping(model_tm : Element):
|
|
Element elem_keys_tm
|
|
Element elem_keys_tm
|
|
Element elem_tm
|
|
Element elem_tm
|
|
elem_keys_tm = dict_keys(dict_read(model_tm, "model"))
|
|
elem_keys_tm = dict_keys(dict_read(model_tm, "model"))
|
|
- while (integer_lt(0, read_nr_out(elem_keys_tm))):
|
|
|
|
|
|
+ while (0 < read_nr_out(elem_keys_tm)):
|
|
elem_tm = dict_read(dict_read(model_tm, "model"), set_pop(elem_keys_tm))
|
|
elem_tm = dict_read(dict_read(model_tm, "model"), set_pop(elem_keys_tm))
|
|
if (is_edge(elem_tm)):
|
|
if (is_edge(elem_tm)):
|
|
dict_add(tm_tm, elem_tm, dict_read(mm_tm, "Edge"))
|
|
dict_add(tm_tm, elem_tm, dict_read(mm_tm, "Edge"))
|
|
else:
|
|
else:
|
|
- if (string_neq(cast_v2s(elem_tm), "None")):
|
|
|
|
|
|
+ if (cast_v2s(elem_tm) != "None"):
|
|
dict_add(tm_tm, elem_tm, dict_read(mm_tm, cast_v2s(typeof(elem_tm))))
|
|
dict_add(tm_tm, elem_tm, dict_read(mm_tm, cast_v2s(typeof(elem_tm))))
|
|
else:
|
|
else:
|
|
dict_add(tm_tm, elem_tm, dict_read(mm_tm, "Node"))
|
|
dict_add(tm_tm, elem_tm, dict_read(mm_tm, "Node"))
|