compilation_manager.alc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. include "primitives.alh"
  2. include "constructors.alh"
  3. Element function compilation_manager():
  4. String op_com
  5. String name_com
  6. Boolean defines_com
  7. Element elem_com
  8. Element root_com
  9. Element node_com
  10. Element symbols_com
  11. Element keys_com
  12. Integer nr_com
  13. Integer i_com
  14. if (dict_in(dict_read(read_root(), "__hierarchy"), "objects")):
  15. root_com = dict_read(dict_read(read_root(), "__hierarchy"), "objects")
  16. else:
  17. root_com = create_node()
  18. dict_add(dict_read(read_root(), "__hierarchy"), "objects", root_com)
  19. op_com = input()
  20. if (string_eq(op_com, "upload")):
  21. name_com = input()
  22. node_com = create_node()
  23. dict_add(root_com, name_com, node_com)
  24. dict_add(node_com, "hash_md5", input())
  25. if (input()):
  26. dict_add(node_com, "initializers", construct_top())
  27. else:
  28. dict_add(node_com, "initializers", deserialize(input()))
  29. symbols_com = create_node()
  30. dict_add(node_com, "symbols", symbols_com)
  31. while (input()):
  32. dict_add(symbols_com, input(), input())
  33. elif (string_eq(op_com, "read_symbols")):
  34. name_com = input()
  35. node_com = dict_read(dict_read(root_com, name_com), "symbols")
  36. keys_com = dict_keys(node_com)
  37. String rv
  38. rv = ""
  39. while (integer_lt(0, read_nr_out(keys_com))):
  40. elem_com = set_pop(keys_com)
  41. if (dict_read(node_com, elem_com)):
  42. rv = string_join(rv, string_join(elem_com, ":1\n"))
  43. else:
  44. rv = string_join(rv, string_join(elem_com, ":0\n"))
  45. output(rv)
  46. elif (string_eq(op_com, "read_initializers")):
  47. node_com = dict_read(dict_read(root_com, input()), "initializers")
  48. output(node_com)
  49. elif (string_eq(op_com, "remove_obj")):
  50. dict_delete(root_com, input())
  51. elif (string_eq(op_com, "is_defined")):
  52. name_com = input()
  53. if (dict_in(root_com, name_com)):
  54. output(dict_read(dict_read(root_com, name_com), "hash_md5"))
  55. else:
  56. output(create_node())
  57. else:
  58. log("Failed to understand command")
  59. return op_com