12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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!
- Void function new_type_mapping(model : Element):
- if (dict_in(model, "type_mapping")):
- dict_delete(model, "type_mapping")
- dict_add_fast(model, "type_mapping", dict_create())
- return !
- Void function remove_type(model : Element, name : String):
- dict_delete(model["type_mapping"], name)
- return !
- Void function set_type_mapping(model : Element, type_mapping : Element):
- dict_overwrite(model, "type_mapping", type_mapping)
- return!
- Element function get_type_mapping(model : Element):
- return model["type_mapping"]!
|