|
@@ -139,40 +139,31 @@ def bootstrap():
|
|
|
# Create all children of the root
|
|
|
for node in root:
|
|
|
f.write("Node %s()\n" % node)
|
|
|
- f.write("Edge _%s(root, %s)\n" % (node, node))
|
|
|
- f.write('Node __%s("%s")\n' % (node, node))
|
|
|
- f.write("Edge ___%s(_%s, __%s)\n" % (node, node, node))
|
|
|
+ f.write("Dict (root, \"%s\", %s)\n" % (node, node))
|
|
|
|
|
|
def declare_primitive_class(primitive_class_name, primitive_decls):
|
|
|
f.write("Node %s()\n" % primitive_class_name)
|
|
|
- f.write("Edge _%s(__hierarchy, %s)\n" % (primitive_class_name, primitive_class_name))
|
|
|
- f.write('Node __%s("%s")\n' % (primitive_class_name, primitive_class_name))
|
|
|
- f.write("Edge ___%s(_%s, __%s)\n" % (primitive_class_name, primitive_class_name, primitive_class_name))
|
|
|
+ f.write("Dict (__hierarchy, \"%s\", %s)\n" % (primitive_class_name, primitive_class_name))
|
|
|
|
|
|
# Define all primitive functions
|
|
|
for function, parameters in primitive_decls.iteritems():
|
|
|
f.write("Node _func_signature_%s()\n" % function)
|
|
|
f.write("Node _func_params_%s()\n" % function)
|
|
|
f.write("Node _func_body_%s()\n" % function)
|
|
|
- f.write("Edge _%s_%s(%s, _func_signature_%s)\n" % (primitive_class_name, function, primitive_class_name, function))
|
|
|
- f.write('Node _name_%s("%s")\n' % (function, function))
|
|
|
- f.write("Edge _%s_name_%s(_%s_%s, _name_%s)\n" % (primitive_class_name, function, primitive_class_name, function, function))
|
|
|
|
|
|
- f.write('Node _body_%s("body")\n' % function)
|
|
|
- f.write("Edge _signature_body_%s(_func_signature_%s, _func_body_%s)\n" % (function, function, function))
|
|
|
- f.write("Edge _signature_body_str_%s(_signature_body_%s, _body_%s)\n" % (function, function, function))
|
|
|
-
|
|
|
- f.write('Node _params_%s("params")\n' % function)
|
|
|
- f.write("Edge _signature_params_%s(_func_signature_%s, _func_params_%s)\n" % (function, function, function))
|
|
|
- f.write("Edge _signature_params_str_%s(_signature_params_%s, _params_%s)\n" % (function, function, function))
|
|
|
+ f.write('Dict (%s, "%s", _func_signature_%s)\n' % (primitive_class_name, function, function))
|
|
|
+ f.write('Dict (_func_signature_%s, "body", _func_body_%s)\n' % (function, function))
|
|
|
+ f.write('Dict (_func_signature_%s, "params", _func_params_%s)\n' % (function, function))
|
|
|
|
|
|
parameter_names = "abcdefghijklmnopqrstuvwxyz"
|
|
|
for number, param in enumerate(parameters[1:]):
|
|
|
param_encoding = "%s_%s" % (function, parameter_names[number])
|
|
|
f.write("Node _func_params_%s()\n" % (param_encoding))
|
|
|
+
|
|
|
f.write('Node _name_%s("%s")\n' % (param_encoding, parameter_names[number]))
|
|
|
f.write("Edge _param_link_%s(_func_params_%s, _func_params_%s)\n" % (param_encoding, function, param_encoding))
|
|
|
f.write("Edge _param_link_str_%s(_param_link_%s, _name_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
|
+
|
|
|
f.write('Node _name_str_%s("name")\n' % param_encoding)
|
|
|
f.write("Edge _param_name_%s(_func_params_%s, _name_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
|
f.write("Edge _param_name_str_%s(_param_name_%s, _name_str_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
@@ -185,26 +176,18 @@ def bootstrap():
|
|
|
|
|
|
for data in task_data:
|
|
|
f.write("Node task_%s()\n" % data)
|
|
|
- f.write('Node ___task_%s("%s")\n' % (data, data))
|
|
|
- f.write("Edge _task_%s(task_root, task_%s)\n" % (data, data))
|
|
|
- f.write("Edge __task_%s(_task_%s, ___task_%s)\n" % (data, data, data))
|
|
|
+ f.write('Dict (task_root, "%s", task_%s)\n' % (data, data))
|
|
|
|
|
|
for data in task_frame:
|
|
|
f.write("Node task_%s()\n" % data)
|
|
|
- f.write('Node ___task_%s("%s")\n' % (data, data))
|
|
|
- f.write("Edge _task_%s(task_frame, task_%s)\n" % (data, data))
|
|
|
- f.write("Edge __task_%s(_task_%s, ___task_%s)\n" % (data, data, data))
|
|
|
+ f.write('Dict (task_frame, "%s", task_%s)\n' % (data, data))
|
|
|
|
|
|
# Add last_input and last_output links
|
|
|
for data in ["input", "output"]:
|
|
|
- f.write('Node ___task_last_%s("last_%s")\n' % (data, data))
|
|
|
- f.write("Edge _task_last_%s(task_root, task_%s)\n" % (data, data))
|
|
|
- f.write("Edge __task_last_%s(_task_last_%s, ___task_last_%s)\n" % (data, data, data))
|
|
|
+ f.write('Dict (task_root, "last_%s", task_%s)\n' % (data, data))
|
|
|
|
|
|
# Bind task to the root
|
|
|
- f.write('Node ___new_task("%s")\n' % task_manager)
|
|
|
- f.write("Edge _new_task(root, task_root)\n")
|
|
|
- f.write("Edge __new_task(_new_task, ___new_task)\n")
|
|
|
+ f.write('Dict (root, "%s", task_root)\n' % (task_manager))
|
|
|
|
|
|
def compile_code_AL(filename, target, prepend="", main=False, symbols=None):
|
|
|
import sys
|
|
@@ -216,9 +199,7 @@ def bootstrap():
|
|
|
# Create all library code
|
|
|
# But first create the structure to hold compiled data
|
|
|
f.write("Node __objects()\n", both=False)
|
|
|
- f.write('Node __objects_name("objects")\n', both=False)
|
|
|
- f.write("Edge __obj_link(__hierarchy, __objects)\n", both=False)
|
|
|
- f.write("Edge _name_obj_link(__obj_link, __objects_name)\n", both=False)
|
|
|
+ f.write('Dict (__hierarchy, "objects", __objects)\n', both=False)
|
|
|
|
|
|
# Compile all files and add to structure manually
|
|
|
for bootstrap_file in bootstrap_files:
|
|
@@ -230,46 +211,33 @@ def bootstrap():
|
|
|
|
|
|
# Now link the code with the compilation manager structure
|
|
|
f.write("Node elem()\n", both=False)
|
|
|
- f.write('Node initializers("initializers")\n', both=False)
|
|
|
- f.write('Node hash("hash_md5")\n', both=False)
|
|
|
- f.write("Edge _(__objects, elem)\n", both=False)
|
|
|
- f.write('Node filename("%s")\n' % bootstrap_file, both=False)
|
|
|
- f.write("Edge _(_, filename)\n", both=False)
|
|
|
- f.write("Edge _(elem, %s_initial_IP)\n" % bootstrap_file, both=False)
|
|
|
- f.write("Edge _(_, initializers)\n", both=False)
|
|
|
+
|
|
|
+ f.write('Dict (__objects, "%s", elem)\n' % bootstrap_file, both=False)
|
|
|
+ f.write('Dict (elem, "initializers", %s_initial_IP)\n' % bootstrap_file, both=False)
|
|
|
+
|
|
|
md5 = hashlib.md5()
|
|
|
md5.update(open(bootstrap_file, 'r').read())
|
|
|
+
|
|
|
f.write('Node hash_value("%s")\n' % md5.hexdigest(), both=False)
|
|
|
- f.write("Edge _(elem, hash_value)\n", both=False)
|
|
|
- f.write("Edge _(_, hash)\n", both=False)
|
|
|
+ f.write('Dict (elem, "hash_md5", hash_value)\n', both=False)
|
|
|
|
|
|
- f.write('Node symbols("symbols")\n', both=False)
|
|
|
f.write('Node __symbols()\n', both=False)
|
|
|
- f.write('Edge _(elem, __symbols)\n', both=False)
|
|
|
- f.write('Edge _(_, symbols)\n', both=False)
|
|
|
+ f.write('Dict (elem, "symbols", __symbols)\n', both=False)
|
|
|
|
|
|
for k, v in symbols.items():
|
|
|
f.write('Node v(%s)\n' % v, both=False)
|
|
|
- f.write('Node k("%s")\n' % k, both=False)
|
|
|
- f.write('Edge _(__symbols, v)\n', both=False)
|
|
|
- f.write('Edge _(_, k)\n', both=False)
|
|
|
+ f.write('Dict (__symbols, "%s", v)\n' % (k), both=False)
|
|
|
|
|
|
# Create code for initial task
|
|
|
print("[BOOT] task_manager")
|
|
|
- f.write('Node _IP_str("IP")\n', both=False)
|
|
|
- f.write("Edge _task_frame(task_frame, %s_initial_IP)\n" % initial_code_manager, both=False)
|
|
|
- f.write("Edge __task_frame(_task_frame, _IP_str)\n", both=False)
|
|
|
+ f.write('Dict (task_frame, "IP", %s_initial_IP)\n' % (initial_code_manager), both=False)
|
|
|
|
|
|
f.write('Node __phase("init")\n', both=False)
|
|
|
- f.write('Node __phase_str("phase")\n', both=False)
|
|
|
- f.write("Edge _task_phase(task_frame, __phase)\n", both=False)
|
|
|
- f.write("Edge __task_phase(_task_phase, __phase_str)\n", both=False)
|
|
|
+ f.write('Dict (task_frame, "phase", __phase)\n', both=False)
|
|
|
|
|
|
# Create code for new tasks to start at
|
|
|
print("[BOOT] new_task")
|
|
|
- f.write('Node __IP_str("__IP")\n', both=False)
|
|
|
- f.write("Edge _task_IP(__hierarchy, %s_initial_IP)\n" % initial_code_task, both=False)
|
|
|
- f.write("Edge __task_IP(_task_IP, __IP_str)\n", both=False)
|
|
|
+ f.write('Dict (__hierarchy, "__IP", %s_initial_IP)\n' % initial_code_task, both=False)
|
|
|
except:
|
|
|
os.remove("bootstrap/bootstrap.m.gz")
|
|
|
os.remove("bootstrap/minimal.m.gz")
|