Merge branch 'fix_core_scripts' into quicken_mcode
This commit is contained in:
22
Makefile
22
Makefile
@@ -5,16 +5,10 @@
|
||||
# or manually build with meson once.
|
||||
#
|
||||
# The cell shop is at ~/.cell and core scripts are installed to ~/.cell/core
|
||||
#
|
||||
# See BUILDING.md for details on the bootstrap process and .mach files.
|
||||
|
||||
CELL_SHOP = $(HOME)/.cell
|
||||
CELL_CORE_PACKAGE = $(CELL_SHOP)/packages/core
|
||||
|
||||
# .cm sources that compile to .mcode bytecode
|
||||
MACH_SOURCES = tokenize.cm parse.cm fold.cm mcode.cm \
|
||||
internal/bootstrap.cm internal/engine.cm
|
||||
|
||||
maker: install
|
||||
|
||||
makecell:
|
||||
@@ -22,7 +16,7 @@ makecell:
|
||||
cp cell /opt/homebrew/bin/
|
||||
|
||||
# Install core: symlink this directory to ~/.cell/core
|
||||
install: bootstrap .mach.stamp $(CELL_SHOP)
|
||||
install: cell $(CELL_SHOP)
|
||||
@echo "Linking cell core to $(CELL_CORE_PACKAGE)"
|
||||
rm -rf $(CELL_CORE_PACKAGE)
|
||||
ln -s $(PWD) $(CELL_CORE_PACKAGE)
|
||||
@@ -46,16 +40,6 @@ libcell_runtime.dylib: $(CELL_SHOP)/build/dynamic
|
||||
cell_main: source/main.c libcell_runtime.dylib
|
||||
cc -o cell_main source/main.c -L. -lcell_runtime -Wl,-rpath,@loader_path -Wl,-rpath,/opt/homebrew/lib
|
||||
|
||||
# Regenerate .mach bytecode when any .cm source changes
|
||||
.mach.stamp: $(MACH_SOURCES)
|
||||
./cell --dev regen
|
||||
@touch $@
|
||||
|
||||
# Force-regenerate all .mach bytecode files
|
||||
regen:
|
||||
./cell --core . regen
|
||||
@touch .mach.stamp
|
||||
|
||||
# Create the cell shop directories
|
||||
$(CELL_SHOP):
|
||||
mkdir -p $(CELL_SHOP)
|
||||
@@ -84,7 +68,7 @@ bootstrap:
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
rm -rf $(CELL_SHOP)/build build_bootstrap
|
||||
rm -f cell cell_main libcell_runtime.dylib .mach.stamp
|
||||
rm -f cell cell_main libcell_runtime.dylib
|
||||
|
||||
# Ensure dynamic build directory exists
|
||||
$(CELL_SHOP)/build/dynamic: $(CELL_SHOP)
|
||||
@@ -95,4 +79,4 @@ meson:
|
||||
meson setup build_dbg -Dbuildtype=debugoptimized
|
||||
meson install -C build_dbg
|
||||
|
||||
.PHONY: cell static bootstrap clean meson install regen
|
||||
.PHONY: cell static bootstrap clean meson install
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
7469
boot/engine.cm.mcode
7469
boot/engine.cm.mcode
File diff suppressed because it is too large
Load Diff
903
boot/fd.cm.mcode
903
boot/fd.cm.mcode
@@ -1,903 +0,0 @@
|
||||
{
|
||||
"name": "fd.cm",
|
||||
"functions": [
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 4,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["put", 2, 3, 1, 7, 12],
|
||||
["return", 1, 8, 12],
|
||||
"_nop_ur_1",
|
||||
"_nop_ur_2"
|
||||
],
|
||||
"name": "<anonymous>",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 2
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 10,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["null", 3, 5, 14],
|
||||
["function", 4, 0, 6, 21],
|
||||
["access", 6, {"name":"replace","kind":"name","make":"intrinsic"}, 6, 3],
|
||||
["frame", 7, 6, 3, 6, 3],
|
||||
["null", 8, 6, 3],
|
||||
["setarg", 7, 0, 8, 6, 3],
|
||||
["setarg", 7, 1, 1, 6, 3],
|
||||
["setarg", 7, 2, 2, 6, 3],
|
||||
["setarg", 7, 3, 4, 6, 3],
|
||||
["invoke", 7, 5, 6, 3],
|
||||
["return", 3, 10, 10],
|
||||
"_nop_ur_1",
|
||||
"_nop_ur_2"
|
||||
],
|
||||
"name": "last_pos",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 2
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 27,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["regexp", 5, "\\/+$", "", 15, 25],
|
||||
["access", 6, "", 15, 33],
|
||||
["access", 8, {"name":"replace","kind":"name","make":"intrinsic"}, 15, 11],
|
||||
["frame", 9, 8, 3, 15, 11],
|
||||
["null", 10, 15, 11],
|
||||
["setarg", 9, 0, 10, 15, 11],
|
||||
["setarg", 9, 1, 1, 15, 11],
|
||||
["setarg", 9, 2, 5, 15, 11],
|
||||
["setarg", 9, 3, 6, 15, 11],
|
||||
["invoke", 9, 7, 15, 11],
|
||||
["move", 3, 7, 15, 11],
|
||||
["regexp", 11, "^\\/+", "", 16, 24],
|
||||
["access", 12, "", 16, 32],
|
||||
["access", 14, {"name":"replace","kind":"name","make":"intrinsic"}, 16, 11],
|
||||
["frame", 15, 14, 3, 16, 11],
|
||||
["null", 16, 16, 11],
|
||||
["setarg", 15, 0, 16, 16, 11],
|
||||
["setarg", 15, 1, 2, 16, 11],
|
||||
["setarg", 15, 2, 11, 16, 11],
|
||||
["setarg", 15, 3, 12, 16, 11],
|
||||
["invoke", 15, 13, 16, 11],
|
||||
["move", 4, 13, 16, 11],
|
||||
"_nop_bl_1",
|
||||
["jump_true", 3, "if_else_0", 17, 8],
|
||||
["return", 4, 17, 18],
|
||||
"_nop_ur_1",
|
||||
"if_else_0",
|
||||
"if_end_1",
|
||||
"_nop_bl_2",
|
||||
["jump_true", 4, "if_else_2", 18, 8],
|
||||
["return", 3, 18, 18],
|
||||
"_nop_ur_2",
|
||||
"if_else_2",
|
||||
"if_end_3",
|
||||
["access", 19, "/", 19, 14],
|
||||
["is_text", 21, 3, 19, 14],
|
||||
["jump_false", 21, "add_cn_5", 19, 14],
|
||||
"_nop_tc_1",
|
||||
"_nop_tc_2",
|
||||
["concat", 20, 3, 19, 19, 14],
|
||||
["jump", "add_done_4", 19, 14],
|
||||
"add_cn_5",
|
||||
["is_num", 21, 3, 19, 14],
|
||||
["jump_false", 21, "add_err_6", 19, 14],
|
||||
"_nop_tc_3",
|
||||
["jump", "add_err_6", 19, 14],
|
||||
["add", 20, 3, 19, 19, 14],
|
||||
["jump", "add_done_4", 19, 14],
|
||||
"add_err_6",
|
||||
["disrupt", 19, 14],
|
||||
"add_done_4",
|
||||
["is_text", 24, 20, 19, 20],
|
||||
["jump_false", 24, "add_cn_8", 19, 20],
|
||||
["is_text", 25, 4, 19, 20],
|
||||
["jump_false", 25, "add_cn_8", 19, 20],
|
||||
["concat", 23, 20, 4, 19, 20],
|
||||
["jump", "add_done_7", 19, 20],
|
||||
"add_cn_8",
|
||||
["is_num", 24, 20, 19, 20],
|
||||
["jump_false", 24, "add_err_9", 19, 20],
|
||||
["is_num", 25, 4, 19, 20],
|
||||
["jump_false", 25, "add_err_9", 19, 20],
|
||||
["add", 23, 20, 4, 19, 20],
|
||||
["jump", "add_done_7", 19, 20],
|
||||
"add_err_9",
|
||||
["disrupt", 19, 20],
|
||||
"add_done_7",
|
||||
["return", 23, 19, 20],
|
||||
"_nop_ur_3",
|
||||
"_nop_ur_4"
|
||||
],
|
||||
"name": "join_paths",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 2
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 21,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["access", 3, "/", 24, 29],
|
||||
["get", 5, 3, 1, 24, 14],
|
||||
["frame", 6, 5, 2, 24, 14],
|
||||
["null", 7, 24, 14],
|
||||
["setarg", 6, 0, 7, 24, 14],
|
||||
["setarg", 6, 1, 1, 24, 14],
|
||||
["setarg", 6, 2, 3, 24, 14],
|
||||
["invoke", 6, 4, 24, 14],
|
||||
["move", 2, 4, 24, 14],
|
||||
["null", 8, 25, 15],
|
||||
["is_identical", 9, 2, 8, 25, 15],
|
||||
["jump_true", 9, "eq_done_12", 25, 15],
|
||||
["is_int", 10, 2, 25, 15],
|
||||
["jump_false", 10, "eq_ni_13", 25, 15],
|
||||
"_nop_tc_1",
|
||||
["jump", "eq_ni_13", 25, 15],
|
||||
["eq_int", 9, 2, 8, 25, 15],
|
||||
["jump", "eq_done_12", 25, 15],
|
||||
"eq_ni_13",
|
||||
["is_num", 10, 2, 25, 15],
|
||||
["jump_false", 10, "eq_nn_14", 25, 15],
|
||||
"_nop_tc_2",
|
||||
["jump", "eq_nn_14", 25, 15],
|
||||
["eq_float", 9, 2, 8, 25, 15],
|
||||
["jump", "eq_done_12", 25, 15],
|
||||
"eq_nn_14",
|
||||
["is_text", 10, 2, 25, 15],
|
||||
["jump_false", 10, "eq_nt_15", 25, 15],
|
||||
"_nop_tc_3",
|
||||
["jump", "eq_nt_15", 25, 15],
|
||||
["eq_text", 9, 2, 8, 25, 15],
|
||||
["jump", "eq_done_12", 25, 15],
|
||||
"eq_nt_15",
|
||||
["is_null", 10, 2, 25, 15],
|
||||
["jump_false", 10, "eq_nnl_16", 25, 15],
|
||||
"_nop_tc_4",
|
||||
"_nop_tc_5",
|
||||
["true", 9, 25, 15],
|
||||
["jump", "eq_done_12", 25, 15],
|
||||
"eq_nnl_16",
|
||||
["is_bool", 10, 2, 25, 15],
|
||||
["jump_false", 10, "eq_nb_17", 25, 15],
|
||||
"_nop_tc_6",
|
||||
["jump", "eq_nb_17", 25, 15],
|
||||
["eq_bool", 9, 2, 8, 25, 15],
|
||||
["jump", "eq_done_12", 25, 15],
|
||||
"eq_nb_17",
|
||||
["false", 9, 25, 15],
|
||||
"eq_done_12",
|
||||
["jump_false", 9, "if_else_10", 25, 15],
|
||||
["return", 1, 25, 28],
|
||||
"_nop_ur_1",
|
||||
"if_else_10",
|
||||
"if_end_11",
|
||||
["access", 12, 1, 26, 26],
|
||||
["is_text", 14, 2, 26, 26],
|
||||
["jump_false", 14, "add_cn_19", 26, 26],
|
||||
"_nop_tc_7",
|
||||
["jump", "add_cn_19", 26, 26],
|
||||
["concat", 13, 2, 12, 26, 26],
|
||||
["jump", "add_done_18", 26, 26],
|
||||
"add_cn_19",
|
||||
["is_num", 14, 2, 26, 26],
|
||||
["jump_false", 14, "add_err_20", 26, 26],
|
||||
"_nop_tc_8",
|
||||
"_nop_tc_9",
|
||||
["add", 13, 2, 12, 26, 26],
|
||||
["jump", "add_done_18", 26, 26],
|
||||
"add_err_20",
|
||||
["disrupt", 26, 26],
|
||||
"add_done_18",
|
||||
["access", 17, {"name":"text","kind":"name","make":"intrinsic"}, 26, 10],
|
||||
["frame", 18, 17, 2, 26, 10],
|
||||
["null", 19, 26, 10],
|
||||
["setarg", 18, 0, 19, 26, 10],
|
||||
["setarg", 18, 1, 1, 26, 10],
|
||||
["setarg", 18, 2, 13, 26, 10],
|
||||
["tail_invoke", 18, 16, 26, 10],
|
||||
["return", 16, 26, 10],
|
||||
"_nop_ur_2",
|
||||
"_nop_ur_3"
|
||||
],
|
||||
"name": "basename",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 19,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["access", 3, "/", 30, 29],
|
||||
["get", 5, 3, 1, 30, 14],
|
||||
["frame", 6, 5, 2, 30, 14],
|
||||
["null", 7, 30, 14],
|
||||
["setarg", 6, 0, 7, 30, 14],
|
||||
["setarg", 6, 1, 1, 30, 14],
|
||||
["setarg", 6, 2, 3, 30, 14],
|
||||
["invoke", 6, 4, 30, 14],
|
||||
["move", 2, 4, 30, 14],
|
||||
["null", 8, 31, 15],
|
||||
["is_identical", 9, 2, 8, 31, 15],
|
||||
["jump_true", 9, "eq_done_23", 31, 15],
|
||||
["is_int", 10, 2, 31, 15],
|
||||
["jump_false", 10, "eq_ni_24", 31, 15],
|
||||
"_nop_tc_1",
|
||||
["jump", "eq_ni_24", 31, 15],
|
||||
["eq_int", 9, 2, 8, 31, 15],
|
||||
["jump", "eq_done_23", 31, 15],
|
||||
"eq_ni_24",
|
||||
["is_num", 10, 2, 31, 15],
|
||||
["jump_false", 10, "eq_nn_25", 31, 15],
|
||||
"_nop_tc_2",
|
||||
["jump", "eq_nn_25", 31, 15],
|
||||
["eq_float", 9, 2, 8, 31, 15],
|
||||
["jump", "eq_done_23", 31, 15],
|
||||
"eq_nn_25",
|
||||
["is_text", 10, 2, 31, 15],
|
||||
["jump_false", 10, "eq_nt_26", 31, 15],
|
||||
"_nop_tc_3",
|
||||
["jump", "eq_nt_26", 31, 15],
|
||||
["eq_text", 9, 2, 8, 31, 15],
|
||||
["jump", "eq_done_23", 31, 15],
|
||||
"eq_nt_26",
|
||||
["is_null", 10, 2, 31, 15],
|
||||
["jump_false", 10, "eq_nnl_27", 31, 15],
|
||||
"_nop_tc_4",
|
||||
"_nop_tc_5",
|
||||
["true", 9, 31, 15],
|
||||
["jump", "eq_done_23", 31, 15],
|
||||
"eq_nnl_27",
|
||||
["is_bool", 10, 2, 31, 15],
|
||||
["jump_false", 10, "eq_nb_28", 31, 15],
|
||||
"_nop_tc_6",
|
||||
["jump", "eq_nb_28", 31, 15],
|
||||
["eq_bool", 9, 2, 8, 31, 15],
|
||||
["jump", "eq_done_23", 31, 15],
|
||||
"eq_nb_28",
|
||||
["false", 9, 31, 15],
|
||||
"eq_done_23",
|
||||
["jump_false", 9, "if_else_21", 31, 15],
|
||||
["access", 12, "", 31, 28],
|
||||
["return", 12, 31, 28],
|
||||
"_nop_ur_1",
|
||||
"if_else_21",
|
||||
"if_end_22",
|
||||
["access", 13, 0, 32, 20],
|
||||
["access", 15, {"name":"text","kind":"name","make":"intrinsic"}, 32, 10],
|
||||
["frame", 16, 15, 3, 32, 10],
|
||||
["null", 17, 32, 10],
|
||||
["setarg", 16, 0, 17, 32, 10],
|
||||
["setarg", 16, 1, 1, 32, 10],
|
||||
["setarg", 16, 2, 13, 32, 10],
|
||||
["setarg", 16, 3, 2, 32, 10],
|
||||
["tail_invoke", 16, 14, 32, 10],
|
||||
["return", 14, 32, 10],
|
||||
"_nop_ur_2",
|
||||
"_nop_ur_3"
|
||||
],
|
||||
"name": "dirname",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 18,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["access", 3, ".", 36, 29],
|
||||
["get", 5, 3, 1, 36, 14],
|
||||
["frame", 6, 5, 2, 36, 14],
|
||||
["null", 7, 36, 14],
|
||||
["setarg", 6, 0, 7, 36, 14],
|
||||
["setarg", 6, 1, 1, 36, 14],
|
||||
["setarg", 6, 2, 3, 36, 14],
|
||||
["invoke", 6, 4, 36, 14],
|
||||
["move", 2, 4, 36, 14],
|
||||
["null", 8, 37, 15],
|
||||
["is_identical", 9, 2, 8, 37, 15],
|
||||
["jump_true", 9, "eq_done_31", 37, 15],
|
||||
["is_int", 10, 2, 37, 15],
|
||||
["jump_false", 10, "eq_ni_32", 37, 15],
|
||||
"_nop_tc_1",
|
||||
["jump", "eq_ni_32", 37, 15],
|
||||
["eq_int", 9, 2, 8, 37, 15],
|
||||
["jump", "eq_done_31", 37, 15],
|
||||
"eq_ni_32",
|
||||
["is_num", 10, 2, 37, 15],
|
||||
["jump_false", 10, "eq_nn_33", 37, 15],
|
||||
"_nop_tc_2",
|
||||
["jump", "eq_nn_33", 37, 15],
|
||||
["eq_float", 9, 2, 8, 37, 15],
|
||||
["jump", "eq_done_31", 37, 15],
|
||||
"eq_nn_33",
|
||||
["is_text", 10, 2, 37, 15],
|
||||
["jump_false", 10, "eq_nt_34", 37, 15],
|
||||
"_nop_tc_3",
|
||||
["jump", "eq_nt_34", 37, 15],
|
||||
["eq_text", 9, 2, 8, 37, 15],
|
||||
["jump", "eq_done_31", 37, 15],
|
||||
"eq_nt_34",
|
||||
["is_null", 10, 2, 37, 15],
|
||||
["jump_false", 10, "eq_nnl_35", 37, 15],
|
||||
"_nop_tc_4",
|
||||
"_nop_tc_5",
|
||||
["true", 9, 37, 15],
|
||||
["jump", "eq_done_31", 37, 15],
|
||||
"eq_nnl_35",
|
||||
["is_bool", 10, 2, 37, 15],
|
||||
["jump_false", 10, "eq_nb_36", 37, 15],
|
||||
"_nop_tc_6",
|
||||
["jump", "eq_nb_36", 37, 15],
|
||||
["eq_bool", 9, 2, 8, 37, 15],
|
||||
["jump", "eq_done_31", 37, 15],
|
||||
"eq_nb_36",
|
||||
["false", 9, 37, 15],
|
||||
"eq_done_31",
|
||||
["jump_false", 9, "if_else_29", 37, 15],
|
||||
["return", 1, 37, 28],
|
||||
"_nop_ur_1",
|
||||
"if_else_29",
|
||||
"if_end_30",
|
||||
["access", 12, 0, 38, 20],
|
||||
["access", 14, {"name":"text","kind":"name","make":"intrinsic"}, 38, 10],
|
||||
["frame", 15, 14, 3, 38, 10],
|
||||
["null", 16, 38, 10],
|
||||
["setarg", 15, 0, 16, 38, 10],
|
||||
["setarg", 15, 1, 1, 38, 10],
|
||||
["setarg", 15, 2, 12, 38, 10],
|
||||
["setarg", 15, 3, 2, 38, 10],
|
||||
["tail_invoke", 15, 13, 38, 10],
|
||||
["return", 13, 38, 10],
|
||||
"_nop_ur_2",
|
||||
"_nop_ur_3"
|
||||
],
|
||||
"name": "stem",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 28,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["access", 2, "!", 49, 26],
|
||||
["access", 4, {"name":"starts_with","kind":"name","make":"intrinsic"}, 49, 11],
|
||||
["frame", 5, 4, 2, 49, 11],
|
||||
["null", 6, 49, 11],
|
||||
["setarg", 5, 0, 6, 49, 11],
|
||||
["setarg", 5, 1, 1, 49, 11],
|
||||
["setarg", 5, 2, 2, 49, 11],
|
||||
["invoke", 5, 3, 49, 11],
|
||||
["move", 7, 3, 49, 11],
|
||||
["jump_false", 7, "and_end_47", 49, 11],
|
||||
["access", 8, 1, 49, 57],
|
||||
["access", 10, {"name":"text","kind":"name","make":"intrinsic"}, 49, 49],
|
||||
["frame", 11, 10, 2, 49, 49],
|
||||
["null", 12, 49, 49],
|
||||
["setarg", 11, 0, 12, 49, 49],
|
||||
["setarg", 11, 1, 1, 49, 49],
|
||||
["setarg", 11, 2, 8, 49, 49],
|
||||
["invoke", 11, 9, 49, 49],
|
||||
["get", 13, 1, 1, 49, 61],
|
||||
["get", 14, 4, 3, 49, 67],
|
||||
["load_field", 15, 14, "WM_WILDSTAR", 49, 67],
|
||||
["get", 17, 4, 3, 49, 34],
|
||||
["is_proxy", 18, 17, 49, 34],
|
||||
["jump_false", 18, "record_path_48", 49, 34],
|
||||
["null", 19, 49, 34],
|
||||
["access", 20, "match", 49, 34],
|
||||
["array", 21, 0, 49, 34],
|
||||
["push", 21, 9, 49, 34],
|
||||
["push", 21, 13, 49, 34],
|
||||
["push", 21, 15, 49, 34],
|
||||
["frame", 22, 17, 2, 49, 34],
|
||||
["setarg", 22, 0, 19, 49, 34],
|
||||
["setarg", 22, 1, 20, 49, 34],
|
||||
["setarg", 22, 2, 21, 49, 34],
|
||||
["invoke", 22, 16, 49, 34],
|
||||
["jump", "call_done_49", 49, 34],
|
||||
"record_path_48",
|
||||
["load_field", 23, 17, "match", 49, 34],
|
||||
["frame", 24, 23, 3, 49, 34],
|
||||
["setarg", 24, 0, 17, 49, 34],
|
||||
["setarg", 24, 1, 9, 49, 34],
|
||||
["setarg", 24, 2, 13, 49, 34],
|
||||
["setarg", 24, 3, 15, 49, 34],
|
||||
["invoke", 24, 16, 49, 34],
|
||||
"call_done_49",
|
||||
["move", 7, 16, 49, 34],
|
||||
"and_end_47",
|
||||
["jump_false", 7, "if_else_45", 49, 34],
|
||||
["true", 25, 50, 17],
|
||||
["put", 25, 2, 1, 50, 17],
|
||||
["true", 26, 51, 16],
|
||||
["return", 26, 51, 16],
|
||||
"_nop_ur_1",
|
||||
"if_else_45",
|
||||
"if_end_46",
|
||||
["null", 27, 51, 16],
|
||||
["return", 27, 51, 16]
|
||||
],
|
||||
"name": "<anonymous>",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 12,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["false", 2, 47, 17],
|
||||
["get", 3, 1, 1, 48, 12],
|
||||
["function", 4, 6, 48, 19],
|
||||
["null", 5, 53, 8],
|
||||
["true", 6, 53, 14],
|
||||
["access", 8, {"name":"arrfor","kind":"name","make":"intrinsic"}, 48, 5],
|
||||
["frame", 9, 8, 4, 48, 5],
|
||||
["null", 10, 48, 5],
|
||||
["setarg", 9, 0, 10, 48, 5],
|
||||
["setarg", 9, 1, 3, 48, 5],
|
||||
["setarg", 9, 2, 4, 48, 5],
|
||||
["setarg", 9, 3, 5, 48, 5],
|
||||
["setarg", 9, 4, 6, 48, 5],
|
||||
["invoke", 9, 7, 48, 5],
|
||||
["return", 2, 54, 12],
|
||||
"_nop_ur_1",
|
||||
"_nop_ur_2"
|
||||
],
|
||||
"name": "check_neg",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 24,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["access", 2, "!", 60, 27],
|
||||
["access", 4, {"name":"starts_with","kind":"name","make":"intrinsic"}, 60, 12],
|
||||
["frame", 5, 4, 2, 60, 12],
|
||||
["null", 6, 60, 12],
|
||||
["setarg", 5, 0, 6, 60, 12],
|
||||
["setarg", 5, 1, 1, 60, 12],
|
||||
["setarg", 5, 2, 2, 60, 12],
|
||||
["invoke", 5, 3, 60, 12],
|
||||
["not", 7, 3, 60, 12],
|
||||
["move", 8, 7, 60, 12],
|
||||
["jump_false", 8, "and_end_52", 60, 12],
|
||||
["get", 9, 1, 1, 60, 53],
|
||||
["get", 10, 4, 3, 60, 59],
|
||||
["load_field", 11, 10, "WM_WILDSTAR", 60, 59],
|
||||
["get", 13, 4, 3, 60, 35],
|
||||
["is_proxy", 14, 13, 60, 35],
|
||||
["jump_false", 14, "record_path_53", 60, 35],
|
||||
["null", 15, 60, 35],
|
||||
["access", 16, "match", 60, 35],
|
||||
["array", 17, 0, 60, 35],
|
||||
["push", 17, 1, 60, 35],
|
||||
["push", 17, 9, 60, 35],
|
||||
["push", 17, 11, 60, 35],
|
||||
["frame", 18, 13, 2, 60, 35],
|
||||
["setarg", 18, 0, 15, 60, 35],
|
||||
["setarg", 18, 1, 16, 60, 35],
|
||||
["setarg", 18, 2, 17, 60, 35],
|
||||
["invoke", 18, 12, 60, 35],
|
||||
["jump", "call_done_54", 60, 35],
|
||||
"record_path_53",
|
||||
["load_field", 19, 13, "match", 60, 35],
|
||||
["frame", 20, 19, 3, 60, 35],
|
||||
["setarg", 20, 0, 13, 60, 35],
|
||||
["setarg", 20, 1, 1, 60, 35],
|
||||
["setarg", 20, 2, 9, 60, 35],
|
||||
["setarg", 20, 3, 11, 60, 35],
|
||||
["invoke", 20, 12, 60, 35],
|
||||
"call_done_54",
|
||||
["move", 8, 12, 60, 35],
|
||||
"and_end_52",
|
||||
["jump_false", 8, "if_else_50", 60, 35],
|
||||
["true", 21, 61, 17],
|
||||
["put", 21, 2, 1, 61, 17],
|
||||
["true", 22, 62, 16],
|
||||
["return", 22, 62, 16],
|
||||
"_nop_ur_1",
|
||||
"if_else_50",
|
||||
"if_end_51",
|
||||
["null", 23, 62, 16],
|
||||
["return", 23, 62, 16]
|
||||
],
|
||||
"name": "<anonymous>",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 12,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["false", 2, 58, 17],
|
||||
["get", 3, 1, 1, 59, 12],
|
||||
["function", 4, 8, 59, 19],
|
||||
["null", 5, 64, 8],
|
||||
["true", 6, 64, 14],
|
||||
["access", 8, {"name":"arrfor","kind":"name","make":"intrinsic"}, 59, 5],
|
||||
["frame", 9, 8, 4, 59, 5],
|
||||
["null", 10, 59, 5],
|
||||
["setarg", 9, 0, 10, 59, 5],
|
||||
["setarg", 9, 1, 3, 59, 5],
|
||||
["setarg", 9, 2, 4, 59, 5],
|
||||
["setarg", 9, 3, 5, 59, 5],
|
||||
["setarg", 9, 4, 6, 59, 5],
|
||||
["invoke", 9, 7, 59, 5],
|
||||
["return", 2, 65, 12],
|
||||
"_nop_ur_1",
|
||||
"_nop_ur_2"
|
||||
],
|
||||
"name": "check_pos",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 52,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["get", 5, 2, 1, 75, 22],
|
||||
["jump_false", 5, "tern_else_62", 75, 22],
|
||||
["get", 7, 2, 1, 75, 35],
|
||||
["access", 8, "/", 75, 48],
|
||||
["is_text", 10, 7, 75, 48],
|
||||
["jump_false", 10, "add_cn_65", 75, 48],
|
||||
"_nop_tc_1",
|
||||
"_nop_tc_2",
|
||||
["concat", 9, 7, 8, 75, 48],
|
||||
["jump", "add_done_64", 75, 48],
|
||||
"add_cn_65",
|
||||
["is_num", 10, 7, 75, 48],
|
||||
["jump_false", 10, "add_err_66", 75, 48],
|
||||
"_nop_tc_3",
|
||||
["jump", "add_err_66", 75, 48],
|
||||
["add", 9, 7, 8, 75, 48],
|
||||
["jump", "add_done_64", 75, 48],
|
||||
"add_err_66",
|
||||
["disrupt", 75, 48],
|
||||
"add_done_64",
|
||||
["is_text", 13, 9, 75, 54],
|
||||
["jump_false", 13, "add_cn_68", 75, 54],
|
||||
["is_text", 14, 1, 75, 54],
|
||||
["jump_false", 14, "add_cn_68", 75, 54],
|
||||
["concat", 12, 9, 1, 75, 54],
|
||||
["jump", "add_done_67", 75, 54],
|
||||
"add_cn_68",
|
||||
["is_num", 13, 9, 75, 54],
|
||||
["jump_false", 13, "add_err_69", 75, 54],
|
||||
["is_num", 14, 1, 75, 54],
|
||||
["jump_false", 14, "add_err_69", 75, 54],
|
||||
["add", 12, 9, 1, 75, 54],
|
||||
["jump", "add_done_67", 75, 54],
|
||||
"add_err_69",
|
||||
["disrupt", 75, 54],
|
||||
"add_done_67",
|
||||
["move", 6, 12, 75, 54],
|
||||
["jump", "tern_end_63", 75, 54],
|
||||
"tern_else_62",
|
||||
["move", 6, 1, 75, 61],
|
||||
"tern_end_63",
|
||||
["move", 3, 6, 75, 61],
|
||||
["get", 15, 1, 1, 77, 35],
|
||||
["get", 17, 2, 3, 77, 24],
|
||||
["frame", 18, 17, 2, 77, 24],
|
||||
["null", 19, 77, 24],
|
||||
["setarg", 18, 0, 19, 77, 24],
|
||||
["setarg", 18, 1, 15, 77, 24],
|
||||
["setarg", 18, 2, 1, 77, 24],
|
||||
["invoke", 18, 16, 77, 24],
|
||||
["move", 2, 16, 77, 24],
|
||||
["get", 21, 1, 3, 78, 16],
|
||||
["is_proxy", 22, 21, 78, 16],
|
||||
["jump_false", 22, "record_path_70", 78, 16],
|
||||
["null", 23, 78, 16],
|
||||
["access", 24, "stat", 78, 16],
|
||||
["array", 25, 0, 78, 16],
|
||||
["push", 25, 2, 78, 16],
|
||||
["frame", 26, 21, 2, 78, 16],
|
||||
["setarg", 26, 0, 23, 78, 16],
|
||||
["setarg", 26, 1, 24, 78, 16],
|
||||
["setarg", 26, 2, 25, 78, 16],
|
||||
["invoke", 26, 20, 78, 16],
|
||||
["jump", "call_done_71", 78, 16],
|
||||
"record_path_70",
|
||||
["load_field", 27, 21, "stat", 78, 16],
|
||||
["frame", 28, 27, 1, 78, 16],
|
||||
["setarg", 28, 0, 21, 78, 16],
|
||||
["setarg", 28, 1, 2, 78, 16],
|
||||
["invoke", 28, 20, 78, 16],
|
||||
"call_done_71",
|
||||
["move", 4, 20, 78, 16],
|
||||
["load_field", 29, 4, "isDirectory", 80, 11],
|
||||
["jump_false", 29, "if_else_72", 80, 11],
|
||||
["get", 31, 4, 2, 81, 14],
|
||||
["frame", 32, 31, 1, 81, 14],
|
||||
["null", 33, 81, 14],
|
||||
["setarg", 32, 0, 33, 81, 14],
|
||||
["setarg", 32, 1, 3, 81, 14],
|
||||
["invoke", 32, 30, 81, 14],
|
||||
"_nop_bl_1",
|
||||
["jump_true", 30, "if_else_74", 81, 14],
|
||||
["get", 36, 8, 2, 82, 11],
|
||||
["frame", 37, 36, 2, 82, 11],
|
||||
["null", 38, 82, 11],
|
||||
["setarg", 37, 0, 38, 82, 11],
|
||||
["setarg", 37, 1, 2, 82, 11],
|
||||
["setarg", 37, 2, 3, 82, 11],
|
||||
["invoke", 37, 35, 82, 11],
|
||||
["jump", "if_end_75", 82, 11],
|
||||
"if_else_74",
|
||||
"if_end_75",
|
||||
["jump", "if_end_73", 82, 11],
|
||||
"if_else_72",
|
||||
["get", 40, 4, 2, 85, 14],
|
||||
["frame", 41, 40, 1, 85, 14],
|
||||
["null", 42, 85, 14],
|
||||
["setarg", 41, 0, 42, 85, 14],
|
||||
["setarg", 41, 1, 3, 85, 14],
|
||||
["invoke", 41, 39, 85, 14],
|
||||
["not", 43, 39, 85, 14],
|
||||
["move", 44, 43, 85, 14],
|
||||
["jump_false", 44, "and_end_78", 85, 14],
|
||||
["get", 46, 5, 2, 85, 37],
|
||||
["frame", 47, 46, 1, 85, 37],
|
||||
["null", 48, 85, 37],
|
||||
["setarg", 47, 0, 48, 85, 37],
|
||||
["setarg", 47, 1, 3, 85, 37],
|
||||
["invoke", 47, 45, 85, 37],
|
||||
["move", 44, 45, 85, 37],
|
||||
"and_end_78",
|
||||
["jump_false", 44, "if_else_76", 85, 37],
|
||||
["get", 49, 6, 2, 86, 16],
|
||||
["is_array", 50, 49, 86, 25],
|
||||
["jump_false", 50, "push_err_79", 86, 25],
|
||||
["push", 49, 3, 86, 25],
|
||||
["jump", "push_done_80", 86, 25],
|
||||
"push_err_79",
|
||||
["disrupt", 86, 25],
|
||||
"push_done_80",
|
||||
["jump", "if_end_77", 86, 25],
|
||||
"if_else_76",
|
||||
"if_end_77",
|
||||
"if_end_73",
|
||||
["null", 51, 86, 25],
|
||||
["return", 51, 86, 25]
|
||||
],
|
||||
"name": "<anonymous>",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 1
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 32,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["move", 4, 2, 69, 9],
|
||||
["jump_false", 4, "and_end_57", 69, 9],
|
||||
["get", 6, 4, 1, 69, 23],
|
||||
["frame", 7, 6, 1, 69, 23],
|
||||
["null", 8, 69, 23],
|
||||
["setarg", 7, 0, 8, 69, 23],
|
||||
["setarg", 7, 1, 2, 69, 23],
|
||||
["invoke", 7, 5, 69, 23],
|
||||
["move", 4, 5, 69, 23],
|
||||
"and_end_57",
|
||||
["jump_false", 4, "if_else_55", 69, 23],
|
||||
["null", 9, 69, 46],
|
||||
["return", 9, 69, 46],
|
||||
"_nop_ur_1",
|
||||
"if_else_55",
|
||||
"if_end_56",
|
||||
["get", 11, 1, 2, 71, 16],
|
||||
["is_proxy", 12, 11, 71, 16],
|
||||
["jump_false", 12, "record_path_58", 71, 16],
|
||||
["null", 13, 71, 16],
|
||||
["access", 14, "readdir", 71, 16],
|
||||
["array", 15, 0, 71, 16],
|
||||
["push", 15, 1, 71, 16],
|
||||
["frame", 16, 11, 2, 71, 16],
|
||||
["setarg", 16, 0, 13, 71, 16],
|
||||
["setarg", 16, 1, 14, 71, 16],
|
||||
["setarg", 16, 2, 15, 71, 16],
|
||||
["invoke", 16, 10, 71, 16],
|
||||
["jump", "call_done_59", 71, 16],
|
||||
"record_path_58",
|
||||
["load_field", 17, 11, "readdir", 71, 16],
|
||||
["frame", 18, 17, 1, 71, 16],
|
||||
["setarg", 18, 0, 11, 71, 16],
|
||||
["setarg", 18, 1, 1, 71, 16],
|
||||
["invoke", 18, 10, 71, 16],
|
||||
"call_done_59",
|
||||
["move", 3, 10, 71, 16],
|
||||
"_nop_bl_1",
|
||||
["jump_true", 3, "if_else_60", 72, 10],
|
||||
["null", 20, 72, 16],
|
||||
["return", 20, 72, 16],
|
||||
"_nop_ur_2",
|
||||
"if_else_60",
|
||||
"if_end_61",
|
||||
["function", 21, 10, 74, 18],
|
||||
["length", 23, 3, 74, 18],
|
||||
["int", 24, 0, 74, 18],
|
||||
["int", 28, 1, 74, 18],
|
||||
["null", 27, 74, 18],
|
||||
"arrfor_loop_81",
|
||||
["lt_int", 25, 24, 23, 74, 18],
|
||||
["jump_false", 25, "arrfor_done_82", 74, 18],
|
||||
["load_index", 26, 3, 24, 74, 18],
|
||||
["frame", 29, 21, 2, 74, 18],
|
||||
["setarg", 29, 0, 27, 74, 18],
|
||||
["setarg", 29, 1, 26, 74, 18],
|
||||
["setarg", 29, 2, 24, 74, 18],
|
||||
["invoke", 29, 30, 74, 18],
|
||||
["add", 24, 24, 28, 74, 18],
|
||||
["jump", "arrfor_loop_81", 74, 18],
|
||||
"arrfor_done_82",
|
||||
["null", 22, 74, 18],
|
||||
["null", 31, 74, 18],
|
||||
["return", 31, 74, 18]
|
||||
],
|
||||
"name": "visit",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 2
|
||||
},
|
||||
{
|
||||
"disruption_pc": 0,
|
||||
"nr_slots": 34,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["move", 3, 2, 42, 14],
|
||||
["null", 9, 43, 15],
|
||||
["is_identical", 10, 3, 9, 43, 15],
|
||||
["jump_true", 10, "eq_done_39", 43, 15],
|
||||
["is_int", 11, 3, 43, 15],
|
||||
["jump_false", 11, "eq_ni_40", 43, 15],
|
||||
"_nop_tc_1",
|
||||
["jump", "eq_ni_40", 43, 15],
|
||||
["eq_int", 10, 3, 9, 43, 15],
|
||||
["jump", "eq_done_39", 43, 15],
|
||||
"eq_ni_40",
|
||||
["is_num", 11, 3, 43, 15],
|
||||
["jump_false", 11, "eq_nn_41", 43, 15],
|
||||
"_nop_tc_2",
|
||||
["jump", "eq_nn_41", 43, 15],
|
||||
["eq_float", 10, 3, 9, 43, 15],
|
||||
["jump", "eq_done_39", 43, 15],
|
||||
"eq_nn_41",
|
||||
["is_text", 11, 3, 43, 15],
|
||||
["jump_false", 11, "eq_nt_42", 43, 15],
|
||||
"_nop_tc_3",
|
||||
["jump", "eq_nt_42", 43, 15],
|
||||
["eq_text", 10, 3, 9, 43, 15],
|
||||
["jump", "eq_done_39", 43, 15],
|
||||
"eq_nt_42",
|
||||
["is_null", 11, 3, 43, 15],
|
||||
["jump_false", 11, "eq_nnl_43", 43, 15],
|
||||
"_nop_tc_4",
|
||||
"_nop_tc_5",
|
||||
["true", 10, 43, 15],
|
||||
["jump", "eq_done_39", 43, 15],
|
||||
"eq_nnl_43",
|
||||
["is_bool", 11, 3, 43, 15],
|
||||
["jump_false", 11, "eq_nb_44", 43, 15],
|
||||
"_nop_tc_6",
|
||||
["jump", "eq_nb_44", 43, 15],
|
||||
["eq_bool", 10, 3, 9, 43, 15],
|
||||
["jump", "eq_done_39", 43, 15],
|
||||
"eq_nb_44",
|
||||
["false", 10, 43, 15],
|
||||
"eq_done_39",
|
||||
["jump_false", 10, "if_else_37", 43, 15],
|
||||
["access", 13, ".", 43, 28],
|
||||
["move", 3, 13, 43, 28],
|
||||
["jump", "if_end_38", 43, 28],
|
||||
"if_else_37",
|
||||
"if_end_38",
|
||||
["array", 14, 0, 44, 17],
|
||||
["move", 6, 14, 44, 17],
|
||||
["function", 15, 7, 46, 3],
|
||||
["move", 4, 15, 46, 3],
|
||||
["function", 16, 9, 57, 3],
|
||||
["move", 5, 16, 57, 3],
|
||||
["function", 17, 11, 68, 3],
|
||||
["move", 8, 17, 68, 3],
|
||||
["get", 19, 1, 1, 92, 12],
|
||||
["is_proxy", 20, 19, 92, 12],
|
||||
["jump_false", 20, "record_path_83", 92, 12],
|
||||
["null", 21, 92, 12],
|
||||
["access", 22, "stat", 92, 12],
|
||||
["array", 23, 0, 92, 12],
|
||||
["push", 23, 3, 92, 12],
|
||||
["frame", 24, 19, 2, 92, 12],
|
||||
["setarg", 24, 0, 21, 92, 12],
|
||||
["setarg", 24, 1, 22, 92, 12],
|
||||
["setarg", 24, 2, 23, 92, 12],
|
||||
["invoke", 24, 18, 92, 12],
|
||||
["jump", "call_done_84", 92, 12],
|
||||
"record_path_83",
|
||||
["load_field", 25, 19, "stat", 92, 12],
|
||||
["frame", 26, 25, 1, 92, 12],
|
||||
["setarg", 26, 0, 19, 92, 12],
|
||||
["setarg", 26, 1, 3, 92, 12],
|
||||
["invoke", 26, 18, 92, 12],
|
||||
"call_done_84",
|
||||
["move", 7, 18, 92, 12],
|
||||
["move", 27, 7, 93, 7],
|
||||
["jump_false", 27, "and_end_87", 93, 7],
|
||||
["load_field", 28, 7, "isDirectory", 93, 13],
|
||||
["move", 27, 28, 93, 13],
|
||||
"and_end_87",
|
||||
["jump_false", 27, "if_else_85", 93, 13],
|
||||
["access", 29, "", 94, 17],
|
||||
["frame", 31, 8, 2, 94, 5],
|
||||
["null", 32, 94, 5],
|
||||
["setarg", 31, 0, 32, 94, 5],
|
||||
["setarg", 31, 1, 3, 94, 5],
|
||||
["setarg", 31, 2, 29, 94, 5],
|
||||
["invoke", 31, 30, 94, 5],
|
||||
["jump", "if_end_86", 94, 5],
|
||||
"if_else_85",
|
||||
"if_end_86",
|
||||
["return", 6, 97, 10],
|
||||
"_nop_ur_1",
|
||||
"_nop_ur_2"
|
||||
],
|
||||
"name": "<anonymous>",
|
||||
"filename": "fd.cm",
|
||||
"nr_args": 2
|
||||
}
|
||||
],
|
||||
"main": {
|
||||
"nr_slots": 22,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["function", 5, 1, 0, 0],
|
||||
["move", 3, 5, 0, 0],
|
||||
["function", 6, 2, 0, 0],
|
||||
["move", 2, 6, 0, 0],
|
||||
["access", 7, "internal/fd", 1, 14],
|
||||
["access", 9, {"name":"use","kind":"name","make":"intrinsic"}, 1, 10],
|
||||
["frame", 10, 9, 1, 1, 10],
|
||||
["null", 11, 1, 10],
|
||||
["setarg", 10, 0, 11, 1, 10],
|
||||
["setarg", 10, 1, 7, 1, 10],
|
||||
["invoke", 10, 8, 1, 10],
|
||||
["move", 1, 8, 1, 10],
|
||||
["access", 12, "wildstar", 2, 20],
|
||||
["access", 14, {"name":"use","kind":"name","make":"intrinsic"}, 2, 16],
|
||||
["frame", 15, 14, 1, 2, 16],
|
||||
["null", 16, 2, 16],
|
||||
["setarg", 15, 0, 16, 2, 16],
|
||||
["setarg", 15, 1, 12, 2, 16],
|
||||
["invoke", 15, 13, 2, 16],
|
||||
["move", 4, 13, 2, 16],
|
||||
["store_field", 1, 2, "join_paths", 22, 1],
|
||||
["function", 17, 3, 23, 15],
|
||||
["store_field", 1, 17, "basename", 23, 1],
|
||||
["function", 18, 4, 29, 14],
|
||||
["store_field", 1, 18, "dirname", 29, 1],
|
||||
["function", 19, 5, 35, 11],
|
||||
["store_field", 1, 19, "stem", 35, 1],
|
||||
["function", 20, 12, 41, 13],
|
||||
["store_field", 1, 20, "globfs", 41, 1],
|
||||
["return", 1, 100, 8],
|
||||
"_nop_ur_1",
|
||||
"_nop_ur_2"
|
||||
],
|
||||
"nr_args": 0
|
||||
},
|
||||
"filename": "fd.cm",
|
||||
"data": {}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
2965
boot/link.cm.mcode
2965
boot/link.cm.mcode
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3531
boot/pronto.cm.mcode
3531
boot/pronto.cm.mcode
File diff suppressed because it is too large
Load Diff
2255
boot/qbe.cm.mcode
2255
boot/qbe.cm.mcode
File diff suppressed because it is too large
Load Diff
13301
boot/qbe_emit.cm.mcode
13301
boot/qbe_emit.cm.mcode
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
||||
// seed_bootstrap.cm — minimal bootstrap for regenerating boot files
|
||||
// Loads only the compiler pipeline, runs a script directly (no engine/actors)
|
||||
// Usage: ./cell --dev --seed regen
|
||||
//
|
||||
// Hidden env: os, core_path, shop_path, args, json
|
||||
|
||||
var load_internal = os.load_internal
|
||||
var fd = load_internal("js_core_internal_fd_use")
|
||||
|
||||
var use_cache = {}
|
||||
use_cache['fd'] = fd
|
||||
use_cache['os'] = os
|
||||
use_cache['json'] = json
|
||||
|
||||
function use_basic(path) {
|
||||
if (use_cache[path])
|
||||
return use_cache[path]
|
||||
var result = load_internal("js_core_" + replace(path, '/', '_') + "_use")
|
||||
if (result) {
|
||||
use_cache[path] = result
|
||||
return result
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// Load a module from boot .mcode — no caching, just eval
|
||||
function boot_load(name) {
|
||||
var mcode_path = core_path + '/boot/' + name + ".cm.mcode"
|
||||
var mcode_json = null
|
||||
if (!fd.is_file(mcode_path)) {
|
||||
print("seed: missing boot mcode: " + mcode_path + "\n")
|
||||
disrupt
|
||||
}
|
||||
mcode_json = text(fd.slurp(mcode_path))
|
||||
return mach_eval_mcode(name, mcode_json, {use: use_basic})
|
||||
}
|
||||
|
||||
var tokenize_mod = boot_load("tokenize")
|
||||
var parse_mod = boot_load("parse")
|
||||
var fold_mod = boot_load("fold")
|
||||
var mcode_mod = boot_load("mcode")
|
||||
var streamline_mod = boot_load("streamline")
|
||||
|
||||
use_cache['tokenize'] = tokenize_mod
|
||||
use_cache['parse'] = parse_mod
|
||||
use_cache['fold'] = fold_mod
|
||||
use_cache['mcode'] = mcode_mod
|
||||
use_cache['streamline'] = streamline_mod
|
||||
|
||||
function analyze(src, filename) {
|
||||
var tok_result = tokenize_mod(src, filename)
|
||||
var ast = parse_mod(tok_result.tokens, src, filename, tokenize_mod)
|
||||
var _i = 0
|
||||
var e = null
|
||||
var has_errors = ast.errors != null && length(ast.errors) > 0
|
||||
if (has_errors) {
|
||||
while (_i < length(ast.errors)) {
|
||||
e = ast.errors[_i]
|
||||
if (e.line != null) {
|
||||
print(`${filename}:${text(e.line)}:${text(e.column)}: error: ${e.message}`)
|
||||
} else {
|
||||
print(`${filename}: error: ${e.message}`)
|
||||
}
|
||||
_i = _i + 1
|
||||
}
|
||||
disrupt
|
||||
}
|
||||
return fold_mod(ast)
|
||||
}
|
||||
|
||||
function run_ast(name, ast, env) {
|
||||
var compiled = mcode_mod(ast)
|
||||
var optimized = streamline_mod(compiled)
|
||||
var mcode_json = json.encode(optimized)
|
||||
return mach_eval_mcode(name, mcode_json, env)
|
||||
}
|
||||
|
||||
function use_fn(path) {
|
||||
var result = null
|
||||
var file_path = null
|
||||
var script = null
|
||||
var ast = null
|
||||
var mcode_path = null
|
||||
var mcode_json = null
|
||||
if (use_cache[path])
|
||||
return use_cache[path]
|
||||
|
||||
// Try C embed
|
||||
result = load_internal("js_core_" + replace(path, '/', '_') + "_use")
|
||||
if (result) {
|
||||
use_cache[path] = result
|
||||
return result
|
||||
}
|
||||
|
||||
// Try boot mcode
|
||||
mcode_path = core_path + '/boot/' + path + '.cm.mcode'
|
||||
if (fd.is_file(mcode_path)) {
|
||||
mcode_json = text(fd.slurp(mcode_path))
|
||||
result = mach_eval_mcode(path, mcode_json, {use: use_fn})
|
||||
use_cache[path] = result
|
||||
return result
|
||||
}
|
||||
|
||||
// Try .cm source (CWD then core)
|
||||
file_path = path + '.cm'
|
||||
if (!fd.is_file(file_path))
|
||||
file_path = core_path + '/' + path + '.cm'
|
||||
if (fd.is_file(file_path)) {
|
||||
script = text(fd.slurp(file_path))
|
||||
ast = analyze(script, file_path)
|
||||
result = run_ast(path, ast, {use: use_fn})
|
||||
use_cache[path] = result
|
||||
return result
|
||||
}
|
||||
|
||||
print("seed: module not found: " + path + "\n")
|
||||
disrupt
|
||||
}
|
||||
|
||||
// Run the program from args
|
||||
var program = args[0]
|
||||
var user_args = []
|
||||
var _j = 1
|
||||
var prog_path = null
|
||||
var script = null
|
||||
var ast = null
|
||||
|
||||
if (!program) {
|
||||
print("seed: no program specified\n")
|
||||
disrupt
|
||||
}
|
||||
|
||||
while (_j < length(args)) {
|
||||
push(user_args, args[_j])
|
||||
_j = _j + 1
|
||||
}
|
||||
|
||||
prog_path = program + '.ce'
|
||||
if (!fd.is_file(prog_path))
|
||||
prog_path = core_path + '/' + program + '.ce'
|
||||
if (!fd.is_file(prog_path)) {
|
||||
prog_path = program + '.cm'
|
||||
if (!fd.is_file(prog_path))
|
||||
prog_path = core_path + '/' + program + '.cm'
|
||||
}
|
||||
if (!fd.is_file(prog_path)) {
|
||||
print("seed: program not found: " + program + "\n")
|
||||
disrupt
|
||||
}
|
||||
|
||||
script = text(fd.slurp(prog_path))
|
||||
ast = analyze(script, prog_path)
|
||||
run_ast(program, ast, {use: use_fn, args: user_args})
|
||||
File diff suppressed because it is too large
Load Diff
11574
boot/streamline.cm.mcode
11574
boot/streamline.cm.mcode
File diff suppressed because it is too large
Load Diff
3249
boot/time.cm.mcode
3249
boot/time.cm.mcode
File diff suppressed because it is too large
Load Diff
3334
boot/toml.cm.mcode
3334
boot/toml.cm.mcode
File diff suppressed because it is too large
Load Diff
@@ -1,619 +0,0 @@
|
||||
{
|
||||
"name": "toolchains.cm",
|
||||
"functions": [],
|
||||
"main": {
|
||||
"nr_slots": 304,
|
||||
"nr_close_slots": 0,
|
||||
"instructions": [
|
||||
["record", 1, 22],
|
||||
["record", 2, 12],
|
||||
["access", 3, "arm-none-eabi-gcc", 3, 8],
|
||||
["store_field", 2, 3, "c", 3, 8],
|
||||
["access", 4, "arm-none-eabi-g++", 4, 10],
|
||||
["store_field", 2, 4, "cpp", 4, 10],
|
||||
["access", 5, "arm-none-eabi-ar", 5, 9],
|
||||
["store_field", 2, 5, "ar", 5, 9],
|
||||
["access", 6, "arm-none-eabi-strip", 6, 12],
|
||||
["store_field", 2, 6, "strip", 6, 12],
|
||||
["access", 7, "arm-none-eabi-objcopy", 7, 14],
|
||||
["store_field", 2, 7, "objcopy", 7, 14],
|
||||
["access", 8, "arm-none-eabi-gcc", 8, 9],
|
||||
["store_field", 2, 8, "ld", 8, 9],
|
||||
["access", 9, "playdate", 9, 13],
|
||||
["store_field", 2, 9, "system", 9, 13],
|
||||
["access", 10, "arm", 10, 17],
|
||||
["store_field", 2, 10, "cpu_family", 10, 17],
|
||||
["access", 11, "cortex-m7", 11, 10],
|
||||
["store_field", 2, 11, "cpu", 11, 10],
|
||||
["access", 12, "little", 12, 13],
|
||||
["store_field", 2, 12, "endian", 12, 13],
|
||||
["access", 13, "-DTARGET_PLAYDATE=1", 13, 14],
|
||||
["access", 14, "-DTARGET_EXTENSION=1", 13, 37],
|
||||
["access", 15, "-mcpu=cortex-m7", 13, 61],
|
||||
["access", 16, "-mthumb", 13, 80],
|
||||
["access", 17, "-mfloat-abi=hard", 13, 91],
|
||||
["access", 18, "-mfpu=fpv5-sp-d16", 13, 111],
|
||||
["access", 19, "-fno-exceptions", 13, 132],
|
||||
["array", 20, 7, 13, 132],
|
||||
["push", 20, 13, 13, 132],
|
||||
["push", 20, 14, 13, 132],
|
||||
["push", 20, 15, 13, 132],
|
||||
["push", 20, 16, 13, 132],
|
||||
["push", 20, 17, 13, 132],
|
||||
["push", 20, 18, 13, 132],
|
||||
["push", 20, 19, 13, 132],
|
||||
["store_field", 2, 20, "c_args", 13, 132],
|
||||
["access", 21, "-mcpu=cortex-m7", 14, 19],
|
||||
["access", 22, "-mthumb", 14, 38],
|
||||
["access", 23, "-mfloat-abi=hard", 14, 49],
|
||||
["access", 24, "-mfpu=fpv5-sp-d16", 14, 69],
|
||||
["access", 25, "-nostartfiles", 14, 90],
|
||||
["access", 26, "-T/Users/john/Developer/PlaydateSDK/C_API/buildsupport/link_map.ld", 14, 107],
|
||||
["array", 27, 6, 14, 107],
|
||||
["push", 27, 21, 14, 107],
|
||||
["push", 27, 22, 14, 107],
|
||||
["push", 27, 23, 14, 107],
|
||||
["push", 27, 24, 14, 107],
|
||||
["push", 27, 25, 14, 107],
|
||||
["push", 27, 26, 14, 107],
|
||||
["store_field", 2, 27, "c_link_args", 14, 107],
|
||||
["store_field", 1, 2, "playdate", 14, 107],
|
||||
["record", 28, 10],
|
||||
["access", 29, "clang", 17, 8],
|
||||
["store_field", 28, 29, "c", 17, 8],
|
||||
["access", 30, "clang++", 18, 10],
|
||||
["store_field", 28, 30, "cpp", 18, 10],
|
||||
["access", 31, "ar", 19, 9],
|
||||
["store_field", 28, 31, "ar", 19, 9],
|
||||
["access", 32, "strip", 20, 12],
|
||||
["store_field", 28, 32, "strip", 20, 12],
|
||||
["access", 33, "playdate", 21, 13],
|
||||
["store_field", 28, 33, "system", 21, 13],
|
||||
["access", 34, "x86_64", 22, 17],
|
||||
["store_field", 28, 34, "cpu_family", 22, 17],
|
||||
["access", 35, "x86_64", 23, 10],
|
||||
["store_field", 28, 35, "cpu", 23, 10],
|
||||
["access", 36, "little", 24, 13],
|
||||
["store_field", 28, 36, "endian", 24, 13],
|
||||
["access", 37, "-U__APPLE__ -DTARGET_SIMULATOR=1", 25, 14],
|
||||
["access", 38, "-DTARGET_EXTENSION=1", 25, 50],
|
||||
["access", 39, "-fPIC", 25, 74],
|
||||
["array", 40, 3, 25, 74],
|
||||
["push", 40, 37, 25, 74],
|
||||
["push", 40, 38, 25, 74],
|
||||
["push", 40, 39, 25, 74],
|
||||
["store_field", 28, 40, "c_args", 25, 74],
|
||||
["access", 41, "-shared", 26, 19],
|
||||
["array", 42, 1, 26, 19],
|
||||
["push", 42, 41, 26, 19],
|
||||
["store_field", 28, 42, "c_link_args", 26, 19],
|
||||
["store_field", 1, 28, "playdate_simulator", 26, 19],
|
||||
["record", 43, 11],
|
||||
["access", 44, "x86_64-w64-mingw32-gcc", 29, 8],
|
||||
["store_field", 43, 44, "c", 29, 8],
|
||||
["access", 45, "x86_64-w64-mingw32-g++", 30, 10],
|
||||
["store_field", 43, 45, "cpp", 30, 10],
|
||||
["access", 46, "x86_64-w64-mingw32-ar", 31, 9],
|
||||
["store_field", 43, 46, "ar", 31, 9],
|
||||
["access", 47, "x86_64-w64-mingw32-windres", 32, 14],
|
||||
["store_field", 43, 47, "windres", 32, 14],
|
||||
["access", 48, "x86_64-w64-mingw32-strip", 33, 12],
|
||||
["store_field", 43, 48, "strip", 33, 12],
|
||||
["access", 49, "windows", 34, 13],
|
||||
["store_field", 43, 49, "system", 34, 13],
|
||||
["access", 50, "x86_64", 35, 17],
|
||||
["store_field", 43, 50, "cpu_family", 35, 17],
|
||||
["access", 51, "x86_64", 36, 10],
|
||||
["store_field", 43, 51, "cpu", 36, 10],
|
||||
["access", 52, "little", 37, 13],
|
||||
["store_field", 43, 52, "endian", 37, 13],
|
||||
["array", 53, 0, 38, 13],
|
||||
["store_field", 43, 53, "c_args", 38, 13],
|
||||
["array", 54, 0, 39, 18],
|
||||
["store_field", 43, 54, "c_link_args", 39, 18],
|
||||
["store_field", 1, 43, "windows", 39, 18],
|
||||
["record", 55, 11],
|
||||
["access", 56, "i686-w64-mingw32-gcc", 42, 8],
|
||||
["store_field", 55, 56, "c", 42, 8],
|
||||
["access", 57, "i686-w64-mingw32-g++", 43, 10],
|
||||
["store_field", 55, 57, "cpp", 43, 10],
|
||||
["access", 58, "i686-w64-mingw32-ar", 44, 9],
|
||||
["store_field", 55, 58, "ar", 44, 9],
|
||||
["access", 59, "i686-w64-mingw32-windres", 45, 14],
|
||||
["store_field", 55, 59, "windres", 45, 14],
|
||||
["access", 60, "i686-w64-mingw32-strip", 46, 12],
|
||||
["store_field", 55, 60, "strip", 46, 12],
|
||||
["access", 61, "windows", 47, 13],
|
||||
["store_field", 55, 61, "system", 47, 13],
|
||||
["access", 62, "x86", 48, 17],
|
||||
["store_field", 55, 62, "cpu_family", 48, 17],
|
||||
["access", 63, "i686", 49, 10],
|
||||
["store_field", 55, 63, "cpu", 49, 10],
|
||||
["access", 64, "little", 50, 13],
|
||||
["store_field", 55, 64, "endian", 50, 13],
|
||||
["array", 65, 0, 51, 13],
|
||||
["store_field", 55, 65, "c_args", 51, 13],
|
||||
["array", 66, 0, 52, 18],
|
||||
["store_field", 55, 66, "c_link_args", 52, 18],
|
||||
["store_field", 1, 55, "windows_i686", 52, 18],
|
||||
["record", 67, 10],
|
||||
["access", 68, "zig cc -target x86_64-linux-musl", 55, 8],
|
||||
["store_field", 67, 68, "c", 55, 8],
|
||||
["access", 69, "zig c++ -target x86_64-linux-musl", 56, 10],
|
||||
["store_field", 67, 69, "cpp", 56, 10],
|
||||
["access", 70, "zig ar", 57, 9],
|
||||
["store_field", 67, 70, "ar", 57, 9],
|
||||
["access", 71, "strip", 58, 12],
|
||||
["store_field", 67, 71, "strip", 58, 12],
|
||||
["access", 72, "linux", 59, 13],
|
||||
["store_field", 67, 72, "system", 59, 13],
|
||||
["access", 73, "x86_64", 60, 17],
|
||||
["store_field", 67, 73, "cpu_family", 60, 17],
|
||||
["access", 74, "x86_64", 61, 10],
|
||||
["store_field", 67, 74, "cpu", 61, 10],
|
||||
["access", 75, "little", 62, 13],
|
||||
["store_field", 67, 75, "endian", 62, 13],
|
||||
["array", 76, 0, 63, 13],
|
||||
["store_field", 67, 76, "c_args", 63, 13],
|
||||
["array", 77, 0, 64, 18],
|
||||
["store_field", 67, 77, "c_link_args", 64, 18],
|
||||
["store_field", 1, 67, "linux", 64, 18],
|
||||
["record", 78, 10],
|
||||
["access", 79, "zig cc -target aarch64-linux-musl", 67, 8],
|
||||
["store_field", 78, 79, "c", 67, 8],
|
||||
["access", 80, "zig c++ -target aarch64-linux-musl", 68, 10],
|
||||
["store_field", 78, 80, "cpp", 68, 10],
|
||||
["access", 81, "zig ar", 69, 9],
|
||||
["store_field", 78, 81, "ar", 69, 9],
|
||||
["access", 82, "strip", 70, 12],
|
||||
["store_field", 78, 82, "strip", 70, 12],
|
||||
["access", 83, "linux", 71, 13],
|
||||
["store_field", 78, 83, "system", 71, 13],
|
||||
["access", 84, "aarch64", 72, 17],
|
||||
["store_field", 78, 84, "cpu_family", 72, 17],
|
||||
["access", 85, "aarch64", 73, 10],
|
||||
["store_field", 78, 85, "cpu", 73, 10],
|
||||
["access", 86, "little", 74, 13],
|
||||
["store_field", 78, 86, "endian", 74, 13],
|
||||
["array", 87, 0, 75, 13],
|
||||
["store_field", 78, 87, "c_args", 75, 13],
|
||||
["array", 88, 0, 76, 18],
|
||||
["store_field", 78, 88, "c_link_args", 76, 18],
|
||||
["store_field", 1, 78, "linux_arm64", 76, 18],
|
||||
["record", 89, 10],
|
||||
["access", 90, "clang -target arm64-apple-macos11", 79, 8],
|
||||
["store_field", 89, 90, "c", 79, 8],
|
||||
["access", 91, "clang++ -target arm64-apple-macos11", 80, 10],
|
||||
["store_field", 89, 91, "cpp", 80, 10],
|
||||
["access", 92, "ar", 81, 9],
|
||||
["store_field", 89, 92, "ar", 81, 9],
|
||||
["access", 93, "strip", 82, 12],
|
||||
["store_field", 89, 93, "strip", 82, 12],
|
||||
["access", 94, "darwin", 83, 13],
|
||||
["store_field", 89, 94, "system", 83, 13],
|
||||
["access", 95, "aarch64", 84, 17],
|
||||
["store_field", 89, 95, "cpu_family", 84, 17],
|
||||
["access", 96, "aarch64", 85, 10],
|
||||
["store_field", 89, 96, "cpu", 85, 10],
|
||||
["access", 97, "little", 86, 13],
|
||||
["store_field", 89, 97, "endian", 86, 13],
|
||||
["access", 98, "-isysroot", 87, 14],
|
||||
["access", 99, "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", 87, 27],
|
||||
["array", 100, 2, 87, 27],
|
||||
["push", 100, 98, 87, 27],
|
||||
["push", 100, 99, 87, 27],
|
||||
["store_field", 89, 100, "c_args", 87, 27],
|
||||
["access", 101, "-isysroot", 88, 19],
|
||||
["access", 102, "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", 88, 32],
|
||||
["array", 103, 2, 88, 32],
|
||||
["push", 103, 101, 88, 32],
|
||||
["push", 103, 102, 88, 32],
|
||||
["store_field", 89, 103, "c_link_args", 88, 32],
|
||||
["store_field", 1, 89, "macos_arm64", 88, 32],
|
||||
["record", 104, 10],
|
||||
["access", 105, "clang -target x86_64-apple-macos10.12", 91, 8],
|
||||
["store_field", 104, 105, "c", 91, 8],
|
||||
["access", 106, "clang++ -target x86_64-apple-macos10.12", 92, 10],
|
||||
["store_field", 104, 106, "cpp", 92, 10],
|
||||
["access", 107, "ar", 93, 9],
|
||||
["store_field", 104, 107, "ar", 93, 9],
|
||||
["access", 108, "strip", 94, 12],
|
||||
["store_field", 104, 108, "strip", 94, 12],
|
||||
["access", 109, "darwin", 95, 13],
|
||||
["store_field", 104, 109, "system", 95, 13],
|
||||
["access", 110, "x86_64", 96, 17],
|
||||
["store_field", 104, 110, "cpu_family", 96, 17],
|
||||
["access", 111, "x86_64", 97, 10],
|
||||
["store_field", 104, 111, "cpu", 97, 10],
|
||||
["access", 112, "little", 98, 13],
|
||||
["store_field", 104, 112, "endian", 98, 13],
|
||||
["access", 113, "-isysroot", 99, 14],
|
||||
["access", 114, "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", 99, 27],
|
||||
["array", 115, 2, 99, 27],
|
||||
["push", 115, 113, 99, 27],
|
||||
["push", 115, 114, 99, 27],
|
||||
["store_field", 104, 115, "c_args", 99, 27],
|
||||
["access", 116, "-isysroot", 100, 19],
|
||||
["access", 117, "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", 100, 32],
|
||||
["array", 118, 2, 100, 32],
|
||||
["push", 118, 116, 100, 32],
|
||||
["push", 118, 117, 100, 32],
|
||||
["store_field", 104, 118, "c_link_args", 100, 32],
|
||||
["store_field", 1, 104, "macos_x86_64", 100, 32],
|
||||
["record", 119, 10],
|
||||
["access", 120, "clang -target arm64-apple-ios12.0", 103, 8],
|
||||
["store_field", 119, 120, "c", 103, 8],
|
||||
["access", 121, "clang++ -target arm64-apple-ios12.0", 104, 10],
|
||||
["store_field", 119, 121, "cpp", 104, 10],
|
||||
["access", 122, "ar", 105, 9],
|
||||
["store_field", 119, 122, "ar", 105, 9],
|
||||
["access", 123, "strip", 106, 12],
|
||||
["store_field", 119, 123, "strip", 106, 12],
|
||||
["access", 124, "ios", 107, 13],
|
||||
["store_field", 119, 124, "system", 107, 13],
|
||||
["access", 125, "aarch64", 108, 17],
|
||||
["store_field", 119, 125, "cpu_family", 108, 17],
|
||||
["access", 126, "aarch64", 109, 10],
|
||||
["store_field", 119, 126, "cpu", 109, 10],
|
||||
["access", 127, "little", 110, 13],
|
||||
["store_field", 119, 127, "endian", 110, 13],
|
||||
["access", 128, "-isysroot", 111, 14],
|
||||
["access", 129, "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk", 111, 27],
|
||||
["access", 130, "-fembed-bitcode", 111, 129],
|
||||
["array", 131, 3, 111, 129],
|
||||
["push", 131, 128, 111, 129],
|
||||
["push", 131, 129, 111, 129],
|
||||
["push", 131, 130, 111, 129],
|
||||
["store_field", 119, 131, "c_args", 111, 129],
|
||||
["access", 132, "-isysroot", 112, 19],
|
||||
["access", 133, "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk", 112, 32],
|
||||
["access", 134, "-fembed-bitcode", 112, 134],
|
||||
["array", 135, 3, 112, 134],
|
||||
["push", 135, 132, 112, 134],
|
||||
["push", 135, 133, 112, 134],
|
||||
["push", 135, 134, 112, 134],
|
||||
["store_field", 119, 135, "c_link_args", 112, 134],
|
||||
["store_field", 1, 119, "ios_arm64", 112, 134],
|
||||
["record", 136, 10],
|
||||
["access", 137, "clang -target arm64-apple-ios12.0-simulator", 115, 8],
|
||||
["store_field", 136, 137, "c", 115, 8],
|
||||
["access", 138, "clang++ -target arm64-apple-ios12.0-simulator", 116, 10],
|
||||
["store_field", 136, 138, "cpp", 116, 10],
|
||||
["access", 139, "ar", 117, 9],
|
||||
["store_field", 136, 139, "ar", 117, 9],
|
||||
["access", 140, "strip", 118, 12],
|
||||
["store_field", 136, 140, "strip", 118, 12],
|
||||
["access", 141, "ios", 119, 13],
|
||||
["store_field", 136, 141, "system", 119, 13],
|
||||
["access", 142, "aarch64", 120, 17],
|
||||
["store_field", 136, 142, "cpu_family", 120, 17],
|
||||
["access", 143, "aarch64", 121, 10],
|
||||
["store_field", 136, 143, "cpu", 121, 10],
|
||||
["access", 144, "little", 122, 13],
|
||||
["store_field", 136, 144, "endian", 122, 13],
|
||||
["access", 145, "-isysroot", 123, 14],
|
||||
["access", 146, "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk", 123, 27],
|
||||
["array", 147, 2, 123, 27],
|
||||
["push", 147, 145, 123, 27],
|
||||
["push", 147, 146, 123, 27],
|
||||
["store_field", 136, 147, "c_args", 123, 27],
|
||||
["access", 148, "-isysroot", 124, 19],
|
||||
["access", 149, "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk", 124, 32],
|
||||
["array", 150, 2, 124, 32],
|
||||
["push", 150, 148, 124, 32],
|
||||
["push", 150, 149, 124, 32],
|
||||
["store_field", 136, 150, "c_link_args", 124, 32],
|
||||
["store_field", 1, 136, "ios_simulator_arm64", 124, 32],
|
||||
["record", 151, 10],
|
||||
["access", 152, "clang -target x86_64-apple-ios12.0-simulator", 127, 8],
|
||||
["store_field", 151, 152, "c", 127, 8],
|
||||
["access", 153, "clang++ -target x86_64-apple-ios12.0-simulator", 128, 10],
|
||||
["store_field", 151, 153, "cpp", 128, 10],
|
||||
["access", 154, "ar", 129, 9],
|
||||
["store_field", 151, 154, "ar", 129, 9],
|
||||
["access", 155, "strip", 130, 12],
|
||||
["store_field", 151, 155, "strip", 130, 12],
|
||||
["access", 156, "ios", 131, 13],
|
||||
["store_field", 151, 156, "system", 131, 13],
|
||||
["access", 157, "x86_64", 132, 17],
|
||||
["store_field", 151, 157, "cpu_family", 132, 17],
|
||||
["access", 158, "x86_64", 133, 10],
|
||||
["store_field", 151, 158, "cpu", 133, 10],
|
||||
["access", 159, "little", 134, 13],
|
||||
["store_field", 151, 159, "endian", 134, 13],
|
||||
["access", 160, "-isysroot", 135, 14],
|
||||
["access", 161, "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk", 135, 27],
|
||||
["array", 162, 2, 135, 27],
|
||||
["push", 162, 160, 135, 27],
|
||||
["push", 162, 161, 135, 27],
|
||||
["store_field", 151, 162, "c_args", 135, 27],
|
||||
["access", 163, "-isysroot", 136, 19],
|
||||
["access", 164, "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk", 136, 32],
|
||||
["array", 165, 2, 136, 32],
|
||||
["push", 165, 163, 136, 32],
|
||||
["push", 165, 164, 136, 32],
|
||||
["store_field", 151, 165, "c_link_args", 136, 32],
|
||||
["store_field", 1, 151, "ios_simulator_x86_64", 136, 32],
|
||||
["record", 166, 10],
|
||||
["access", 167, "clang -target arm64-apple-tvos12.0", 139, 8],
|
||||
["store_field", 166, 167, "c", 139, 8],
|
||||
["access", 168, "clang++ -target arm64-apple-tvos12.0", 140, 10],
|
||||
["store_field", 166, 168, "cpp", 140, 10],
|
||||
["access", 169, "ar", 141, 9],
|
||||
["store_field", 166, 169, "ar", 141, 9],
|
||||
["access", 170, "strip", 142, 12],
|
||||
["store_field", 166, 170, "strip", 142, 12],
|
||||
["access", 171, "tvos", 143, 13],
|
||||
["store_field", 166, 171, "system", 143, 13],
|
||||
["access", 172, "aarch64", 144, 17],
|
||||
["store_field", 166, 172, "cpu_family", 144, 17],
|
||||
["access", 173, "aarch64", 145, 10],
|
||||
["store_field", 166, 173, "cpu", 145, 10],
|
||||
["access", 174, "little", 146, 13],
|
||||
["store_field", 166, 174, "endian", 146, 13],
|
||||
["access", 175, "-isysroot", 147, 14],
|
||||
["access", 176, "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk", 147, 27],
|
||||
["access", 177, "-fembed-bitcode", 147, 131],
|
||||
["array", 178, 3, 147, 131],
|
||||
["push", 178, 175, 147, 131],
|
||||
["push", 178, 176, 147, 131],
|
||||
["push", 178, 177, 147, 131],
|
||||
["store_field", 166, 178, "c_args", 147, 131],
|
||||
["access", 179, "-isysroot", 148, 19],
|
||||
["access", 180, "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk", 148, 32],
|
||||
["access", 181, "-fembed-bitcode", 148, 136],
|
||||
["array", 182, 3, 148, 136],
|
||||
["push", 182, 179, 148, 136],
|
||||
["push", 182, 180, 148, 136],
|
||||
["push", 182, 181, 148, 136],
|
||||
["store_field", 166, 182, "c_link_args", 148, 136],
|
||||
["store_field", 1, 166, "tvos_arm64", 148, 136],
|
||||
["record", 183, 10],
|
||||
["access", 184, "clang -target arm64-apple-tvos12.0-simulator", 151, 8],
|
||||
["store_field", 183, 184, "c", 151, 8],
|
||||
["access", 185, "clang++ -target arm64-apple-tvos12.0-simulator", 152, 10],
|
||||
["store_field", 183, 185, "cpp", 152, 10],
|
||||
["access", 186, "ar", 153, 9],
|
||||
["store_field", 183, 186, "ar", 153, 9],
|
||||
["access", 187, "strip", 154, 12],
|
||||
["store_field", 183, 187, "strip", 154, 12],
|
||||
["access", 188, "tvos", 155, 13],
|
||||
["store_field", 183, 188, "system", 155, 13],
|
||||
["access", 189, "aarch64", 156, 17],
|
||||
["store_field", 183, 189, "cpu_family", 156, 17],
|
||||
["access", 190, "aarch64", 157, 10],
|
||||
["store_field", 183, 190, "cpu", 157, 10],
|
||||
["access", 191, "little", 158, 13],
|
||||
["store_field", 183, 191, "endian", 158, 13],
|
||||
["access", 192, "-isysroot", 159, 14],
|
||||
["access", 193, "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk", 159, 27],
|
||||
["array", 194, 2, 159, 27],
|
||||
["push", 194, 192, 159, 27],
|
||||
["push", 194, 193, 159, 27],
|
||||
["store_field", 183, 194, "c_args", 159, 27],
|
||||
["access", 195, "-isysroot", 160, 19],
|
||||
["access", 196, "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk", 160, 32],
|
||||
["array", 197, 2, 160, 32],
|
||||
["push", 197, 195, 160, 32],
|
||||
["push", 197, 196, 160, 32],
|
||||
["store_field", 183, 197, "c_link_args", 160, 32],
|
||||
["store_field", 1, 183, "tvos_simulator_arm64", 160, 32],
|
||||
["record", 198, 10],
|
||||
["access", 199, "clang -target x86_64-apple-tvos12.0-simulator", 163, 8],
|
||||
["store_field", 198, 199, "c", 163, 8],
|
||||
["access", 200, "clang++ -target x86_64-apple-tvos12.0-simulator", 164, 10],
|
||||
["store_field", 198, 200, "cpp", 164, 10],
|
||||
["access", 201, "ar", 165, 9],
|
||||
["store_field", 198, 201, "ar", 165, 9],
|
||||
["access", 202, "strip", 166, 12],
|
||||
["store_field", 198, 202, "strip", 166, 12],
|
||||
["access", 203, "tvos", 167, 13],
|
||||
["store_field", 198, 203, "system", 167, 13],
|
||||
["access", 204, "x86_64", 168, 17],
|
||||
["store_field", 198, 204, "cpu_family", 168, 17],
|
||||
["access", 205, "x86_64", 169, 10],
|
||||
["store_field", 198, 205, "cpu", 169, 10],
|
||||
["access", 206, "little", 170, 13],
|
||||
["store_field", 198, 206, "endian", 170, 13],
|
||||
["access", 207, "-isysroot", 171, 14],
|
||||
["access", 208, "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk", 171, 27],
|
||||
["array", 209, 2, 171, 27],
|
||||
["push", 209, 207, 171, 27],
|
||||
["push", 209, 208, 171, 27],
|
||||
["store_field", 198, 209, "c_args", 171, 27],
|
||||
["access", 210, "-isysroot", 172, 19],
|
||||
["access", 211, "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk", 172, 32],
|
||||
["array", 212, 2, 172, 32],
|
||||
["push", 212, 210, 172, 32],
|
||||
["push", 212, 211, 172, 32],
|
||||
["store_field", 198, 212, "c_link_args", 172, 32],
|
||||
["store_field", 1, 198, "tvos_simulator_x86_64", 172, 32],
|
||||
["record", 213, 10],
|
||||
["access", 214, "clang -target arm64_32-apple-watchos5.0", 175, 8],
|
||||
["store_field", 213, 214, "c", 175, 8],
|
||||
["access", 215, "clang++ -target arm64_32-apple-watchos5.0", 176, 10],
|
||||
["store_field", 213, 215, "cpp", 176, 10],
|
||||
["access", 216, "ar", 177, 9],
|
||||
["store_field", 213, 216, "ar", 177, 9],
|
||||
["access", 217, "strip", 178, 12],
|
||||
["store_field", 213, 217, "strip", 178, 12],
|
||||
["access", 218, "watchos", 179, 13],
|
||||
["store_field", 213, 218, "system", 179, 13],
|
||||
["access", 219, "aarch64", 180, 17],
|
||||
["store_field", 213, 219, "cpu_family", 180, 17],
|
||||
["access", 220, "arm64_32", 181, 10],
|
||||
["store_field", 213, 220, "cpu", 181, 10],
|
||||
["access", 221, "little", 182, 13],
|
||||
["store_field", 213, 221, "endian", 182, 13],
|
||||
["access", 222, "-isysroot", 183, 14],
|
||||
["access", 223, "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk", 183, 27],
|
||||
["access", 224, "-fembed-bitcode", 183, 127],
|
||||
["array", 225, 3, 183, 127],
|
||||
["push", 225, 222, 183, 127],
|
||||
["push", 225, 223, 183, 127],
|
||||
["push", 225, 224, 183, 127],
|
||||
["store_field", 213, 225, "c_args", 183, 127],
|
||||
["access", 226, "-isysroot", 184, 19],
|
||||
["access", 227, "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk", 184, 32],
|
||||
["access", 228, "-fembed-bitcode", 184, 132],
|
||||
["array", 229, 3, 184, 132],
|
||||
["push", 229, 226, 184, 132],
|
||||
["push", 229, 227, 184, 132],
|
||||
["push", 229, 228, 184, 132],
|
||||
["store_field", 213, 229, "c_link_args", 184, 132],
|
||||
["store_field", 1, 213, "watchos_arm64", 184, 132],
|
||||
["record", 230, 10],
|
||||
["access", 231, "clang -target arm64-apple-watchos5.0-simulator", 187, 8],
|
||||
["store_field", 230, 231, "c", 187, 8],
|
||||
["access", 232, "clang++ -target arm64-apple-watchos5.0-simulator", 188, 10],
|
||||
["store_field", 230, 232, "cpp", 188, 10],
|
||||
["access", 233, "ar", 189, 9],
|
||||
["store_field", 230, 233, "ar", 189, 9],
|
||||
["access", 234, "strip", 190, 12],
|
||||
["store_field", 230, 234, "strip", 190, 12],
|
||||
["access", 235, "watchos", 191, 13],
|
||||
["store_field", 230, 235, "system", 191, 13],
|
||||
["access", 236, "aarch64", 192, 17],
|
||||
["store_field", 230, 236, "cpu_family", 192, 17],
|
||||
["access", 237, "aarch64", 193, 10],
|
||||
["store_field", 230, 237, "cpu", 193, 10],
|
||||
["access", 238, "little", 194, 13],
|
||||
["store_field", 230, 238, "endian", 194, 13],
|
||||
["access", 239, "-isysroot", 195, 14],
|
||||
["access", 240, "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk", 195, 27],
|
||||
["array", 241, 2, 195, 27],
|
||||
["push", 241, 239, 195, 27],
|
||||
["push", 241, 240, 195, 27],
|
||||
["store_field", 230, 241, "c_args", 195, 27],
|
||||
["access", 242, "-isysroot", 196, 19],
|
||||
["access", 243, "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk", 196, 32],
|
||||
["array", 244, 2, 196, 32],
|
||||
["push", 244, 242, 196, 32],
|
||||
["push", 244, 243, 196, 32],
|
||||
["store_field", 230, 244, "c_link_args", 196, 32],
|
||||
["store_field", 1, 230, "watchos_simulator_arm64", 196, 32],
|
||||
["record", 245, 10],
|
||||
["access", 246, "clang -target x86_64-apple-watchos5.0-simulator", 199, 8],
|
||||
["store_field", 245, 246, "c", 199, 8],
|
||||
["access", 247, "clang++ -target x86_64-apple-watchos5.0-simulator", 200, 10],
|
||||
["store_field", 245, 247, "cpp", 200, 10],
|
||||
["access", 248, "ar", 201, 9],
|
||||
["store_field", 245, 248, "ar", 201, 9],
|
||||
["access", 249, "strip", 202, 12],
|
||||
["store_field", 245, 249, "strip", 202, 12],
|
||||
["access", 250, "watchos", 203, 13],
|
||||
["store_field", 245, 250, "system", 203, 13],
|
||||
["access", 251, "x86_64", 204, 17],
|
||||
["store_field", 245, 251, "cpu_family", 204, 17],
|
||||
["access", 252, "x86_64", 205, 10],
|
||||
["store_field", 245, 252, "cpu", 205, 10],
|
||||
["access", 253, "little", 206, 13],
|
||||
["store_field", 245, 253, "endian", 206, 13],
|
||||
["access", 254, "-isysroot", 207, 14],
|
||||
["access", 255, "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk", 207, 27],
|
||||
["array", 256, 2, 207, 27],
|
||||
["push", 256, 254, 207, 27],
|
||||
["push", 256, 255, 207, 27],
|
||||
["store_field", 245, 256, "c_args", 207, 27],
|
||||
["access", 257, "-isysroot", 208, 19],
|
||||
["access", 258, "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk", 208, 32],
|
||||
["array", 259, 2, 208, 32],
|
||||
["push", 259, 257, 208, 32],
|
||||
["push", 259, 258, 208, 32],
|
||||
["store_field", 245, 259, "c_link_args", 208, 32],
|
||||
["store_field", 1, 245, "watchos_simulator_x86_64", 208, 32],
|
||||
["record", 260, 10],
|
||||
["access", 261, "clang -target arm64-apple-xros1.0", 211, 8],
|
||||
["store_field", 260, 261, "c", 211, 8],
|
||||
["access", 262, "clang++ -target arm64-apple-xros1.0", 212, 10],
|
||||
["store_field", 260, 262, "cpp", 212, 10],
|
||||
["access", 263, "ar", 213, 9],
|
||||
["store_field", 260, 263, "ar", 213, 9],
|
||||
["access", 264, "strip", 214, 12],
|
||||
["store_field", 260, 264, "strip", 214, 12],
|
||||
["access", 265, "visionos", 215, 13],
|
||||
["store_field", 260, 265, "system", 215, 13],
|
||||
["access", 266, "aarch64", 216, 17],
|
||||
["store_field", 260, 266, "cpu_family", 216, 17],
|
||||
["access", 267, "aarch64", 217, 10],
|
||||
["store_field", 260, 267, "cpu", 217, 10],
|
||||
["access", 268, "little", 218, 13],
|
||||
["store_field", 260, 268, "endian", 218, 13],
|
||||
["access", 269, "-isysroot", 219, 14],
|
||||
["access", 270, "/Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS.sdk", 219, 27],
|
||||
["array", 271, 2, 219, 27],
|
||||
["push", 271, 269, 219, 27],
|
||||
["push", 271, 270, 219, 27],
|
||||
["store_field", 260, 271, "c_args", 219, 27],
|
||||
["access", 272, "-isysroot", 220, 19],
|
||||
["access", 273, "/Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS.sdk", 220, 32],
|
||||
["array", 274, 2, 220, 32],
|
||||
["push", 274, 272, 220, 32],
|
||||
["push", 274, 273, 220, 32],
|
||||
["store_field", 260, 274, "c_link_args", 220, 32],
|
||||
["store_field", 1, 260, "visionos_arm64", 220, 32],
|
||||
["record", 275, 10],
|
||||
["access", 276, "clang -target arm64-apple-xros1.0-simulator", 223, 8],
|
||||
["store_field", 275, 276, "c", 223, 8],
|
||||
["access", 277, "clang++ -target arm64-apple-xros1.0-simulator", 224, 10],
|
||||
["store_field", 275, 277, "cpp", 224, 10],
|
||||
["access", 278, "ar", 225, 9],
|
||||
["store_field", 275, 278, "ar", 225, 9],
|
||||
["access", 279, "strip", 226, 12],
|
||||
["store_field", 275, 279, "strip", 226, 12],
|
||||
["access", 280, "visionos", 227, 13],
|
||||
["store_field", 275, 280, "system", 227, 13],
|
||||
["access", 281, "aarch64", 228, 17],
|
||||
["store_field", 275, 281, "cpu_family", 228, 17],
|
||||
["access", 282, "aarch64", 229, 10],
|
||||
["store_field", 275, 282, "cpu", 229, 10],
|
||||
["access", 283, "little", 230, 13],
|
||||
["store_field", 275, 283, "endian", 230, 13],
|
||||
["access", 284, "-isysroot", 231, 14],
|
||||
["access", 285, "/Applications/Xcode.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator.sdk", 231, 27],
|
||||
["array", 286, 2, 231, 27],
|
||||
["push", 286, 284, 231, 27],
|
||||
["push", 286, 285, 231, 27],
|
||||
["store_field", 275, 286, "c_args", 231, 27],
|
||||
["access", 287, "-isysroot", 232, 19],
|
||||
["access", 288, "/Applications/Xcode.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator.sdk", 232, 32],
|
||||
["array", 289, 2, 232, 32],
|
||||
["push", 289, 287, 232, 32],
|
||||
["push", 289, 288, 232, 32],
|
||||
["store_field", 275, 289, "c_link_args", 232, 32],
|
||||
["store_field", 1, 275, "visionos_simulator_arm64", 232, 32],
|
||||
["record", 290, 10],
|
||||
["access", 291, "emcc", 235, 8],
|
||||
["store_field", 290, 291, "c", 235, 8],
|
||||
["access", 292, "em++", 236, 10],
|
||||
["store_field", 290, 292, "cpp", 236, 10],
|
||||
["access", 293, "emar", 237, 9],
|
||||
["store_field", 290, 293, "ar", 237, 9],
|
||||
["access", 294, "emstrip", 238, 12],
|
||||
["store_field", 290, 294, "strip", 238, 12],
|
||||
["access", 295, "emscripten", 239, 13],
|
||||
["store_field", 290, 295, "system", 239, 13],
|
||||
["access", 296, "wasm32", 240, 17],
|
||||
["store_field", 290, 296, "cpu_family", 240, 17],
|
||||
["access", 297, "wasm32", 241, 10],
|
||||
["store_field", 290, 297, "cpu", 241, 10],
|
||||
["access", 298, "little", 242, 13],
|
||||
["store_field", 290, 298, "endian", 242, 13],
|
||||
["array", 299, 0, 243, 13],
|
||||
["store_field", 290, 299, "c_args", 243, 13],
|
||||
["array", 300, 0, 244, 18],
|
||||
["store_field", 290, 300, "c_link_args", 244, 18],
|
||||
["store_field", 1, 290, "emscripten", 244, 18],
|
||||
["record", 301, 0],
|
||||
["store_field", 1, 301, "raspberrypi", 246, 16],
|
||||
["record", 302, 0],
|
||||
["store_field", 1, 302, "android", 249, 12],
|
||||
["return", 1, 249, 12],
|
||||
"_nop_ur_1",
|
||||
"_nop_ur_2"
|
||||
],
|
||||
"nr_args": 0
|
||||
},
|
||||
"filename": "toolchains.cm",
|
||||
"data": {}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
33
docs/shop.md
33
docs/shop.md
@@ -9,18 +9,36 @@ The shop is the module resolution and loading engine behind `use()`. It handles
|
||||
|
||||
## Startup Pipeline
|
||||
|
||||
When `pit` runs a program, three layers bootstrap in sequence:
|
||||
When `pit` runs a program, startup takes one of two paths:
|
||||
|
||||
### Fast path (warm cache)
|
||||
|
||||
```
|
||||
bootstrap.cm → engine.cm → shop.cm → user program
|
||||
C runtime → engine.cm (from cache) → shop.cm → user program
|
||||
```
|
||||
|
||||
**bootstrap.cm** loads the compiler toolchain (tokenize, parse, fold, mcode, streamline) from pre-compiled bytecode. It defines `analyze()` (source to AST) and `compile_to_blob()` (AST to binary blob). It then loads engine.cm.
|
||||
The C runtime hashes the source of `internal/engine.cm` with BLAKE2 and looks up the hash in the content-addressed cache (`~/.pit/build/<hash>`). On a cache hit, engine.cm loads directly — no bootstrap involved.
|
||||
|
||||
**engine.cm** creates the actor runtime (`$_`), defines `use_core()` for loading core modules, and populates the environment that shop receives. It then loads shop.cm via `use_core('internal/shop')`.
|
||||
### Cold path (first run or cache cleared)
|
||||
|
||||
```
|
||||
C runtime → bootstrap.cm → (seeds cache) → engine.cm (from cache) → shop.cm → user program
|
||||
```
|
||||
|
||||
On a cache miss, the C runtime loads `boot/bootstrap.cm.mcode` (a pre-compiled seed). Bootstrap compiles engine.cm and the pipeline modules (tokenize, parse, fold, mcode, streamline) from source and caches the results. The C runtime then retries the engine cache lookup, which now succeeds.
|
||||
|
||||
### Engine
|
||||
|
||||
**engine.cm** is self-sufficient. It loads its own compilation pipeline from the content-addressed cache, with fallback to the pre-compiled seeds in `boot/`. It defines `analyze()` (source to AST), `compile_to_blob()` (AST to binary blob), and `use_core()` for loading core modules. It creates the actor runtime and loads shop.cm via `use_core('internal/shop')`.
|
||||
|
||||
### Shop
|
||||
|
||||
**shop.cm** receives its dependencies through the module environment — `analyze`, `run_ast_fn`, `use_cache`, `shop_path`, `runtime_env`, `content_hash`, `cache_path`, and others. It defines `Shop.use()`, which is the function behind every `use()` call in user code.
|
||||
|
||||
### Cache invalidation
|
||||
|
||||
All caching is content-addressed by BLAKE2 hash of the source. When any source file changes, its hash changes and the old cache entry is simply never looked up again. No manual invalidation is needed. To force a full rebuild, delete `~/.pit/build/`.
|
||||
|
||||
## Module Resolution
|
||||
|
||||
When `use('path')` is called from a package context, the shop resolves the module through a multi-layer search. Both the `.cm` script file and C symbol are resolved independently, and the one with the narrowest scope wins.
|
||||
@@ -90,7 +108,7 @@ This scheme provides automatic cache invalidation: when source changes, its hash
|
||||
|
||||
### Core Module Caching
|
||||
|
||||
Core modules loaded via `use_core()` in engine.cm follow the same pattern. On first startup after a fresh install, core modules are compiled from `.cm.mcode` JSON IR and cached as `.mach` blobs. Subsequent startups load from cache, skipping the JSON parse and compile steps entirely.
|
||||
Core modules loaded via `use_core()` in engine.cm follow the same content-addressed pattern. On first use, a module is compiled from source and cached by the BLAKE2 hash of its source content. Subsequent loads with unchanged source hit the cache directly.
|
||||
|
||||
User scripts (`.ce` files) are also cached. The first run compiles and caches; subsequent runs with unchanged source load from cache.
|
||||
|
||||
@@ -196,9 +214,10 @@ If `shop.toml` is missing or has no `[policy]` section, all methods are enabled
|
||||
|
||||
| File | Role |
|
||||
|------|------|
|
||||
| `internal/bootstrap.cm` | Loads compiler, defines `analyze()` and `compile_to_blob()` |
|
||||
| `internal/engine.cm` | Actor runtime, `use_core()`, environment setup |
|
||||
| `internal/bootstrap.cm` | Minimal cache seeder (cold start only) |
|
||||
| `internal/engine.cm` | Self-sufficient entry point: compilation pipeline, actor runtime, `use_core()` |
|
||||
| `internal/shop.cm` | Module resolution, compilation, caching, C extension loading |
|
||||
| `internal/os.c` | OS intrinsics: dylib ops, internal symbol lookup, embedded modules |
|
||||
| `package.cm` | Package directory detection, alias resolution, file listing |
|
||||
| `link.cm` | Development link management (link.toml read/write) |
|
||||
| `boot/*.cm.mcode` | Pre-compiled pipeline seeds (tokenize, parse, fold, mcode, bootstrap) |
|
||||
|
||||
@@ -104,7 +104,8 @@ pit --emit-qbe script.ce > output.ssa
|
||||
| `streamline.cm` | Mcode IR optimizer |
|
||||
| `qbe_emit.cm` | Mcode IR → QBE IL emitter |
|
||||
| `qbe.cm` | QBE IL operation templates |
|
||||
| `internal/bootstrap.cm` | Pipeline orchestrator |
|
||||
| `internal/bootstrap.cm` | Cache seeder (cold start only) |
|
||||
| `internal/engine.cm` | Self-sufficient pipeline loader and orchestrator |
|
||||
|
||||
## Debug Tools
|
||||
|
||||
|
||||
112
fix_pipeline.md
112
fix_pipeline.md
@@ -1,112 +0,0 @@
|
||||
# Fix Compilation Pipeline Bootstrap
|
||||
|
||||
## Problem
|
||||
|
||||
After merging `fix_gc` into `pitweb`, the compilation pipeline `.cm` source files
|
||||
(tokenize.cm, parse.cm, fold.cm, mcode.cm, streamline.cm) cannot bootstrap themselves.
|
||||
|
||||
The old pitweb pipeline mcode compiles the merged `.cm` source without errors, but the
|
||||
resulting new pipeline mcode is **semantically broken** — it can't even compile
|
||||
`var x = 42; print(x)`.
|
||||
|
||||
Both branches worked independently. The merge introduced no syntax errors, but the old
|
||||
pitweb compiler produces incorrect bytecode from the merged pipeline source. This is a
|
||||
classic bootstrapping problem: the new pipeline needs a compatible compiler to build
|
||||
itself, but the only available compiler (old pitweb) miscompiles it.
|
||||
|
||||
## Current State
|
||||
|
||||
- `boot/tokenize.cm.mcode` through `boot/streamline.cm.mcode` contain the **old pitweb**
|
||||
pipeline mcode (pre-merge). These pass 641/641 vm_suite tests.
|
||||
- All other boot mcode files (engine, bootstrap, seed_bootstrap, plus core modules like
|
||||
fd, time, toml, etc.) are compiled from the merged source and work correctly.
|
||||
- The merged pipeline `.cm` source has changes from fix_gc that are **not active** — the
|
||||
runtime uses the old pitweb pipeline mcode.
|
||||
|
||||
**The old pitweb pipeline is NOT fully working.** While it passes the test suite, it
|
||||
miscompiles nested function declarations. This breaks:
|
||||
|
||||
- `toml.encode()` — the encoder uses nested `function` declarations inside `encode_toml`
|
||||
- `Shop.save_lock()` — calls `toml.encode()`, so any lock.toml mutation fails
|
||||
- Any other `.cm` module that uses nested named function declarations
|
||||
|
||||
This means the **ID-based package symbol naming** (Phase 2 in the plan) is blocked: it
|
||||
needs `save_lock()` to persist package IDs to lock.toml.
|
||||
|
||||
The shop.cm changes for ID-based naming are already written and correct — they just need
|
||||
a working pipeline underneath. Once the pipeline is fixed, the ID system will work.
|
||||
|
||||
## What Changed in the Pipeline
|
||||
|
||||
The fix_gc merge brought these changes to the pipeline `.cm` files:
|
||||
|
||||
- **mcode.cm**: Type-guarded arithmetic (`emit_add_decomposed` now generates `is_text`/`is_num`
|
||||
checks instead of letting the VM dispatch), `emit_numeric_binop` for subtract/multiply/etc.,
|
||||
`sensory_ops` lookup table, array/record literal count args (`["array", dest, count]`
|
||||
instead of `["array", dest, 0]`)
|
||||
- **fold.cm**: Lookup tables (`binary_ops`, `unary_ops`, `assign_ops`, etc.) replacing
|
||||
if-chains, combined `"array"` and `"text literal"` handling
|
||||
- **tokenize.cm**: ~500 lines of changes
|
||||
- **streamline.cm**: ~700 lines of changes
|
||||
- **parse.cm**: ~40 lines of changes (minor)
|
||||
|
||||
## Regen Flags
|
||||
|
||||
`regen.ce` now has two modes:
|
||||
|
||||
```
|
||||
./cell --dev --seed regen # default: skip pipeline files
|
||||
./cell --dev --seed regen --all # include pipeline files (tokenize/parse/fold/mcode/streamline)
|
||||
```
|
||||
|
||||
The default mode is safe — it regenerates everything except the 5 pipeline files,
|
||||
preserving the working old pitweb pipeline mcode.
|
||||
|
||||
## How to Fix
|
||||
|
||||
The goal is to get the merged pipeline `.cm` source to produce working mcode when
|
||||
compiled by the current (old pitweb) pipeline. The process:
|
||||
|
||||
1. Start from the current repo state (old pitweb pipeline mcode in boot/)
|
||||
2. Edit one or more pipeline `.cm` files to fix the issue
|
||||
3. Regen with `--all` to recompile everything including pipeline:
|
||||
```
|
||||
./cell --dev --seed regen --all
|
||||
```
|
||||
4. Test the new pipeline with a simple sanity check:
|
||||
```
|
||||
rm -rf .cell/build/*
|
||||
echo 'var x = 42; print(x)' > /tmp/test.ce
|
||||
./cell --dev --seed /tmp/test
|
||||
```
|
||||
5. If that works, run the full test suite:
|
||||
```
|
||||
rm -rf .cell/build/*
|
||||
./cell --dev vm_suite
|
||||
```
|
||||
6. If tests pass, regen again (the new pipeline compiles itself):
|
||||
```
|
||||
./cell --dev --seed regen --all
|
||||
```
|
||||
7. Repeat steps 4-6 until **idempotent** — two consecutive `regen --all` runs produce
|
||||
identical boot mcode and all tests pass.
|
||||
|
||||
## Debugging Tips
|
||||
|
||||
- The old pitweb pipeline mcode is always available via:
|
||||
```
|
||||
git checkout HEAD^1 -- boot/tokenize.cm.mcode boot/parse.cm.mcode \
|
||||
boot/fold.cm.mcode boot/mcode.cm.mcode boot/streamline.cm.mcode
|
||||
```
|
||||
- Use `--seed` mode for testing compilation — it bypasses the engine entirely and
|
||||
loads the pipeline directly from boot mcode.
|
||||
- The failure mode is silent: the old compiler compiles the new source without errors
|
||||
but produces wrong bytecode.
|
||||
- Known broken patterns with the old pitweb pipeline:
|
||||
- `var x = 42; print(x)` fails when compiled by the regenned pipeline mcode
|
||||
- Nested named function declarations (`function foo() {}` inside another function)
|
||||
produce "not a function" errors — this breaks `toml.encode()`
|
||||
- Test with: `echo 'var toml = use("toml"); print(toml.encode({a: 1}))' > /tmp/t.ce && ./cell --dev /tmp/t.ce`
|
||||
- The most likely culprits are the mcode.cm changes (type-guarded arithmetic, array/record
|
||||
count args) since these change the bytecode format. The fold.cm changes (lookup tables)
|
||||
are more likely safe refactors.
|
||||
@@ -1,22 +1,15 @@
|
||||
// Hidden vars come from env:
|
||||
// CLI mode (cell_init): os, args, core_path, shop_path
|
||||
// Actor spawn (script_startup): os, json, actorsym, init, core_path, shop_path
|
||||
// args[0] = script name, args[1..] = user args
|
||||
// Minimal bootstrap — seeds the content-addressed cache
|
||||
// Only runs on cold start (C runtime couldn't find engine in cache)
|
||||
// Hidden vars: os, core_path, shop_path
|
||||
var load_internal = os.load_internal
|
||||
function use_embed(name) {
|
||||
return load_internal("js_core_" + name + "_use")
|
||||
}
|
||||
|
||||
var fd = use_embed('internal_fd')
|
||||
var json = use_embed('json')
|
||||
var json_mod = use_embed('json')
|
||||
var crypto = use_embed('crypto')
|
||||
|
||||
var use_cache = {}
|
||||
use_cache['fd'] = fd
|
||||
use_cache['os'] = os
|
||||
use_cache['json'] = json
|
||||
use_cache['crypto'] = crypto
|
||||
|
||||
function content_hash(content) {
|
||||
return text(crypto.blake2(content), 'h')
|
||||
}
|
||||
@@ -29,250 +22,84 @@ function cache_path(hash) {
|
||||
function ensure_build_dir() {
|
||||
if (!shop_path) return null
|
||||
var dir = shop_path + '/build'
|
||||
if (!fd.is_dir(dir)) {
|
||||
fd.mkdir(dir)
|
||||
}
|
||||
if (!fd.is_dir(dir)) fd.mkdir(dir)
|
||||
return dir
|
||||
}
|
||||
|
||||
// Bootstrap: load tokenize.cm, parse.cm, fold.cm from pre-compiled mach bytecode
|
||||
function use_basic(path) {
|
||||
if (use_cache[path])
|
||||
return use_cache[path]
|
||||
var result = use_embed(replace(path, '/', '_'))
|
||||
use_cache[path] = result
|
||||
return result
|
||||
}
|
||||
|
||||
// Load a module from cached .mach or .mcode bytecode
|
||||
function boot_load(name, env) {
|
||||
var mcode_path = core_path + '/boot/' + name + ".cm.mcode"
|
||||
// Load seed pipeline from boot/ (tokenize, parse, mcode only)
|
||||
function boot_load(name) {
|
||||
var mcode_path = core_path + '/boot/' + name + '.cm.mcode'
|
||||
var mcode_blob = null
|
||||
var hash = null
|
||||
var cached = null
|
||||
var mcode_json = null
|
||||
var mach_blob = null
|
||||
if (fd.is_file(mcode_path)) {
|
||||
mcode_blob = fd.slurp(mcode_path)
|
||||
hash = content_hash(mcode_blob)
|
||||
cached = cache_path(hash)
|
||||
if (cached && fd.is_file(cached)) {
|
||||
return mach_load(fd.slurp(cached), env)
|
||||
}
|
||||
mcode_json = text(mcode_blob)
|
||||
mach_blob = mach_compile_mcode_bin(name, mcode_json)
|
||||
if (cached) {
|
||||
ensure_build_dir()
|
||||
fd.slurpwrite(cached, mach_blob)
|
||||
}
|
||||
return mach_load(mach_blob, env)
|
||||
if (!fd.is_file(mcode_path)) {
|
||||
print("error: missing seed: " + name + "\n")
|
||||
disrupt
|
||||
}
|
||||
print("error: missing bootstrap bytecode: " + name + "\n")
|
||||
disrupt
|
||||
mcode_blob = fd.slurp(mcode_path)
|
||||
mach_blob = mach_compile_mcode_bin(name, text(mcode_blob))
|
||||
return mach_load(mach_blob, {use: use_embed})
|
||||
}
|
||||
|
||||
var boot_env = {use: use_basic}
|
||||
var tokenize_mod = boot_load("tokenize", boot_env)
|
||||
var parse_mod = boot_load("parse", boot_env)
|
||||
var fold_mod = boot_load("fold", boot_env)
|
||||
use_cache['tokenize'] = tokenize_mod
|
||||
use_cache['parse'] = parse_mod
|
||||
use_cache['fold'] = fold_mod
|
||||
var tokenize_mod = boot_load("tokenize")
|
||||
var parse_mod = boot_load("parse")
|
||||
var fold_mod = boot_load("fold")
|
||||
var mcode_mod = boot_load("mcode")
|
||||
|
||||
// Always load mcode compiler module
|
||||
var mcode_mod = boot_load("mcode", boot_env)
|
||||
use_cache['mcode'] = mcode_mod
|
||||
use_cache['core/mcode'] = mcode_mod
|
||||
var streamline_mod = null
|
||||
|
||||
// Warn if any .cm source is newer than its compiled bytecode
|
||||
function check_mach_stale() {
|
||||
var sources = [
|
||||
{src: "tokenize.cm", mcode: "boot/tokenize.cm.mcode"},
|
||||
{src: "parse.cm", mcode: "boot/parse.cm.mcode"},
|
||||
{src: "fold.cm", mcode: "boot/fold.cm.mcode"},
|
||||
{src: "mcode.cm", mcode: "boot/mcode.cm.mcode"},
|
||||
{src: "streamline.cm", mcode: "boot/streamline.cm.mcode"},
|
||||
{src: "qbe.cm", mcode: "boot/qbe.cm.mcode"},
|
||||
{src: "qbe_emit.cm", mcode: "boot/qbe_emit.cm.mcode"},
|
||||
{src: "verify_ir.cm", mcode: "boot/verify_ir.cm.mcode"},
|
||||
{src: "internal/bootstrap.cm", mcode: "boot/bootstrap.cm.mcode"},
|
||||
{src: "internal/engine.cm", mcode: "boot/engine.cm.mcode"}
|
||||
]
|
||||
var stale = []
|
||||
var _i = 0
|
||||
var cm_path = null
|
||||
var mcode_path = null
|
||||
var cm_stat = null
|
||||
var compiled_stat = null
|
||||
var entry = null
|
||||
while (_i < length(sources)) {
|
||||
entry = sources[_i]
|
||||
cm_path = core_path + '/' + entry.src
|
||||
mcode_path = core_path + '/' + entry.mcode
|
||||
if (fd.is_file(mcode_path) && fd.is_file(cm_path)) {
|
||||
compiled_stat = fd.stat(mcode_path)
|
||||
cm_stat = fd.stat(cm_path)
|
||||
if (cm_stat.mtime > compiled_stat.mtime) {
|
||||
push(stale, entry.src)
|
||||
}
|
||||
}
|
||||
_i = _i + 1
|
||||
}
|
||||
if (length(stale) > 0) {
|
||||
print("warning: bytecode is stale for: " + text(stale, ", ") + "\n")
|
||||
print("run 'make regen' to update\n")
|
||||
}
|
||||
}
|
||||
check_mach_stale()
|
||||
|
||||
// analyze: tokenize + parse, check for errors
|
||||
function analyze(src, filename) {
|
||||
var tok_result = tokenize_mod(src, filename)
|
||||
var ast = parse_mod(tok_result.tokens, src, filename, tokenize_mod)
|
||||
var _i = 0
|
||||
var prev_line = -1
|
||||
var prev_msg = null
|
||||
var e = null
|
||||
var msg = null
|
||||
var line = null
|
||||
var col = null
|
||||
var has_errors = ast.errors != null && length(ast.errors) > 0
|
||||
if (has_errors) {
|
||||
while (_i < length(ast.errors)) {
|
||||
e = ast.errors[_i]
|
||||
msg = e.message
|
||||
line = e.line
|
||||
col = e.column
|
||||
if (msg != prev_msg || line != prev_line) {
|
||||
if (line != null && col != null) {
|
||||
print(`${filename}:${text(line)}:${text(col)}: error: ${msg}`)
|
||||
} else {
|
||||
print(`${filename}: error: ${msg}`)
|
||||
}
|
||||
}
|
||||
prev_line = line
|
||||
prev_msg = msg
|
||||
if (e.line != null && e.column != null)
|
||||
print(`${filename}:${text(e.line)}:${text(e.column)}: error: ${msg}`)
|
||||
else
|
||||
print(`${filename}: error: ${msg}`)
|
||||
_i = _i + 1
|
||||
}
|
||||
disrupt
|
||||
}
|
||||
ast = fold_mod(ast)
|
||||
return ast
|
||||
return fold_mod(ast)
|
||||
}
|
||||
|
||||
// Load optimization pipeline modules (needs analyze to be defined)
|
||||
streamline_mod = boot_load("streamline", boot_env)
|
||||
use_cache['streamline'] = streamline_mod
|
||||
use_cache['core/streamline'] = streamline_mod
|
||||
|
||||
// Lazy-loaded verify_ir module (loaded on first use)
|
||||
var _verify_ir_mod = null
|
||||
|
||||
// Run AST through mcode pipeline → register VM
|
||||
function run_ast(name, ast, env) {
|
||||
var compiled = mcode_mod(ast)
|
||||
if (os._verify_ir) {
|
||||
if (_verify_ir_mod == null) {
|
||||
_verify_ir_mod = boot_load('verify_ir', boot_env)
|
||||
}
|
||||
compiled._verify = true
|
||||
compiled._verify_mod = _verify_ir_mod
|
||||
}
|
||||
var optimized = streamline_mod(compiled)
|
||||
// Clean up verify properties before JSON encoding
|
||||
if (optimized._verify) {
|
||||
delete optimized._verify
|
||||
delete optimized._verify_mod
|
||||
}
|
||||
var mcode_json = json.encode(optimized)
|
||||
var mach_blob = mach_compile_mcode_bin(name, mcode_json)
|
||||
return mach_load(mach_blob, env)
|
||||
}
|
||||
|
||||
// Run AST through mcode pipeline WITHOUT optimization → register VM
|
||||
function run_ast_noopt(name, ast, env) {
|
||||
var compiled = mcode_mod(ast)
|
||||
var mcode_json = json.encode(compiled)
|
||||
var mach_blob = mach_compile_mcode_bin(name, mcode_json)
|
||||
return mach_load(mach_blob, env)
|
||||
}
|
||||
|
||||
// Compile AST to blob without loading (for caching)
|
||||
function compile_to_blob(name, ast) {
|
||||
var compiled = mcode_mod(ast)
|
||||
var optimized = streamline_mod(compiled)
|
||||
return mach_compile_mcode_bin(name, json.encode(optimized))
|
||||
}
|
||||
|
||||
// Helper to load engine.cm and run it with given env
|
||||
function load_engine(env) {
|
||||
var mcode_path = core_path + '/boot/engine.cm.mcode'
|
||||
var mcode_blob = null
|
||||
var hash = null
|
||||
var cached = null
|
||||
function compile_and_cache(name, source_path) {
|
||||
var source_blob = fd.slurp(source_path)
|
||||
var hash = content_hash(source_blob)
|
||||
var cached = cache_path(hash)
|
||||
var ast = null
|
||||
var compiled = null
|
||||
var mcode_json = null
|
||||
var mach_blob = null
|
||||
var engine_src = null
|
||||
var engine_ast = null
|
||||
if (fd.is_file(mcode_path)) {
|
||||
mcode_blob = fd.slurp(mcode_path)
|
||||
hash = content_hash(mcode_blob)
|
||||
cached = cache_path(hash)
|
||||
if (cached && fd.is_file(cached)) {
|
||||
return mach_load(fd.slurp(cached), env)
|
||||
}
|
||||
mcode_json = text(mcode_blob)
|
||||
mach_blob = mach_compile_mcode_bin('engine', mcode_json)
|
||||
if (cached) {
|
||||
ensure_build_dir()
|
||||
fd.slurpwrite(cached, mach_blob)
|
||||
}
|
||||
return mach_load(mach_blob, env)
|
||||
if (cached && fd.is_file(cached)) return
|
||||
ast = analyze(text(source_blob), source_path)
|
||||
compiled = mcode_mod(ast)
|
||||
mcode_json = json_mod.encode(compiled)
|
||||
mach_blob = mach_compile_mcode_bin(name, mcode_json)
|
||||
if (cached) {
|
||||
ensure_build_dir()
|
||||
fd.slurpwrite(cached, mach_blob)
|
||||
}
|
||||
// Fallback: compile from source
|
||||
var engine_cm = core_path + '/internal/engine.cm'
|
||||
engine_src = text(fd.slurp(engine_cm))
|
||||
engine_ast = analyze(engine_src, engine_cm)
|
||||
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
|
||||
|
||||
if (args != null) {
|
||||
// CLI mode — always run as actor program (.ce)
|
||||
program = args[0]
|
||||
if (!program) {
|
||||
print("error: no program specified\n")
|
||||
disrupt
|
||||
}
|
||||
_j = 1
|
||||
while (_j < length(args)) {
|
||||
push(user_args, args[_j])
|
||||
_j = _j + 1
|
||||
}
|
||||
|
||||
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, run_ast_noopt_fn: run_ast_noopt,
|
||||
use_cache: use_cache,
|
||||
content_hash: content_hash, cache_path: cache_path,
|
||||
ensure_build_dir: ensure_build_dir, compile_to_blob_fn: compile_to_blob
|
||||
})
|
||||
} else {
|
||||
// Actor spawn mode — load engine.cm with full actor env
|
||||
load_engine({
|
||||
os: os, actorsym: actorsym, init: init,
|
||||
core_path: core_path, shop_path: shop_path, json: json,
|
||||
analyze: analyze, run_ast_fn: run_ast, run_ast_noopt_fn: run_ast_noopt,
|
||||
use_cache: use_cache,
|
||||
content_hash: content_hash, cache_path: cache_path,
|
||||
ensure_build_dir: ensure_build_dir, compile_to_blob_fn: compile_to_blob
|
||||
})
|
||||
// Seed the cache with everything engine needs
|
||||
var seed_files = [
|
||||
{name: "tokenize", path: "tokenize.cm"},
|
||||
{name: "parse", path: "parse.cm"},
|
||||
{name: "fold", path: "fold.cm"},
|
||||
{name: "mcode", path: "mcode.cm"},
|
||||
{name: "streamline", path: "streamline.cm"},
|
||||
{name: "engine", path: "internal/engine.cm"}
|
||||
]
|
||||
var _i = 0
|
||||
var entry = null
|
||||
while (_i < length(seed_files)) {
|
||||
entry = seed_files[_i]
|
||||
compile_and_cache(entry.name, core_path + '/' + entry.path)
|
||||
_i = _i + 1
|
||||
}
|
||||
print("bootstrap: cache seeded\n")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Hidden vars (os, actorsym, init, core_path, shop_path, analyze, run_ast_fn, run_ast_noopt_fn, json, use_cache, content_hash, cache_path, ensure_build_dir, compile_to_blob_fn) come from env
|
||||
// Hidden vars (os, actorsym, init, core_path, shop_path, json, args) come from env
|
||||
// Engine is self-sufficient: defines its own compilation pipeline
|
||||
var ACTORDATA = actorsym
|
||||
var SYSYM = '__SYSTEM__'
|
||||
|
||||
@@ -14,7 +15,7 @@ var cases = {
|
||||
var dylib_ext = cases[os.platform()]
|
||||
|
||||
var MOD_EXT = '.cm'
|
||||
var ACTOR_EXT = '.ce'
|
||||
var ACTOR_EXT = '.ce'
|
||||
|
||||
var load_internal = os.load_internal
|
||||
function use_embed(name) {
|
||||
@@ -47,11 +48,159 @@ function ends_with(str, suffix) {
|
||||
|
||||
var fd = use_embed('internal_fd')
|
||||
var js = use_embed('js')
|
||||
var crypto = use_embed('crypto')
|
||||
|
||||
// core_path and shop_path come from env (bootstrap.cm passes them through)
|
||||
// core_path and shop_path come from env (C runtime passes them through)
|
||||
// shop_path may be null if --core was used without --shop
|
||||
var packages_path = shop_path ? shop_path + '/packages' : null
|
||||
|
||||
// Self-sufficient initialization: content-addressed cache
|
||||
var use_cache = {}
|
||||
|
||||
function content_hash(content) {
|
||||
return text(crypto.blake2(content), 'h')
|
||||
}
|
||||
|
||||
function cache_path(hash) {
|
||||
if (!shop_path) return null
|
||||
return shop_path + '/build/' + hash
|
||||
}
|
||||
|
||||
function ensure_build_dir() {
|
||||
if (!shop_path) return null
|
||||
var dir = shop_path + '/build'
|
||||
if (!fd.is_dir(dir)) fd.mkdir(dir)
|
||||
return dir
|
||||
}
|
||||
|
||||
// Load a pipeline module from cache, with boot/ seed fallback
|
||||
function load_pipeline_module(name, env) {
|
||||
var source_path = core_path + '/' + name + '.cm'
|
||||
var source_blob = null
|
||||
var hash = null
|
||||
var cached = null
|
||||
var mcode_path = null
|
||||
var mcode_blob = null
|
||||
var mach_blob = null
|
||||
if (fd.is_file(source_path)) {
|
||||
source_blob = fd.slurp(source_path)
|
||||
hash = content_hash(source_blob)
|
||||
cached = cache_path(hash)
|
||||
if (cached && fd.is_file(cached))
|
||||
return mach_load(fd.slurp(cached), env)
|
||||
}
|
||||
// Boot seed fallback
|
||||
mcode_path = core_path + '/boot/' + name + '.cm.mcode'
|
||||
if (fd.is_file(mcode_path)) {
|
||||
mcode_blob = fd.slurp(mcode_path)
|
||||
mach_blob = mach_compile_mcode_bin(name, text(mcode_blob))
|
||||
return mach_load(mach_blob, env)
|
||||
}
|
||||
print("error: cannot load pipeline module: " + name + "\n")
|
||||
disrupt
|
||||
}
|
||||
|
||||
// Load compilation pipeline
|
||||
var pipeline_env = {use: use_embed}
|
||||
var tokenize_mod = load_pipeline_module('tokenize', pipeline_env)
|
||||
var parse_mod = load_pipeline_module('parse', pipeline_env)
|
||||
var fold_mod = load_pipeline_module('fold', pipeline_env)
|
||||
var mcode_mod = load_pipeline_module('mcode', pipeline_env)
|
||||
var streamline_mod = load_pipeline_module('streamline', pipeline_env)
|
||||
|
||||
use_cache['tokenize'] = tokenize_mod
|
||||
use_cache['parse'] = parse_mod
|
||||
use_cache['fold'] = fold_mod
|
||||
use_cache['mcode'] = mcode_mod
|
||||
use_cache['core/mcode'] = mcode_mod
|
||||
use_cache['streamline'] = streamline_mod
|
||||
use_cache['core/streamline'] = streamline_mod
|
||||
|
||||
// analyze: tokenize + parse + fold, check for errors
|
||||
function analyze(src, filename) {
|
||||
var tok_result = tokenize_mod(src, filename)
|
||||
var _ast = parse_mod(tok_result.tokens, src, filename, tokenize_mod)
|
||||
var _i = 0
|
||||
var prev_line = -1
|
||||
var prev_msg = null
|
||||
var e = null
|
||||
var msg = null
|
||||
var line = null
|
||||
var col = null
|
||||
var has_errors = _ast.errors != null && length(_ast.errors) > 0
|
||||
if (has_errors) {
|
||||
while (_i < length(_ast.errors)) {
|
||||
e = _ast.errors[_i]
|
||||
msg = e.message
|
||||
line = e.line
|
||||
col = e.column
|
||||
if (msg != prev_msg || line != prev_line) {
|
||||
if (line != null && col != null)
|
||||
print(`${filename}:${text(line)}:${text(col)}: error: ${msg}`)
|
||||
else
|
||||
print(`${filename}: error: ${msg}`)
|
||||
}
|
||||
prev_line = line
|
||||
prev_msg = msg
|
||||
_i = _i + 1
|
||||
}
|
||||
disrupt
|
||||
}
|
||||
return fold_mod(_ast)
|
||||
}
|
||||
|
||||
// Lazy-loaded verify_ir module (loaded on first use)
|
||||
var _verify_ir_mod = null
|
||||
|
||||
// Run AST through mcode pipeline -> register VM
|
||||
function run_ast_fn(name, ast, env) {
|
||||
var compiled = mcode_mod(ast)
|
||||
if (os._verify_ir) {
|
||||
if (_verify_ir_mod == null) {
|
||||
_verify_ir_mod = load_pipeline_module('verify_ir', pipeline_env)
|
||||
}
|
||||
compiled._verify = true
|
||||
compiled._verify_mod = _verify_ir_mod
|
||||
}
|
||||
var optimized = streamline_mod(compiled)
|
||||
if (optimized._verify) {
|
||||
delete optimized._verify
|
||||
delete optimized._verify_mod
|
||||
}
|
||||
var mcode_json = json.encode(optimized)
|
||||
var mach_blob = mach_compile_mcode_bin(name, mcode_json)
|
||||
return mach_load(mach_blob, env)
|
||||
}
|
||||
|
||||
// Run AST through mcode pipeline WITHOUT optimization -> register VM
|
||||
function run_ast_noopt_fn(name, ast, env) {
|
||||
var compiled = mcode_mod(ast)
|
||||
var mcode_json = json.encode(compiled)
|
||||
var mach_blob = mach_compile_mcode_bin(name, mcode_json)
|
||||
return mach_load(mach_blob, env)
|
||||
}
|
||||
|
||||
// Compile AST to blob without loading (for caching)
|
||||
function compile_to_blob(name, ast) {
|
||||
var compiled = mcode_mod(ast)
|
||||
var optimized = streamline_mod(compiled)
|
||||
return mach_compile_mcode_bin(name, json.encode(optimized))
|
||||
}
|
||||
|
||||
// If loaded directly by C runtime (not via bootstrap), convert args -> init
|
||||
var _program = null
|
||||
var _user_args = []
|
||||
var _j = 1
|
||||
var _init = init
|
||||
if (args != null && _init == null) {
|
||||
_program = args[0]
|
||||
while (_j < length(args)) {
|
||||
push(_user_args, args[_j])
|
||||
_j = _j + 1
|
||||
}
|
||||
_init = {program: _program, arg: _user_args}
|
||||
}
|
||||
|
||||
use_cache['core/os'] = os
|
||||
|
||||
// Extra env properties added as engine initializes (log, runtime fns, etc.)
|
||||
@@ -68,8 +217,6 @@ function use_core(path) {
|
||||
var result = null
|
||||
var script = null
|
||||
var ast = null
|
||||
var mcode_path = null
|
||||
var mcode_blob = null
|
||||
var _load_mod = null
|
||||
|
||||
// Build env: merge core_extras
|
||||
@@ -82,32 +229,6 @@ function use_core(path) {
|
||||
var source_blob = null
|
||||
var file_path = null
|
||||
|
||||
// Check for pre-compiled .cm.mcode JSON IR (generated by regen)
|
||||
mcode_path = core_path + '/boot/' + replace(path, '/', '_') + '.cm.mcode'
|
||||
if (fd.is_file(mcode_path)) {
|
||||
_load_mod = function() {
|
||||
mcode_blob = fd.slurp(mcode_path)
|
||||
hash = content_hash(mcode_blob)
|
||||
cached_path = cache_path(hash)
|
||||
if (cached_path && fd.is_file(cached_path)) {
|
||||
result = mach_load(fd.slurp(cached_path), env)
|
||||
} else {
|
||||
mach_blob = mach_compile_mcode_bin('core:' + path, text(mcode_blob))
|
||||
if (cached_path) {
|
||||
ensure_build_dir()
|
||||
fd.slurpwrite(cached_path, mach_blob)
|
||||
}
|
||||
result = mach_load(mach_blob, env)
|
||||
}
|
||||
} disruption {
|
||||
print("use('" + path + "'): failed to load from " + mcode_path + "\n")
|
||||
disrupt
|
||||
}
|
||||
_load_mod()
|
||||
use_cache[cache_key] = result
|
||||
return result
|
||||
}
|
||||
|
||||
// Compile from source .cm file
|
||||
file_path = core_path + '/' + path + MOD_EXT
|
||||
if (fd.is_file(file_path)) {
|
||||
@@ -120,7 +241,7 @@ function use_core(path) {
|
||||
} else {
|
||||
script = text(source_blob)
|
||||
ast = analyze(script, file_path)
|
||||
mach_blob = compile_to_blob_fn('core:' + path, ast)
|
||||
mach_blob = compile_to_blob('core:' + path, ast)
|
||||
if (cached_path) {
|
||||
ensure_build_dir()
|
||||
fd.slurpwrite(cached_path, mach_blob)
|
||||
@@ -230,7 +351,7 @@ function actor_die(err)
|
||||
|
||||
//actor_mod.on_exception(actor_die)
|
||||
|
||||
_cell.args = init != null ? init : {}
|
||||
_cell.args = _init != null ? _init : {}
|
||||
|
||||
function create_actor(desc) {
|
||||
var _desc = desc == null ? {id:guid()} : desc
|
||||
@@ -244,7 +365,7 @@ var $_ = {}
|
||||
|
||||
use_cache['core/json'] = json
|
||||
|
||||
// Create runtime_env early (empty) — filled after pronto loads.
|
||||
// Create runtime_env early (empty) -- filled after pronto loads.
|
||||
// Shop accesses it lazily (in inject_env, called at module-use time, not load time)
|
||||
// so it sees the filled version.
|
||||
var runtime_env = {}
|
||||
@@ -265,8 +386,9 @@ core_extras.runtime_env = runtime_env
|
||||
core_extras.content_hash = content_hash
|
||||
core_extras.cache_path = cache_path
|
||||
core_extras.ensure_build_dir = ensure_build_dir
|
||||
core_extras.compile_to_blob = compile_to_blob
|
||||
|
||||
// NOW load shop — it receives all of the above via env
|
||||
// NOW load shop -- it receives all of the above via env
|
||||
var shop = use_core('internal/shop')
|
||||
var time = use_core('time')
|
||||
|
||||
@@ -387,7 +509,7 @@ REPLYTIMEOUT = config.reply_timeout
|
||||
replycc: the actor that is waiting for the reply
|
||||
target: ID of the actor that's supposed to receive the message. Only added to non direct sends (out of portals)
|
||||
return: reply ID so the replycc actor can know what callback to send the message to
|
||||
|
||||
|
||||
data: the actual content of the message
|
||||
}
|
||||
|
||||
@@ -458,7 +580,7 @@ $_.connection = function(callback, actor, config) {
|
||||
callback({type:"local"})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
callback()
|
||||
}
|
||||
|
||||
@@ -539,10 +661,10 @@ $_.start = function start(cb, program) {
|
||||
if (!program) return
|
||||
|
||||
var id = guid()
|
||||
var startup = {
|
||||
id,
|
||||
overling: $_.self,
|
||||
root,
|
||||
var startup = {
|
||||
id,
|
||||
overling: $_.self,
|
||||
root,
|
||||
program,
|
||||
}
|
||||
greeters[id] = cb
|
||||
@@ -748,7 +870,7 @@ actor_mod.register_actor(_cell.id, turn, true, config.ar_timer)
|
||||
|
||||
if (config.actor_memory)
|
||||
js.mem_limit(config.actor_memory)
|
||||
|
||||
|
||||
if (config.stack_max)
|
||||
js.max_stacksize(config.system.stack_max);
|
||||
|
||||
@@ -857,7 +979,7 @@ function handle_message(msg) {
|
||||
function enet_check()
|
||||
{
|
||||
if (portal) portal.service(handle_host)
|
||||
|
||||
|
||||
$_.delay(enet_check, ENETSERVICE);
|
||||
}
|
||||
|
||||
@@ -936,7 +1058,7 @@ $_.clock(_ => {
|
||||
} else {
|
||||
script = text(source_blob)
|
||||
ast = analyze(script, prog_path)
|
||||
mach_blob = compile_to_blob_fn(prog, ast)
|
||||
mach_blob = compile_to_blob(prog, ast)
|
||||
if (cached_path) {
|
||||
ensure_build_dir()
|
||||
fd.slurpwrite(cached_path, mach_blob)
|
||||
|
||||
125
regen.ce
125
regen.ce
@@ -1,125 +0,0 @@
|
||||
// regen.ce — regenerate .mcode bytecode files and pre-warm .mach cache
|
||||
|
||||
var fd = use("fd")
|
||||
var json = use("json")
|
||||
var crypto = use("crypto")
|
||||
var tokenize = use("tokenize")
|
||||
var parse = use("parse")
|
||||
var fold = use("fold")
|
||||
var mcode = use("mcode")
|
||||
var streamline = use("streamline")
|
||||
|
||||
// Pipeline files (tokenize/parse/fold/mcode/streamline) are only regenerated
|
||||
// with --all flag since they require a self-consistent compiler to bootstrap.
|
||||
var pipeline_files = [
|
||||
{src: "tokenize.cm", name: "tokenize", out: "boot/tokenize.cm.mcode"},
|
||||
{src: "parse.cm", name: "parse", out: "boot/parse.cm.mcode"},
|
||||
{src: "fold.cm", name: "fold", out: "boot/fold.cm.mcode"},
|
||||
{src: "mcode.cm", name: "mcode", out: "boot/mcode.cm.mcode"},
|
||||
{src: "streamline.cm", name: "streamline", out: "boot/streamline.cm.mcode"}
|
||||
]
|
||||
|
||||
var files = [
|
||||
{src: "qbe.cm", name: "qbe", out: "boot/qbe.cm.mcode"},
|
||||
{src: "qbe_emit.cm", name: "qbe_emit", out: "boot/qbe_emit.cm.mcode"},
|
||||
{src: "verify_ir.cm", name: "verify_ir", out: "boot/verify_ir.cm.mcode"},
|
||||
{src: "internal/bootstrap.cm", name: "bootstrap", out: "boot/bootstrap.cm.mcode"},
|
||||
{src: "internal/engine.cm", name: "engine", out: "boot/engine.cm.mcode"},
|
||||
{src: "boot/seed_bootstrap.cm", name: "seed_bootstrap", out: "boot/seed_bootstrap.cm.mcode"},
|
||||
{src: "fd.cm", name: "fd", out: "boot/fd.cm.mcode"},
|
||||
{src: "time.cm", name: "time", out: "boot/time.cm.mcode"},
|
||||
{src: "pronto.cm", name: "pronto", out: "boot/pronto.cm.mcode"},
|
||||
{src: "toml.cm", name: "toml", out: "boot/toml.cm.mcode"},
|
||||
{src: "link.cm", name: "link", out: "boot/link.cm.mcode"},
|
||||
{src: "toolchains.cm", name: "toolchains", out: "boot/toolchains.cm.mcode"},
|
||||
{src: "package.cm", name: "package", out: "boot/package.cm.mcode"},
|
||||
{src: "internal/shop.cm", name: "internal_shop", out: "boot/internal_shop.cm.mcode"}
|
||||
]
|
||||
|
||||
// Include pipeline files with --all flag
|
||||
var os = use('os')
|
||||
var regen_all = args != null && length(args) > 0 && args[0] == "--all"
|
||||
if (regen_all) {
|
||||
files = array(pipeline_files, files)
|
||||
}
|
||||
|
||||
// Resolve shop_path for cache writes
|
||||
var shop = os.getenv('CELL_SHOP')
|
||||
var home = null
|
||||
var cache_dir = null
|
||||
if (!shop) {
|
||||
home = os.getenv('HOME')
|
||||
if (home) {
|
||||
shop = home + '/.cell'
|
||||
}
|
||||
}
|
||||
if (shop) {
|
||||
cache_dir = shop + '/build'
|
||||
if (!fd.is_dir(cache_dir)) {
|
||||
fd.mkdir(cache_dir)
|
||||
}
|
||||
}
|
||||
|
||||
var i = 0
|
||||
var entry = null
|
||||
var src = null
|
||||
var tok_result = null
|
||||
var ast = null
|
||||
var folded = null
|
||||
var mcode_blob = null
|
||||
var hash = null
|
||||
var mach_blob = null
|
||||
var compiled = null
|
||||
var optimized = null
|
||||
var mcode_text = null
|
||||
var f = null
|
||||
var errs = null
|
||||
var ei = 0
|
||||
var e = null
|
||||
var had_errors = false
|
||||
var compact_mcode = null
|
||||
|
||||
while (i < length(files)) {
|
||||
entry = files[i]
|
||||
src = text(fd.slurp(entry.src))
|
||||
tok_result = tokenize(src, entry.src)
|
||||
ast = parse(tok_result.tokens, src, entry.src, tokenize)
|
||||
// Check for parse/semantic errors
|
||||
errs = ast.errors
|
||||
if (errs != null && length(errs) > 0) {
|
||||
ei = 0
|
||||
while (ei < length(errs)) {
|
||||
e = errs[ei]
|
||||
if (e.line != null) {
|
||||
print(`${entry.src}:${text(e.line)}:${text(e.column)}: error: ${e.message}`)
|
||||
} else {
|
||||
print(`${entry.src}: error: ${e.message}`)
|
||||
}
|
||||
ei = ei + 1
|
||||
}
|
||||
had_errors = true
|
||||
i = i + 1
|
||||
continue
|
||||
}
|
||||
folded = fold(ast)
|
||||
compiled = mcode(folded)
|
||||
optimized = streamline(compiled)
|
||||
mcode_text = json.encode(optimized)
|
||||
f = fd.open(entry.out, "w")
|
||||
fd.write(f, mcode_text)
|
||||
fd.close(f)
|
||||
print(`wrote ${entry.out}`)
|
||||
// Pre-warm .mach cache
|
||||
if (cache_dir) {
|
||||
mcode_blob = stone(blob(mcode_text))
|
||||
hash = text(crypto.blake2(mcode_blob), 'h')
|
||||
compact_mcode = json.encode(optimized)
|
||||
mach_blob = mach_compile_mcode_bin(entry.name, compact_mcode)
|
||||
fd.slurpwrite(cache_dir + '/' + hash, mach_blob)
|
||||
print(` cached ${hash}`)
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
if (had_errors) {
|
||||
print("regen aborted: fix errors above")
|
||||
}
|
||||
269
source/cell.c
269
source/cell.c
@@ -12,8 +12,7 @@
|
||||
#include "cJSON.h"
|
||||
|
||||
#define BOOTSTRAP_MCODE "boot/bootstrap.cm.mcode"
|
||||
#define SEED_BOOTSTRAP_MCODE "boot/seed_bootstrap.cm.mcode"
|
||||
#define BOOTSTRAP_SRC "internal/bootstrap.cm"
|
||||
#define ENGINE_SRC "internal/engine.cm"
|
||||
#define CELL_SHOP_DIR ".cell"
|
||||
#define CELL_CORE_DIR "packages/core"
|
||||
|
||||
@@ -213,6 +212,37 @@ static char* load_core_file(const char *filename, size_t *out_size) {
|
||||
return data;
|
||||
}
|
||||
|
||||
// Try loading engine.cm from source-hash cache
|
||||
// Returns heap-allocated binary data and sets *out_size, or NULL on cache miss
|
||||
static char *try_engine_cache(size_t *out_size) {
|
||||
size_t src_size;
|
||||
char *src = load_core_file(ENGINE_SRC, &src_size);
|
||||
if (!src) return NULL;
|
||||
|
||||
char *hex = compute_blake2_hex(src, src_size);
|
||||
free(src);
|
||||
char *cpath = build_cache_path(hex);
|
||||
if (!cpath) { free(hex); return NULL; }
|
||||
free(hex);
|
||||
|
||||
FILE *fh = fopen(cpath, "rb");
|
||||
if (!fh) { free(cpath); return NULL; }
|
||||
free(cpath);
|
||||
|
||||
fseek(fh, 0, SEEK_END);
|
||||
long file_size = ftell(fh);
|
||||
fseek(fh, 0, SEEK_SET);
|
||||
char *data = malloc(file_size);
|
||||
if (data && fread(data, 1, file_size, fh) == (size_t)file_size) {
|
||||
fclose(fh);
|
||||
*out_size = file_size;
|
||||
return data;
|
||||
}
|
||||
free(data);
|
||||
fclose(fh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get the core path for use by scripts
|
||||
const char* cell_get_core_path(void) {
|
||||
return core_path;
|
||||
@@ -254,26 +284,57 @@ void script_startup(cell_rt *prt)
|
||||
cell_rt *crt = JS_GetContextOpaque(js);
|
||||
JS_FreeValue(js, js_core_blob_use(js));
|
||||
|
||||
// Load pre-compiled bootstrap .mcode
|
||||
size_t boot_size;
|
||||
char *boot_data = load_core_file(BOOTSTRAP_MCODE, &boot_size);
|
||||
if (!boot_data) {
|
||||
printf("ERROR: Could not load bootstrap from %s!\n", core_path);
|
||||
return;
|
||||
}
|
||||
|
||||
// Try cache or compile mcode → binary
|
||||
// Try engine fast-path: load engine.cm from source-hash cache
|
||||
size_t bin_size;
|
||||
char *bin_data = load_or_cache_bootstrap(boot_data, boot_size, &bin_size);
|
||||
free(boot_data);
|
||||
char *bin_data = try_engine_cache(&bin_size);
|
||||
|
||||
if (!bin_data) {
|
||||
printf("ERROR: Failed to compile bootstrap mcode!\n");
|
||||
return;
|
||||
// Cold path: run bootstrap to seed cache, then retry
|
||||
size_t boot_size;
|
||||
char *boot_data = load_core_file(BOOTSTRAP_MCODE, &boot_size);
|
||||
if (!boot_data) {
|
||||
printf("ERROR: Could not load bootstrap from %s!\n", core_path);
|
||||
return;
|
||||
}
|
||||
size_t boot_bin_size;
|
||||
char *boot_bin = load_or_cache_bootstrap(boot_data, boot_size, &boot_bin_size);
|
||||
free(boot_data);
|
||||
if (!boot_bin) {
|
||||
printf("ERROR: Failed to compile bootstrap mcode!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Build env for bootstrap (only needs os, core_path, shop_path)
|
||||
JSGCRef boot_env_ref;
|
||||
JS_AddGCRef(js, &boot_env_ref);
|
||||
boot_env_ref.val = JS_NewObject(js);
|
||||
JSValue btmp;
|
||||
btmp = js_core_os_use(js);
|
||||
JS_SetPropertyStr(js, boot_env_ref.val, "os", btmp);
|
||||
if (core_path) {
|
||||
btmp = JS_NewString(js, core_path);
|
||||
JS_SetPropertyStr(js, boot_env_ref.val, "core_path", btmp);
|
||||
}
|
||||
btmp = shop_path ? JS_NewString(js, shop_path) : JS_NULL;
|
||||
JS_SetPropertyStr(js, boot_env_ref.val, "shop_path", btmp);
|
||||
JSValue boot_env = JS_Stone(js, boot_env_ref.val);
|
||||
JS_DeleteGCRef(js, &boot_env_ref);
|
||||
|
||||
crt->state = ACTOR_RUNNING;
|
||||
JSValue bv = JS_RunMachBin(js, (const uint8_t *)boot_bin, boot_bin_size, boot_env);
|
||||
free(boot_bin);
|
||||
uncaught_exception(js, bv);
|
||||
crt->state = ACTOR_IDLE;
|
||||
|
||||
// Retry engine from cache
|
||||
bin_data = try_engine_cache(&bin_size);
|
||||
if (!bin_data) {
|
||||
printf("ERROR: Bootstrap ran but engine.cm not in cache!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create hidden environment
|
||||
// Note: evaluate allocating calls into temporaries before passing to
|
||||
// JS_SetPropertyStr, so env_ref.val is read AFTER GC may have moved it.
|
||||
// Build engine environment
|
||||
JSGCRef env_ref;
|
||||
JS_AddGCRef(js, &env_ref);
|
||||
env_ref.val = JS_NewObject(js);
|
||||
@@ -311,7 +372,7 @@ void script_startup(cell_rt *prt)
|
||||
JSValue hidden_env = JS_Stone(js, env_ref.val);
|
||||
JS_DeleteGCRef(js, &env_ref);
|
||||
|
||||
// Run from binary
|
||||
// Run engine from binary
|
||||
crt->state = ACTOR_RUNNING;
|
||||
JSValue v = JS_RunMachBin(js, (const uint8_t *)bin_data, bin_size, hidden_env);
|
||||
free(bin_data);
|
||||
@@ -371,7 +432,6 @@ static void print_usage(const char *prog)
|
||||
printf(" --shop <path> Set shop path (overrides CELL_SHOP)\n");
|
||||
printf(" --dev Dev mode (shop=.cell, core=.)\n");
|
||||
printf(" --heap <size> Initial heap size (e.g. 256MB, 1GB)\n");
|
||||
printf(" --seed Use seed bootstrap (minimal, for regen)\n");
|
||||
printf(" --test [heap_size] Run C test suite\n");
|
||||
printf(" -h, --help Show this help message\n");
|
||||
printf("\nEnvironment:\n");
|
||||
@@ -402,9 +462,8 @@ int cell_init(int argc, char **argv)
|
||||
return run_test_suite(heap_size);
|
||||
}
|
||||
|
||||
/* Default: run script through bootstrap pipeline */
|
||||
/* Default: run script through engine pipeline */
|
||||
int arg_start = 1;
|
||||
int seed_mode = 0;
|
||||
size_t heap_size = 1024 * 1024; /* 1MB default */
|
||||
const char *shop_override = NULL;
|
||||
const char *core_override = NULL;
|
||||
@@ -425,9 +484,6 @@ int cell_init(int argc, char **argv)
|
||||
}
|
||||
core_override = argv[arg_start + 1];
|
||||
arg_start += 2;
|
||||
} else if (strcmp(argv[arg_start], "--seed") == 0) {
|
||||
seed_mode = 1;
|
||||
arg_start++;
|
||||
} else if (strcmp(argv[arg_start], "--heap") == 0) {
|
||||
if (arg_start + 1 >= argc) {
|
||||
printf("ERROR: --heap requires a size argument (e.g. 1GB, 256MB, 65536)\n");
|
||||
@@ -464,33 +520,15 @@ int cell_init(int argc, char **argv)
|
||||
|
||||
actor_initialize();
|
||||
|
||||
const char *boot_mcode = seed_mode ? SEED_BOOTSTRAP_MCODE : BOOTSTRAP_MCODE;
|
||||
size_t boot_size;
|
||||
char *boot_data = load_core_file(boot_mcode, &boot_size);
|
||||
if (!boot_data) {
|
||||
printf("ERROR: Could not load bootstrap from %s\n", core_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Try cache or compile mcode → binary
|
||||
size_t bin_size;
|
||||
char *bin_data = load_or_cache_bootstrap(boot_data, boot_size, &bin_size);
|
||||
free(boot_data);
|
||||
if (!bin_data) {
|
||||
printf("ERROR: Failed to compile bootstrap mcode\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_runtime = JS_NewRuntime();
|
||||
if (!g_runtime) {
|
||||
printf("Failed to create JS runtime\n");
|
||||
free(bin_data);
|
||||
return 1;
|
||||
}
|
||||
JSContext *ctx = JS_NewContextWithHeapSize(g_runtime, heap_size);
|
||||
if (!ctx) {
|
||||
printf("Failed to create JS context\n");
|
||||
free(bin_data); JS_FreeRuntime(g_runtime);
|
||||
JS_FreeRuntime(g_runtime);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -525,47 +563,116 @@ int cell_init(int argc, char **argv)
|
||||
|
||||
JS_FreeValue(ctx, js_core_blob_use(ctx));
|
||||
|
||||
JSGCRef env_ref;
|
||||
JS_AddGCRef(ctx, &env_ref);
|
||||
env_ref.val = JS_NewObject(ctx);
|
||||
JSValue tmp;
|
||||
tmp = js_core_os_use(ctx);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "os", tmp);
|
||||
tmp = JS_NewString(ctx, core_path);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "core_path", tmp);
|
||||
tmp = shop_path ? JS_NewString(ctx, shop_path) : JS_NULL;
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "shop_path", tmp);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "actorsym", JS_DupValue(ctx, cli_rt->actor_sym_ref.val));
|
||||
tmp = js_core_json_use(ctx);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "json", tmp);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "init", JS_NULL);
|
||||
JSGCRef args_ref;
|
||||
JS_AddGCRef(ctx, &args_ref);
|
||||
args_ref.val = JS_NewArray(ctx);
|
||||
for (int i = arg_start; i < argc; i++) {
|
||||
JSValue str = JS_NewString(ctx, argv[i]);
|
||||
JS_ArrayPush(ctx, &args_ref.val, str);
|
||||
}
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "args", args_ref.val);
|
||||
JS_DeleteGCRef(ctx, &args_ref);
|
||||
JSValue hidden_env = JS_Stone(ctx, env_ref.val);
|
||||
JS_DeleteGCRef(ctx, &env_ref);
|
||||
|
||||
JSValue result = JS_RunMachBin(ctx, (const uint8_t *)bin_data, bin_size, hidden_env);
|
||||
free(bin_data);
|
||||
|
||||
int exit_code = 0;
|
||||
if (JS_IsException(result)) {
|
||||
JS_GetException(ctx);
|
||||
exit_code = 1;
|
||||
} else if (!JS_IsNull(result)) {
|
||||
const char *str = JS_ToCString(ctx, result);
|
||||
if (str) {
|
||||
printf("%s\n", str);
|
||||
JS_FreeCString(ctx, str);
|
||||
|
||||
// Try engine fast-path: load engine.cm from source-hash cache
|
||||
size_t bin_size;
|
||||
char *bin_data = try_engine_cache(&bin_size);
|
||||
|
||||
if (!bin_data) {
|
||||
// Cold path: run bootstrap to seed cache, then retry
|
||||
size_t boot_size;
|
||||
char *boot_data = load_core_file(BOOTSTRAP_MCODE, &boot_size);
|
||||
if (!boot_data) {
|
||||
printf("ERROR: Could not load bootstrap from %s\n", core_path);
|
||||
return 1;
|
||||
}
|
||||
size_t boot_bin_size;
|
||||
char *boot_bin = load_or_cache_bootstrap(boot_data, boot_size, &boot_bin_size);
|
||||
free(boot_data);
|
||||
if (!boot_bin) {
|
||||
printf("ERROR: Failed to compile bootstrap mcode\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Build env for bootstrap (os, core_path, shop_path required;
|
||||
// args, json, actorsym provided for compatibility)
|
||||
JSGCRef boot_env_ref;
|
||||
JS_AddGCRef(ctx, &boot_env_ref);
|
||||
boot_env_ref.val = JS_NewObject(ctx);
|
||||
JSValue btmp;
|
||||
btmp = js_core_os_use(ctx);
|
||||
JS_SetPropertyStr(ctx, boot_env_ref.val, "os", btmp);
|
||||
btmp = JS_NewString(ctx, core_path);
|
||||
JS_SetPropertyStr(ctx, boot_env_ref.val, "core_path", btmp);
|
||||
btmp = shop_path ? JS_NewString(ctx, shop_path) : JS_NULL;
|
||||
JS_SetPropertyStr(ctx, boot_env_ref.val, "shop_path", btmp);
|
||||
JS_SetPropertyStr(ctx, boot_env_ref.val, "actorsym", JS_DupValue(ctx, cli_rt->actor_sym_ref.val));
|
||||
btmp = js_core_json_use(ctx);
|
||||
JS_SetPropertyStr(ctx, boot_env_ref.val, "json", btmp);
|
||||
JS_SetPropertyStr(ctx, boot_env_ref.val, "init", JS_NULL);
|
||||
JSGCRef boot_args_ref;
|
||||
JS_AddGCRef(ctx, &boot_args_ref);
|
||||
boot_args_ref.val = JS_NewArray(ctx);
|
||||
for (int i = arg_start; i < argc; i++) {
|
||||
JSValue str = JS_NewString(ctx, argv[i]);
|
||||
JS_ArrayPush(ctx, &boot_args_ref.val, str);
|
||||
}
|
||||
JS_SetPropertyStr(ctx, boot_env_ref.val, "args", boot_args_ref.val);
|
||||
JS_DeleteGCRef(ctx, &boot_args_ref);
|
||||
JSValue boot_env = JS_Stone(ctx, boot_env_ref.val);
|
||||
JS_DeleteGCRef(ctx, &boot_env_ref);
|
||||
|
||||
JSValue boot_result = JS_RunMachBin(ctx, (const uint8_t *)boot_bin, boot_bin_size, boot_env);
|
||||
free(boot_bin);
|
||||
if (JS_IsException(boot_result)) {
|
||||
JS_GetException(ctx);
|
||||
printf("ERROR: Bootstrap failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Retry engine from cache (new-style bootstrap seeds it)
|
||||
bin_data = try_engine_cache(&bin_size);
|
||||
if (!bin_data) {
|
||||
// Old-style bootstrap already ran the program — skip engine load
|
||||
goto check_actors;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// Build engine environment
|
||||
JSGCRef env_ref;
|
||||
JS_AddGCRef(ctx, &env_ref);
|
||||
env_ref.val = JS_NewObject(ctx);
|
||||
JSValue tmp;
|
||||
tmp = js_core_os_use(ctx);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "os", tmp);
|
||||
tmp = JS_NewString(ctx, core_path);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "core_path", tmp);
|
||||
tmp = shop_path ? JS_NewString(ctx, shop_path) : JS_NULL;
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "shop_path", tmp);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "actorsym", JS_DupValue(ctx, cli_rt->actor_sym_ref.val));
|
||||
tmp = js_core_json_use(ctx);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "json", tmp);
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "init", JS_NULL);
|
||||
JSGCRef args_ref;
|
||||
JS_AddGCRef(ctx, &args_ref);
|
||||
args_ref.val = JS_NewArray(ctx);
|
||||
for (int i = arg_start; i < argc; i++) {
|
||||
JSValue str = JS_NewString(ctx, argv[i]);
|
||||
JS_ArrayPush(ctx, &args_ref.val, str);
|
||||
}
|
||||
JS_SetPropertyStr(ctx, env_ref.val, "args", args_ref.val);
|
||||
JS_DeleteGCRef(ctx, &args_ref);
|
||||
JSValue hidden_env = JS_Stone(ctx, env_ref.val);
|
||||
|
||||
JSValue result = JS_RunMachBin(ctx, (const uint8_t *)bin_data, bin_size, hidden_env);
|
||||
JS_DeleteGCRef(ctx, &env_ref);
|
||||
free(bin_data);
|
||||
|
||||
if (JS_IsException(result)) {
|
||||
JS_GetException(ctx);
|
||||
exit_code = 1;
|
||||
} else if (!JS_IsNull(result)) {
|
||||
const char *str = JS_ToCString(ctx, result);
|
||||
if (str) {
|
||||
printf("%s\n", str);
|
||||
JS_FreeCString(ctx, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check_actors:
|
||||
if (scheduler_actor_count() > 0) {
|
||||
scheduler_enable_quiescence();
|
||||
actor_loop();
|
||||
|
||||
@@ -95,8 +95,7 @@ static void mach_link_code(JSContext *ctx, JSCodeRegister *code, JSValue env) {
|
||||
int bx = MACH_GET_Bx(instr);
|
||||
int in_env = 0;
|
||||
if (!JS_IsNull(env_ref.val) && (uint32_t)bx < code->cpool_count) {
|
||||
JSValue val = JS_GetProperty(ctx, env_ref.val, code->cpool[bx]);
|
||||
in_env = !JS_IsNull(val) && !JS_IsException(val);
|
||||
in_env = JS_HasProperty(ctx, env_ref.val, code->cpool[bx]);
|
||||
}
|
||||
code->instructions[i] = MACH_ABx(in_env ? MACH_GETENV : MACH_GETINTRINSIC, a, bx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user