123456789101112131415161718192021222324252627282930313233343536373839404142 |
- include "primitives.alh"
- include "utils.alh"
- Element function get_type_mapping_as_dict(model : Element):
- return model["type_mapping"]!
- Element function get_elements_typed_by(model : Element, type : String):
- return reverseKeyLookupMulti(model["type_mapping"], type)!
- String function read_type(model : Element, name : String):
- String result
- Element tm
- if (dict_in(model["model"], name)):
- if (dict_in(model["type_mapping"], name)):
- result = model["type_mapping"][name]
- if (dict_in(model["metamodel"]["model"], result)):
- return result!
- else:
- return ""!
- else:
- return ""!
- else:
- return ""!
- 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(model["type_mapping"], element)):
- dict_delete(model["type_mapping"], element)
- dict_add_fast(model["type_mapping"], element, type)
- return!
- Element function new_type_mapping():
- return dict_create()!
- Void function remove_type(model : Element, name : String):
- dict_delete(model["type_mapping"], name)
- return !
|