|
@@ -2,62 +2,59 @@ include "primitives.alh"
|
|
|
include "constructors.alh"
|
|
|
|
|
|
Element function compilation_manager():
|
|
|
- String op_com
|
|
|
- String name_com
|
|
|
- Boolean defines_com
|
|
|
- Element elem_com
|
|
|
- Element root_com
|
|
|
- Element node_com
|
|
|
- Element symbols_com
|
|
|
- Element keys_com
|
|
|
- Integer nr_com
|
|
|
- Integer i_com
|
|
|
+ String operation
|
|
|
+ String object_name
|
|
|
+ Element root
|
|
|
+ Element node
|
|
|
|
|
|
if (dict_in(dict_read(read_root(), "__hierarchy"), "objects")):
|
|
|
- root_com = dict_read(dict_read(read_root(), "__hierarchy"), "objects")
|
|
|
+ root = dict_read(dict_read(read_root(), "__hierarchy"), "objects")
|
|
|
else:
|
|
|
- root_com = create_node()
|
|
|
- dict_add(dict_read(read_root(), "__hierarchy"), "objects", root_com)
|
|
|
+ root = create_node()
|
|
|
+ dict_add(dict_read(read_root(), "__hierarchy"), "objects", root)
|
|
|
|
|
|
- op_com = input()
|
|
|
- if (string_eq(op_com, "upload")):
|
|
|
- name_com = input()
|
|
|
- node_com = create_node()
|
|
|
- dict_add(root_com, name_com, node_com)
|
|
|
- dict_add(node_com, "hash_md5", input())
|
|
|
+ operation = input()
|
|
|
+ if (operation == "upload"):
|
|
|
+ object_name = input()
|
|
|
+ node = create_node()
|
|
|
+ dict_add(root, object_name, node)
|
|
|
+ dict_add(node, "hash_md5", input())
|
|
|
if (input()):
|
|
|
- dict_add(node_com, "initializers", construct_top())
|
|
|
+ dict_add(node, "initializers", construct_top())
|
|
|
else:
|
|
|
- dict_add(node_com, "initializers", deserialize(input()))
|
|
|
+ dict_add(node, "initializers", deserialize(input()))
|
|
|
|
|
|
- symbols_com = create_node()
|
|
|
- dict_add(node_com, "symbols", symbols_com)
|
|
|
+ Element symbols
|
|
|
+ symbols = create_node()
|
|
|
+ dict_add(node, "symbols", symbols)
|
|
|
while (input()):
|
|
|
- dict_add(symbols_com, input(), input())
|
|
|
- elif (string_eq(op_com, "read_symbols")):
|
|
|
- name_com = input()
|
|
|
- node_com = dict_read(dict_read(root_com, name_com), "symbols")
|
|
|
- keys_com = dict_keys(node_com)
|
|
|
+ dict_add(symbols, input(), input())
|
|
|
+ elif (operation == "read_symbols"):
|
|
|
+ Element keys
|
|
|
+ object_name = input()
|
|
|
+ node = dict_read(dict_read(root, object_name), "symbols")
|
|
|
+ keys = dict_keys(node)
|
|
|
String rv
|
|
|
rv = ""
|
|
|
- while (integer_lt(0, read_nr_out(keys_com))):
|
|
|
- elem_com = set_pop(keys_com)
|
|
|
- if (dict_read(node_com, elem_com)):
|
|
|
- rv = string_join(rv, string_join(elem_com, ":1\n"))
|
|
|
+ String key
|
|
|
+ while (0 < read_nr_out(keys)):
|
|
|
+ key = set_pop(keys)
|
|
|
+ if (dict_read(node, key)):
|
|
|
+ rv = (rv + key) + ":1\n"
|
|
|
else:
|
|
|
- rv = string_join(rv, string_join(elem_com, ":0\n"))
|
|
|
+ rv = (rv + key) + ":0\n"
|
|
|
output(rv)
|
|
|
- elif (string_eq(op_com, "read_initializers")):
|
|
|
- node_com = dict_read(dict_read(root_com, input()), "initializers")
|
|
|
- output(node_com)
|
|
|
- elif (string_eq(op_com, "remove_obj")):
|
|
|
- dict_delete(root_com, input())
|
|
|
- elif (string_eq(op_com, "is_defined")):
|
|
|
- name_com = input()
|
|
|
- if (dict_in(root_com, name_com)):
|
|
|
- output(dict_read(dict_read(root_com, name_com), "hash_md5"))
|
|
|
+ elif (operation == "read_initializers"):
|
|
|
+ node = dict_read(dict_read(root, input()), "initializers")
|
|
|
+ output(node)
|
|
|
+ elif (operation == "remove_obj"):
|
|
|
+ dict_delete(root, input())
|
|
|
+ elif (operation == "is_defined"):
|
|
|
+ object_name = input()
|
|
|
+ if (dict_in(root, object_name)):
|
|
|
+ output(dict_read(dict_read(root, object_name), "hash_md5"))
|
|
|
else:
|
|
|
output(create_node())
|
|
|
else:
|
|
|
log("Failed to understand command")
|
|
|
- return op_com
|
|
|
+ return operation
|