compilation_manager.alc 1.5 KB

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