DEVS_merge.alc 817 B

1234567891011121314151617181920212223242526272829
  1. include "primitives.alh"
  2. include "object_operations.alh"
  3. include "modelling.alh"
  4. Boolean function main(model : Element):
  5. // Find all source elements and add them to the target element
  6. // We actually only have to change the type of each element and rename a bit!
  7. // Model merge operations in the Modelverse take care of the rest automatically
  8. Element all_elements
  9. Element split
  10. String key
  11. String new_key
  12. String type
  13. all_elements = dict_keys(model["model"])
  14. while (set_len(all_elements) > 0):
  15. key = set_pop(all_elements)
  16. type = read_type(model, key)
  17. split = string_split(type, "/")
  18. // Got the type, which might contain a /
  19. if (list_len(split) > 1):
  20. type = list_read(split, 1)
  21. // Strip of the part before the / and make it into "DEVS"
  22. retype(model, key, "result/" + type)
  23. return True!