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: // log("Could not find " + result) return ""! else: // log("Untyped " + name) return ""! else: // log("Couldn't find type of " + name) 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()!