Bootstrap CEK as default evaluator on both JS and Python sides
SPEC_MODULES + SPEC_MODULE_ORDER for frames/cek in platform_js.py, PLATFORM_CEK_JS + CEK_FIXUPS_JS constants, auto-inclusion in run_js_sx.py, 70+ RENAMES in js.sx. Python: CEK always-include in bootstrap_py.py, eval_expr/trampoline overridden to cek_run in platform_py.py with _tree_walk_* preserved for test runners. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,8 +46,14 @@ SPEC_MODULES = {
|
||||
"router": ("router.sx", "router (client-side route matching)"),
|
||||
"signals": ("signals.sx", "signals (reactive signal runtime)"),
|
||||
"page-helpers": ("page-helpers.sx", "page-helpers (pure data transformation helpers)"),
|
||||
"frames": ("frames.sx", "frames (CEK continuation frames)"),
|
||||
"cek": ("cek.sx", "cek (explicit CEK machine evaluator)"),
|
||||
}
|
||||
|
||||
# Explicit ordering for spec modules with dependencies.
|
||||
# Modules listed here are emitted in this order; any not listed use alphabetical.
|
||||
SPEC_MODULE_ORDER = ["deps", "frames", "page-helpers", "router", "signals", "cek"]
|
||||
|
||||
|
||||
EXTENSION_NAMES = {"continuations"}
|
||||
CONTINUATIONS_JS = '''
|
||||
@@ -1476,6 +1482,38 @@ PLATFORM_JS_POST = '''
|
||||
};'''
|
||||
|
||||
|
||||
PLATFORM_CEK_JS = '''
|
||||
// =========================================================================
|
||||
// Platform: CEK module — explicit CEK machine
|
||||
// =========================================================================
|
||||
|
||||
// Standalone aliases for primitives used by cek.sx / frames.sx
|
||||
var inc = PRIMITIVES["inc"];
|
||||
var dec = PRIMITIVES["dec"];
|
||||
var zip_pairs = PRIMITIVES["zip-pairs"];
|
||||
|
||||
var continuation_p = PRIMITIVES["continuation?"];
|
||||
|
||||
function makeCekContinuation(captured, restKont) {
|
||||
var c = new Continuation(function(v) { return v !== undefined ? v : NIL; });
|
||||
c._cek_data = {"captured": captured, "rest-kont": restKont};
|
||||
return c;
|
||||
}
|
||||
function continuationData(c) {
|
||||
return (c && c._cek_data) ? c._cek_data : {};
|
||||
}
|
||||
'''
|
||||
|
||||
# Iterative override for cek_run — replaces transpiled recursive version
|
||||
CEK_FIXUPS_JS = '''
|
||||
// Override recursive cekRun with iterative loop (avoids stack overflow)
|
||||
cekRun = function(state) {
|
||||
while (!cekTerminal_p(state)) { state = cekStep(state); }
|
||||
return cekValue(state);
|
||||
};
|
||||
'''
|
||||
|
||||
|
||||
PLATFORM_DEPS_JS = '''
|
||||
// =========================================================================
|
||||
// Platform: deps module — component dependency analysis
|
||||
|
||||
Reference in New Issue
Block a user