12345678910111213141516171819202122232425262728293031323334353637 |
- include "primitives.alh"
- include "object_operations.alh"
- include "modelling.alh"
- Boolean function main(model : Element):
- // Find all source elements and add them to the target element
- // We actually only have to change the type of each element and rename a bit!
- // Model merge operations in the Modelverse take care of the rest automatically
- Element all_elements
- Element split
- String key
- String new_key
- String type
- all_elements = dict_keys(model["model"])
- while (set_len(all_elements) > 0):
- key = set_pop(all_elements)
- // key now contains an element, which we must retype
- split = string_split(key, "/")
- if (list_len(split) > 1):
- new_key = list_read(split, 1)
- dict_add(model["model"], new_key, model["model"][key])
- dict_delete(model["model"], key)
- key = new_key
- type = read_type(model, key)
- split = string_split(type, "/")
- // Got the type, which might contain a /
- if (list_len(split) > 1):
- type = list_read(split, 1)
- // Strip of the part before the / and make it into "DEVS"
- retype(model, key, "result/" + type)
- return True!
|