|
@@ -7,7 +7,10 @@ import gzip
|
|
|
def bootstrap():
|
|
|
root = ["__hierarchy"]
|
|
|
|
|
|
+ user_manager = "user_manager"
|
|
|
bootstrap_files = glob.glob("bootstrap/*.alc")
|
|
|
+ initial_code_manager = "bootstrap/initial_code_manager.alc"
|
|
|
+ initial_code_user = "bootstrap/initial_code_user.alc"
|
|
|
|
|
|
user_data = [ "input",
|
|
|
"output",
|
|
@@ -105,40 +108,6 @@ def bootstrap():
|
|
|
"time": ["Float"],
|
|
|
}
|
|
|
|
|
|
- initial_user = "user_manager"
|
|
|
- initial_user_code = \
|
|
|
- '''
|
|
|
- include "bootstrap/primitives.alc"
|
|
|
- include "user_manager.alh"
|
|
|
-
|
|
|
- Void function __main():
|
|
|
- \tElement root
|
|
|
- \troot = read_root()
|
|
|
- \troot = root["__hierarchy"]["objects"]
|
|
|
- \texec(root["bootstrap/user_manager.alc"]["initializers"])
|
|
|
- \tuser_management()
|
|
|
- '''
|
|
|
-
|
|
|
- code_new_users = \
|
|
|
- '''
|
|
|
- include "bootstrap/primitives.alc"
|
|
|
- include "user_interface.alh"
|
|
|
-
|
|
|
- Void function __main():
|
|
|
- \tElement root
|
|
|
- \troot = read_root()
|
|
|
- \troot = root["__hierarchy"]["objects"]
|
|
|
- \texec(root["bootstrap/compilation_manager.alc"]["initializers"])
|
|
|
- \texec(root["bootstrap/constructors.alc"]["initializers"])
|
|
|
- \texec(root["bootstrap/library.alc"]["initializers"])
|
|
|
- \texec(root["bootstrap/object_operations.alc"]["initializers"])
|
|
|
- \texec(root["bootstrap/conformance_scd.alc"]["initializers"])
|
|
|
- \texec(root["bootstrap/metamodels.alc"]["initializers"])
|
|
|
- \texec(root["bootstrap/modelling.alc"]["initializers"])
|
|
|
- \texec(root["bootstrap/user_interface.alc"]["initializers"])
|
|
|
- \tnew_user()
|
|
|
- '''
|
|
|
-
|
|
|
### Actual script to generate the file
|
|
|
import os
|
|
|
import sys
|
|
@@ -222,24 +191,15 @@ def bootstrap():
|
|
|
f.write("Edge __user_last_%s(_user_last_%s, ___user_last_%s)\n" % (data, data, data))
|
|
|
|
|
|
# Bind user to the root
|
|
|
- f.write('Node ___new_user("%s")\n' % initial_user)
|
|
|
+ f.write('Node ___new_user("%s")\n' % user_manager)
|
|
|
f.write("Edge _new_user(root, user_root)\n")
|
|
|
f.write("Edge __new_user(_new_user, ___new_user)\n")
|
|
|
|
|
|
- def compile_code_AL(code, target, prepend="", is_file=False, main=False, symbols=None):
|
|
|
+ def compile_code_AL(filename, target, prepend="", main=False, symbols=None):
|
|
|
import sys
|
|
|
sys.path.append("interface/HUTN/")
|
|
|
from hutn_compiler.compiler import main as compile_code
|
|
|
-
|
|
|
- if not is_file:
|
|
|
- f = tempfile.NamedTemporaryFile(delete=False)
|
|
|
- f.write(code)
|
|
|
- f.flush()
|
|
|
- filename = f.name
|
|
|
- f.close()
|
|
|
- else:
|
|
|
- filename = code
|
|
|
- code = compile_code(filename, "interface/HUTN/grammars/actionlanguage.g", "BS", ["--prepend:%s" % prepend, "--main" if main else "--not-main"], symbols=symbols)
|
|
|
+ code = compile_code(filename, "interface/HUTN/grammars/actionlanguage.g", "BS", ["--debug", "--prepend:%s" % prepend, "--main" if main else "--not-main"], symbols=symbols)
|
|
|
return code.replace("auto_initial_IP", target)
|
|
|
|
|
|
# Create all library code
|
|
@@ -255,8 +215,7 @@ def bootstrap():
|
|
|
bootstrap_file = bootstrap_file.replace("\\", "/")
|
|
|
print("[COMP] %s" % bootstrap_file)
|
|
|
symbols = {}
|
|
|
- result = compile_code_AL(bootstrap_file, "initial_IP", prepend=bootstrap_file, is_file=True, symbols=symbols)
|
|
|
- f.write(result, both=False)
|
|
|
+ f.write(compile_code_AL(bootstrap_file, "initial_IP", prepend=bootstrap_file, symbols=symbols, main = bootstrap_file in [initial_code_manager, initial_code_user]), both=False)
|
|
|
|
|
|
# Now link the code with the compilation manager structure
|
|
|
f.write("Node elem()\n", both=False)
|
|
@@ -285,10 +244,9 @@ def bootstrap():
|
|
|
f.write('Edge _(_, k)\n', both=False)
|
|
|
|
|
|
# Create code for initial user
|
|
|
- print("[BOOT] initial_user")
|
|
|
- f.write(compile_code_AL(initial_user_code, "initial_IP", prepend="user_manager", main=True), both=False)
|
|
|
+ print("[BOOT] user_manager")
|
|
|
f.write('Node _IP_str("IP")\n', both=False)
|
|
|
- f.write("Edge _user_frame(user_frame, user_manager_initial_IP)\n", both=False)
|
|
|
+ f.write("Edge _user_frame(user_frame, %s_initial_IP)\n" % initial_code_manager, both=False)
|
|
|
f.write("Edge __user_frame(_user_frame, _IP_str)\n", both=False)
|
|
|
|
|
|
f.write('Node __phase("init")\n', both=False)
|
|
@@ -298,9 +256,8 @@ def bootstrap():
|
|
|
|
|
|
# Create code for new users to start at
|
|
|
print("[BOOT] new_user")
|
|
|
- f.write(compile_code_AL(code_new_users, "initial_IP", prepend="new_user", main=True), both=False)
|
|
|
f.write('Node __IP_str("__IP")\n', both=False)
|
|
|
- f.write("Edge _user_IP(__hierarchy, new_user_initial_IP)\n", both=False)
|
|
|
+ f.write("Edge _user_IP(__hierarchy, %s_initial_IP)\n" % initial_code_user, both=False)
|
|
|
f.write("Edge __user_IP(_user_IP, __IP_str)\n", both=False)
|
|
|
except:
|
|
|
os.remove("bootstrap/bootstrap.m.gz")
|