bootstrap loads engine

This commit is contained in:
2026-02-10 12:13:18 -06:00
parent 3d71f4a363
commit 0d8b5cfb04
5 changed files with 25 additions and 30 deletions

View File

@@ -181,7 +181,7 @@ var script = null
var ast = null
if (args != null) {
// CLI mode — run script directly
// CLI mode — parse args
program = args[0]
_j = 1
while (_j < length(args)) {
@@ -189,11 +189,11 @@ if (args != null) {
_j = _j + 1
}
// Resolve script file: try .cm then .ce in CWD then core_path
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))
@@ -201,9 +201,20 @@ if (args != null) {
if (!fd.is_file(script_file))
script_file = core_path + '/' + program + '.ce'
script = text(fd.slurp(script_file))
ast = analyze(script, script_file)
run_ast(program, ast, {use: use_fn, args: user_args, json: json})
if (ends_with(script_file, '.ce')) {
// Actor script — delegate to engine
load_engine({
os: os, actorsym: actorsym,
init: {program: program, arg: user_args},
core_path: core_path, shop_path: shop_path, json: json,
analyze: analyze, run_ast_fn: run_ast
})
} else {
// Module script — run directly
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
load_engine({

Binary file not shown.

View File

@@ -109,23 +109,7 @@ var REPLYTIMEOUT = 60 // seconds before replies are ignored
function caller_data(depth)
{
var _depth = depth == null ? 0 : depth
var file = "nofile"
var line = 0
var md = null
var m = null
var caller = array(Error().stack, "\n")[1+_depth]
if (caller) {
md = extract(caller, /\((.*)\:/)
m = md ? md[1] : "SCRIPT"
if (m) file = m
md = extract(caller, /\:(\d*)\)/)
m = md ? md[1] : 0
if (m) line = m
}
return {file,line}
return {file: "nofile", line: 0}
}
function console_rec(line, file, msg) {
@@ -140,9 +124,7 @@ function log(name, args) {
if (name == 'console') {
os.print(console_rec(caller.line, caller.file, msg))
} else if (name == 'error') {
if (msg == null) msg = Error()
if (is_proto(msg, Error))
msg = msg.name + ": " + msg.message + "\n" + msg.stack
if (msg == null) msg = "error"
os.print(console_rec(caller.line, caller.file, msg))
} else if (name == 'system') {
msg = "[SYSTEM] " + msg
@@ -166,7 +148,7 @@ function actor_die(err)
if (overling) {
if (err) {
// with an err, this is a forceful disrupt
reason = (is_proto(err, Error)) ? err.stack : err
reason = err
report_to_overling({type:'disrupt', reason})
} else
report_to_overling({type:'stop'})
@@ -300,8 +282,8 @@ $_.time_limit = function(requestor, seconds)
callback(val, reason)
}, value)
} disruption {
cancel(Error('requestor failed'))
callback(null, Error('requestor failed'))
cancel('requestor failed')
callback(null, 'requestor failed')
}
do_request()

Binary file not shown.

View File

@@ -44,9 +44,10 @@ function fallback(requestor_array) {
var cancelled = false
function cancel(reason) {
var _c = null
cancelled = true
if (current_cancel) {
var _c = function() { current_cancel(reason) } disruption {}
_c = function() { current_cancel(reason) } disruption {}
_c()
current_cancel = null
}
@@ -293,9 +294,10 @@ function sequence(requestor_array) {
var cancelled = false
function cancel(reason) {
var _c = null
cancelled = true
if (current_cancel) {
var _c = function() { current_cancel(reason) } disruption {}
_c = function() { current_cancel(reason) } disruption {}
_c()
current_cancel = null
}