typing.alc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. include "primitives.alh"
  2. include "utils.alh"
  3. Element function get_type_mapping_as_dict(model : Element):
  4. return model["type_mapping"]!
  5. Element function get_elements_typed_by(model : Element, type : String):
  6. return reverseKeyLookupMulti(model["type_mapping"], type)!
  7. String function read_type(model : Element, name : String):
  8. String result
  9. Element tm
  10. if (dict_in(model["model"], name)):
  11. if (dict_in(model["type_mapping"], name)):
  12. result = model["type_mapping"][name]
  13. if (dict_in(model["metamodel"]["model"], result)):
  14. return result!
  15. else:
  16. return ""!
  17. else:
  18. return ""!
  19. else:
  20. return ""!
  21. Void function retype(model : Element, element : String, type : String):
  22. // Retype a model, deleting any previous type the element had
  23. // The type string is evaluated in the metamodel previously specified
  24. if (dict_in(model["type_mapping"], element)):
  25. dict_delete(model["type_mapping"], element)
  26. dict_add_fast(model["type_mapping"], element, type)
  27. return!
  28. Element function new_type_mapping():
  29. return dict_create()!
  30. Void function remove_type(model : Element, name : String):
  31. dict_delete(model["type_mapping"], name)
  32. return !