12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- include "primitives.alh"
- include "object_operations.alh"
- include "typing.alh"
- Element function find_type_mapping(model : Element, metamodel : Element):
- // Takes as input a model dictionary and fully specified metamodel
- // No other entries are required, and the type mapping is returned
- // TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
- // and it makes the assumption that SCD is the M3 level...
- // First find the name of the edge and node elements
- Element result
- Element elems
- String elem
- String node_element
- String edge_element
- elems = dict_keys(metamodel["model"])
- while (set_len(elems) > 0):
- elem = set_pop(elems)
- if (bool_not(is_edge(elem))):
- node_element = elem
- else:
- // Is an edge, but might be the inheritance link...
- if (read_type(metamodel, elem) != "Inheritance"):
- // Is not the inheritance link
- edge_element = elem
- // Now we have bot an edge_element and node_element of the metamodel
- // Now just trivially bind all elements!
- result = create_node()
- elems = dict_keys(model)
- while (set_len(elems) > 0):
- elem = set_pop(elems)
- if (is_edge(elem)):
- dict_add(result, elem, edge_element)
- else:
- dict_add(result, elem, node_element)
-
- return result!
|