bootstrap
This commit is contained in:
@@ -123,37 +123,51 @@ function use_fn(path) {
|
||||
// Helper to load engine.cm and run it with given env
|
||||
function load_engine(env) {
|
||||
var engine_path = core_path + '/internal/engine.mach'
|
||||
var data = null
|
||||
var engine_src = null
|
||||
var engine_ast = null
|
||||
if (fd.is_file(engine_path)) {
|
||||
var data = fd.slurp(engine_path)
|
||||
data = fd.slurp(engine_path)
|
||||
return mach_load(data, env)
|
||||
}
|
||||
engine_path = core_path + '/internal/engine.cm'
|
||||
var engine_src = text(fd.slurp(engine_path))
|
||||
var engine_ast = analyze(engine_src, engine_path)
|
||||
engine_src = text(fd.slurp(engine_path))
|
||||
engine_ast = analyze(engine_src, engine_path)
|
||||
return run_ast('engine', engine_ast, env)
|
||||
}
|
||||
|
||||
// Detect mode and route
|
||||
// CLI mode has 'args'; actor spawn mode has 'init'
|
||||
var program = null
|
||||
var user_args = []
|
||||
var _j = 0
|
||||
var script_file = null
|
||||
var script = null
|
||||
var ast = null
|
||||
|
||||
if (args != null) {
|
||||
// CLI mode — run script directly
|
||||
var program = args[0]
|
||||
var user_args = []
|
||||
var _j = 1
|
||||
program = args[0]
|
||||
_j = 1
|
||||
while (_j < length(args)) {
|
||||
push(user_args, args[_j])
|
||||
_j = _j + 1
|
||||
}
|
||||
|
||||
var script_file = program
|
||||
script_file = program
|
||||
if (!ends_with(script_file, '.ce') && !ends_with(script_file, '.cm'))
|
||||
script_file = program + '.cm'
|
||||
|
||||
// Search CWD then core_path, trying .cm then .ce
|
||||
if (!fd.is_file(script_file))
|
||||
script_file = core_path + '/' + program + '.cm'
|
||||
if (!fd.is_file(script_file))
|
||||
script_file = program + '.ce'
|
||||
if (!fd.is_file(script_file))
|
||||
script_file = core_path + '/' + program + '.ce'
|
||||
|
||||
var script = text(fd.slurp(script_file))
|
||||
var ast = analyze(script, script_file)
|
||||
script = text(fd.slurp(script_file))
|
||||
ast = analyze(script, script_file)
|
||||
run_ast(program, ast, {use: use_fn, args: user_args, json: json})
|
||||
} else {
|
||||
// Actor spawn mode — load engine.cm with full actor env
|
||||
|
||||
Reference in New Issue
Block a user