compilation_manager.alc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. include "primitives.alh"
  2. include "constructors.alh"
  3. Element function read_symbols(root : Element, object_name : String):
  4. Element keys
  5. Element node
  6. String rv
  7. String key
  8. node = root[object_name]["symbols"]
  9. keys = dict_keys(node)
  10. rv = ""
  11. while (0 < read_nr_out(keys)):
  12. key = set_pop(keys)
  13. if (node[key]):
  14. rv = (rv + key) + ":1\n"
  15. else:
  16. rv = (rv + key) + ":0\n"
  17. return rv
  18. Element function compilation_manager():
  19. String operation
  20. String object_name
  21. Element root
  22. Element mv_root
  23. Element node
  24. mv_root = read_root()
  25. if (dict_in(mv_root["__hierarchy"], "objects")):
  26. root = mv_root["__hierarchy"]["objects"]
  27. else:
  28. root = create_node()
  29. dict_add(mv_root["__hierarchy"], "objects", root)
  30. operation = input()
  31. if (operation == "upload"):
  32. object_name = input()
  33. node = create_node()
  34. dict_add(root, object_name, node)
  35. dict_add(node, "hash_md5", input())
  36. if (input()):
  37. dict_add(node, "initializers", construct_top())
  38. else:
  39. dict_add(node, "initializers", deserialize(input()))
  40. Element symbols
  41. symbols = create_node()
  42. dict_add(node, "symbols", symbols)
  43. while (input()):
  44. dict_add(symbols, input(), input())
  45. elif (operation == "remove_obj"):
  46. dict_delete(root, input())
  47. elif (operation == "read_symbols"):
  48. output(read_symbols(root, input()))
  49. elif (operation == "read_initializers"):
  50. node = root[input()]["initializers"]
  51. output(node)
  52. elif (operation == "is_defined"):
  53. object_name = input()
  54. if (dict_in(root, object_name)):
  55. output(root[object_name]["hash_md5"])
  56. else:
  57. output(create_node())
  58. else:
  59. log("Failed to understand command")
  60. return operation