compilation_manager.alc 1.6 KB

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