conformance_finding.alc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. include "primitives.alh"
  2. include "object_operations.alh"
  3. include "typing.alh"
  4. Element function find_type_mapping(model : Element, metamodel : Element):
  5. // Takes as input a model dictionary and fully specified metamodel
  6. // No other entries are required, and the type mapping is returned
  7. // TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
  8. // and it makes the assumption that SCD is the M3 level...
  9. // First find the name of the edge and node elements
  10. Element result
  11. Element elems
  12. String elem
  13. String node_element
  14. String edge_element
  15. elems = dict_keys(metamodel["model"])
  16. while (set_len(elems) > 0):
  17. elem = set_pop(elems)
  18. if (bool_not(is_edge(elem))):
  19. node_element = elem
  20. else:
  21. // Is an edge, but might be the inheritance link...
  22. if (read_type(metamodel, elem) != "Inheritance"):
  23. // Is not the inheritance link
  24. edge_element = elem
  25. // Now we have bot an edge_element and node_element of the metamodel
  26. // Now just trivially bind all elements!
  27. result = create_node()
  28. elems = dict_keys(model)
  29. while (set_len(elems) > 0):
  30. elem = set_pop(elems)
  31. if (is_edge(elem)):
  32. dict_add(result, elem, edge_element)
  33. else:
  34. dict_add(result, elem, node_element)
  35. return result!