|
@@ -50,7 +50,7 @@ Element function compilation_manager():
|
|
|
log("ERROR: couldn't find obj " + obj)
|
|
|
obj = input()
|
|
|
|
|
|
- link_and_load(root, objs)
|
|
|
+ link_and_load(root, input(), objs)
|
|
|
elif (operation == "is_defined"):
|
|
|
object_name = input()
|
|
|
if (dict_in(root, object_name)):
|
|
@@ -61,7 +61,7 @@ Element function compilation_manager():
|
|
|
log("Failed to understand command")
|
|
|
return operation
|
|
|
|
|
|
-Boolean function check_symbols(root : Element, objs : Element):
|
|
|
+Boolean function check_symbols(root : Element, main_function : String, objs : Element):
|
|
|
Element symbols
|
|
|
String obj
|
|
|
Element keys
|
|
@@ -70,7 +70,7 @@ Boolean function check_symbols(root : Element, objs : Element):
|
|
|
|
|
|
// We always need a main variable
|
|
|
symbols = create_node()
|
|
|
- dict_add(symbols, "main", False)
|
|
|
+ dict_add(symbols, main_function, False)
|
|
|
|
|
|
// Resolve all symbols
|
|
|
copy_objs = set_copy(objs)
|
|
@@ -109,17 +109,25 @@ Boolean function check_symbols(root : Element, objs : Element):
|
|
|
|
|
|
return True
|
|
|
|
|
|
-Void function link_and_load(root : Element, objs : Element):
|
|
|
+Void function link_and_load(root : Element, main_function : String, objs : Element):
|
|
|
String obj
|
|
|
Element func
|
|
|
+ Element main_f
|
|
|
|
|
|
- if (check_symbols(root, objs)):
|
|
|
+ if (check_symbols(root, main_function, objs)):
|
|
|
+ // Symbols verified OK, start execution
|
|
|
output(True)
|
|
|
+
|
|
|
+ // Call all initializers in turn
|
|
|
while (0 < list_len(objs)):
|
|
|
obj = set_pop(objs)
|
|
|
func = root[obj]["initializers"]
|
|
|
exec(func)
|
|
|
- main()
|
|
|
+
|
|
|
+ // Resolve the main function, which should now be in (global) scope, and execute it
|
|
|
+ main_f = resolve(main_function)
|
|
|
+ main_f()
|
|
|
else:
|
|
|
+ // Symbol verification failed, so don't execute
|
|
|
output(False)
|
|
|
return
|