248 files changed+1771−677
.gitignoremodified
+2−1@@ -15,8 +15,9 @@ ashvm/benchmarks/native_jit *~ # Dont put ai Slop in my Code-.claude CLAUDE.md+AGENTS.md+.claude .agents skills-lock.json CHANGELOG.mdmodified
+15−0@@ -1,3 +1,18 @@+## 2026-10-07 (back on Ash + source and test restructure)+First day back on this project after a break (the last entry here is from 2026-07-21), and it's good to finally be able to pick Ash up again. Before building anything new, the repo got a full cleanup so it's a place I actually want to work in: nothing in the language itself changed, only where files live.++**Why everything is so separated now.** `kiln/src/codegen` had grown to 122 files in one flat directory (sources, headers, `.d` and `.o` all mixed together), and the other directories were headed the same way. Every subsystem is now split into four mirrored trees: `C/` (sources), `H/` (headers), `D/` (dependency files) and `O/` (objects), and inside each tree the files are grouped by feature. For example, `codegen/C/expressions/expr.c` pairs with `codegen/H/expressions/expr.h`, `codegen/D/expressions/expr.d` and `codegen/O/expressions/expr.o`. It's about cleanliness first: you can see where something lives from the path alone, no directory goes past ~14 files, and generated output never sits in the middle of hand-written code. It should also be far better to maintain: adding a module means one obvious place per file type, and the Lua-style high-level rework planned in `plans.md` will touch the lexer and compiler without having to dig through hundreds of files.++- **kiln:** `codegen/` split into `emit`, `expressions`, `functions`, `runtime`, `collections`, `strings`, `builtins`, `io` and `platform`; `parser/` split into `core`, `statements`, `declarations` and `imports`. `lexer`, `elf`, `pe`, `diagnostics` and `app` (`main.c`, `target.c`) got the four trees without extra feature folders, since they are small.+- **ashvm:** same four-tree layout for every subsystem (no `D/` tree, because its Makefile never produced dependency files); `common.h` moved to `app/H/`.+- **Makefiles:** both build objects into the `O/` trees (and kiln dependency files into `D/`) through one generated compile rule instead of in-place `.o` files. `.DEFAULT_GOAL` is pinned to `all`. `make clean` now deletes only `*.o`/`*.d` files so the folders survive, and every `O/` directory has a `.gitkeep` so the empty trees stay in git.+- **Tests:** both `tests/` folders are now `cases/<feature>/*.ash` plus `scripts/` for the `.sh` files (`run_regression.sh` and the two import checks). `fixtures/` and `ash.libs/` moved into `cases/imports/` because imports resolve relative to the entry file's directory.+- **Docs:** `AGENTS.md` condensed so it stays a short, followable rule set for me and for any AI agent, now including the test layout; README structure sections updated.++Verified: clean rebuild of both projects with zero warnings, and the full regression suites (38 kiln cases, 15 ashvm cases, plus the import check scripts) byte-identical to baselines captured before any file moved. The single difference is the path printed in `error_handling_test`'s diagnostic, which now shows the new location of the file. No function bodies were changed.++Next up: the high-level, Lua-style syntax from `plans.md`, without losing the VM's and Kiln's speed.+ ## 2026-07-21 (modules/imports + library storage, both engines) kiln and ashvm both now support `@import <./relative/path.ash>;` and `@import <libname>;` (the latter resolving to `ash.libs/<libname>/<libname>.ash`), with imported functions and constants accessed via namespaced `ns.func(...)`/`ns.CONST` syntax. Implementation is source-level recursive merge, matching the design spec's Approach A: no linker, no new object format — the parser recursively parses an imported file's `fn` declarations and literal top-level `let` constants inline and registers them under a namespaced name (e.g. `"math.add"`) in the same flat function/constant tables everything else already uses. Constants are compile-time-folded to their literal value at each `ns.CONST` use site, not stored as real runtime state. Diamond dependencies (the same file reached via more than one import path) dedup by canonical filesystem path; circular imports and namespace collisions (two different files/libraries deriving the same auto-namespace) are both compile errors, with the collision message naming both colliding resolved paths. Verified by a real regression suite on both engines: `kiln/tests/imports_basic.ash`, `imports_lib.ash`, `imports_const.ash`, `imports_diamond.ash`, `imports_circular_check.sh`, `imports_collision_check.sh`, mirrored in `ashvm/tests/`. README.mdmodified
+6−2@@ -93,9 +93,13 @@ compiler/ single-pass compiler: parser/emitter state, expression chain, call/lambda emission, statement compilation builtins/ len, map, filter, reduce, string/file ops diagnostics/ shared Rust-style error reporting (compile-time and runtime)-main.c entry point (file mode + REPL)++Every subsystem keeps sources in `C/`, headers in `H/`, and build output in a+mirrored `O/` tree (kiln also has `D/` for dependency files), e.g.+`src/vm/C/dispatch.c` includes `src/vm/H/vm.h` and builds to `src/vm/O/dispatch.o`.+app/ main.c entry point (file mode + REPL) benchmarks/ .ash and .cpp benchmark programs, plus the x86-64 JIT experiment-tests/ example programs covering each language feature+tests/ cases/<feature>/*.ash programs covering each language feature; scripts/ holds the regression runners kiln/ a standalone .ash compiler (Windows + Linux). Not started yet. ## Editor supportashvm/Makefilemodified
+38−7@@ -1,14 +1,45 @@ CC = gcc+.DEFAULT_GOAL := all CFLAGS = -Wall -Wextra -std=c11 -O2 -Isrc LDFLAGS = -lm -ASHVM_SRC = src/main.c src/lexer/lexer.c src/lexer/lexer_import.c src/value/value.c src/value/hashmap.c src/vm/chunk.c \- src/compiler/state.c src/compiler/expr.c src/compiler/calls.c src/compiler/stmt.c src/compiler/stmt_control.c \- src/compiler/import_paths.c src/compiler/stmt_import.c src/compiler/constants.c \- src/builtins/builtins.c src/builtins/core.c src/builtins/collection.c src/builtins/string.c src/builtins/file.c \- src/vm/state.c src/vm/errors.c src/vm/dispatch.c src/vm/api.c \- src/diagnostics/diagnostics.c-ASHVM_OBJ = $(ASHVM_SRC:.c=.o)+ASHVM_SRC = \+ src/app/C/main.c \+ src/lexer/C/lexer.c \+ src/lexer/C/lexer_import.c \+ src/value/C/hashmap.c \+ src/value/C/value.c \+ src/vm/C/api.c \+ src/vm/C/chunk.c \+ src/vm/C/dispatch.c \+ src/vm/C/errors.c \+ src/vm/C/state.c \+ src/compiler/C/calls.c \+ src/compiler/C/constants.c \+ src/compiler/C/expr.c \+ src/compiler/C/import_paths.c \+ src/compiler/C/state.c \+ src/compiler/C/stmt.c \+ src/compiler/C/stmt_control.c \+ src/compiler/C/stmt_import.c \+ src/builtins/C/builtins.c \+ src/builtins/C/collection.c \+ src/builtins/C/core.c \+ src/builtins/C/file.c \+ src/builtins/C/string.c \+ src/diagnostics/C/diagnostics.c++# Objects and dependency files live in trees parallel to each C tree:+# src/<subsystem>/C/<feature>/x.c -> src/<subsystem>/O/<feature>/x.o+obj_of = $(patsubst %.c,%.o,$(subst /C/,/O/,$(1)))+ASHVM_OBJ = $(foreach s,$(ASHVM_SRC),$(call obj_of,$(s)))++define compile_rule+$(call obj_of,$(1)): $(1)+ @mkdir -p $$(dir $$@)+ $$(CC) $$(CFLAGS) -c $$< -o $$@+endef+$(foreach s,$(ASHVM_SRC),$(eval $(call compile_rule,$(s)))) BIN = ../bin/ashvm ashvm/src/app/C/main.cmodified
+3−3@@ -2,9 +2,9 @@ #include <stdlib.h> #include <string.h> #include <setjmp.h>-#include "compiler/compiler.h"-#include "vm/vm.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/compiler.h"+#include "vm/H/vm.h"+#include "diagnostics/H/diagnostics.h" static char *read_file(const char *path) { FILE *file = fopen(path, "rb");ashvm/src/app/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
ashvm/src/builtins/C/builtins.cmodified
+3−3@@ -1,7 +1,7 @@ #include <string.h>-#include "builtins/builtins.h"-#include "builtins/internal.h"-#include "vm/vm.h"+#include "builtins/H/builtins.h"+#include "builtins/H/internal.h"+#include "vm/H/vm.h" static const char *builtin_names[] = { "len", "push", "input", "str", "num", "sqrt", "abs", "floor",ashvm/src/builtins/C/collection.cmodified
+3−3@@ -1,8 +1,8 @@ #include <stdlib.h> #include <string.h>-#include "builtins/internal.h"-#include "vm/vm.h"-#include "value/hashmap.h"+#include "builtins/H/internal.h"+#include "vm/H/vm.h"+#include "value/H/hashmap.h" VMValue vm_call_builtin_collection(int id, VMValue *args, int argc) { switch (id) {ashvm/src/builtins/C/core.cmodified
+3−3@@ -2,9 +2,9 @@ #include <stdlib.h> #include <string.h> #include <math.h>-#include "builtins/internal.h"-#include "vm/vm.h"-#include "value/hashmap.h"+#include "builtins/H/internal.h"+#include "vm/H/vm.h"+#include "value/H/hashmap.h" VMValue vm_call_builtin_core(int id, VMValue *args, int argc) { switch (id) {ashvm/src/builtins/C/file.cmodified
+2−2@@ -1,8 +1,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "builtins/internal.h"-#include "vm/vm.h"+#include "builtins/H/internal.h"+#include "vm/H/vm.h" VMValue vm_call_builtin_file(int id, VMValue *args, int argc) { switch (id) {ashvm/src/builtins/C/string.cmodified
+2−2@@ -1,8 +1,8 @@ #include <stdlib.h> #include <string.h> #include <ctype.h>-#include "builtins/internal.h"-#include "vm/vm.h"+#include "builtins/H/internal.h"+#include "vm/H/vm.h" VMValue vm_call_builtin_string(int id, VMValue *args, int argc) { switch (id) {ashvm/src/builtins/H/builtins.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef ASH_VM_BUILTINS_H #define ASH_VM_BUILTINS_H-#include "value/value.h"+#include "value/H/value.h" int vm_builtin_lookup(const char *name, int len); VMValue vm_call_builtin(int id, VMValue *args, int argc);ashvm/src/builtins/H/internal.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef ASH_VM_BUILTINS_INTERNAL_H #define ASH_VM_BUILTINS_INTERNAL_H-#include "value/value.h"+#include "value/H/value.h" // Each group handles a contiguous id range within vm_call_builtin's switch; // see builtins.c for the range -> group mapping and the shared name table.ashvm/src/builtins/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
ashvm/src/compiler/C/calls.cmodified
+3−3@@ -1,9 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "compiler/internal.h"-#include "builtins/builtins.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/internal.h"+#include "builtins/H/builtins.h"+#include "diagnostics/H/diagnostics.h" void emit_call(Token id) { int builtin_id = vm_builtin_lookup(id.start, id.length);ashvm/src/compiler/C/constants.cmodified
+3−3@@ -1,9 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "compiler/constants.h"-#include "compiler/internal.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/constants.h"+#include "compiler/H/internal.h"+#include "diagnostics/H/diagnostics.h" static VMConstant constants[MAX_VM_CONSTS]; static int constant_count = 0;ashvm/src/compiler/C/expr.cmodified
+2−2@@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h>-#include "compiler/internal.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/internal.h"+#include "diagnostics/H/diagnostics.h" // Precedence climbing: expression -> logical_or -> logical_and -> // comparison -> additive -> term -> unary -> postfix -> primary.ashvm/src/compiler/C/import_paths.cmodified
+1−1@@ -2,7 +2,7 @@ #include <string.h> #include <stdio.h> #include <stdlib.h>-#include "compiler/import_paths.h"+#include "compiler/H/import_paths.h" void import_path_dirname(const char *path, char *out, int out_size) { const char *slash = strrchr(path, '/');ashvm/src/compiler/C/state.cmodified
+2−2@@ -1,7 +1,7 @@ #include <stdlib.h> #include <string.h>-#include "compiler/state.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/state.h"+#include "diagnostics/H/diagnostics.h" VMFunction vm_functions[MAX_VM_FUNCS]; int vm_function_count = 0;ashvm/src/compiler/C/stmt.cmodified
+2−2@@ -1,8 +1,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "compiler/internal.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/internal.h"+#include "diagnostics/H/diagnostics.h" // statement() is shared between top-level parsing (compile()'s own loop, // and stmt_import.c's parse_imported_file_body()) and here, inside aashvm/src/compiler/C/stmt_control.cmodified
+2−2@@ -1,7 +1,7 @@ #include <stdlib.h> #include <string.h>-#include "compiler/internal.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/internal.h"+#include "diagnostics/H/diagnostics.h" // Each function here assumes statement() already consumed the keyword token // (TOKEN_FN / TOKEN_IF / TOKEN_TRY / TOKEN_WHILE) that identified it.ashvm/src/compiler/C/stmt_import.cmodified
+4−4@@ -3,9 +3,9 @@ #include <stdio.h> #include <stdlib.h> #include <limits.h>-#include "compiler/internal.h"-#include "compiler/import_paths.h"-#include "diagnostics/diagnostics.h"+#include "compiler/H/internal.h"+#include "compiler/H/import_paths.h"+#include "diagnostics/H/diagnostics.h" #define MAX_VM_IMPORTS 16 #define MAX_VM_IMPORT_DEPTH 8@@ -178,7 +178,7 @@ void compile_import_stmt(void) { resolving_depth++; // --- Save everything the recursive parse of the imported file will- // clobber, mirroring compiler/state.c's own save-recurse-restore+ // clobber, mirroring compiler/C/state.c's own save-recurse-restore // pattern for locals (the C call stack gives correct nesting for // free, same as those). --- DiagnosticsSource saved_diag = diagnostics_save_source();ashvm/src/compiler/H/compiler.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef ASH_VM_COMPILER_H #define ASH_VM_COMPILER_H-#include "vm/chunk.h"+#include "vm/H/chunk.h" #define MAX_VM_FUNCS 64 #define MAX_VM_LOCALS 128ashvm/src/compiler/H/constants.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef ASH_VM_COMPILER_CONSTANTS_H #define ASH_VM_COMPILER_CONSTANTS_H-#include "value/value.h"+#include "value/H/value.h" #define MAX_VM_CONSTS 32 ashvm/src/compiler/H/internal.hmodified
+2−2@@ -1,7 +1,7 @@ #ifndef ASH_VM_COMPILER_INTERNAL_H #define ASH_VM_COMPILER_INTERNAL_H-#include "compiler/state.h"-#include "compiler/constants.h"+#include "compiler/H/state.h"+#include "compiler/H/constants.h" // Cross-file forward declarations between compiler_expr.c and // compiler_stmt.c -- not part of the public API (compiler.h).ashvm/src/compiler/H/state.hmodified
+2−2@@ -1,7 +1,7 @@ #ifndef ASH_VM_COMPILER_STATE_H #define ASH_VM_COMPILER_STATE_H-#include "compiler/compiler.h"-#include "lexer/lexer.h"+#include "compiler/H/compiler.h"+#include "lexer/H/lexer.h" // Shared parser/emitter state for compiler_expr.c and compiler_stmt.c -- // not part of the public API (compiler.h). Mirrors the sameashvm/src/compiler/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
ashvm/src/diagnostics/C/diagnostics.cmodified
+1−1@@ -2,7 +2,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h>-#include "diagnostics/diagnostics.h"+#include "diagnostics/H/diagnostics.h" static const char *g_source = NULL; static const char *g_filename = "source";ashvm/src/diagnostics/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
ashvm/src/lexer/C/lexer.cmodified
+3−3@@ -1,11 +1,11 @@ #include <string.h> #include <ctype.h>-#include "lexer/lexer.h"-#include "lexer/lexer_import.h"+#include "lexer/H/lexer.h"+#include "lexer/H/lexer_import.h" // lex_* (not the bare start/current/line these had as file-static // before) -- shared with lexer_import.c now, and a plain `current` would-// collide with compiler/state.h's own global `Token current` at link time.+// collide with compiler/H/state.h's own global `Token current` at link time. const char *lex_start; const char *lex_current; int lex_line;ashvm/src/lexer/C/lexer_import.cmodified
+1−1@@ -1,4 +1,4 @@-#include "lexer/lexer_import.h"+#include "lexer/H/lexer_import.h" LexerState lexer_save_state(void) { LexerState state;ashvm/src/lexer/H/lexer_import.hmodified
+2−2@@ -1,6 +1,6 @@ #ifndef ASHVM_LEXER_IMPORT_H #define ASHVM_LEXER_IMPORT_H-#include "lexer/lexer.h"+#include "lexer/H/lexer.h" // Cross-file link between lexer.c (the tokenizer's cursor state and its // low-level scan primitives) and lexer_import.c (state save/restore plus@@ -13,7 +13,7 @@ // between lexer.h (public surface) and lexer_import.h (private, // cross-file plumbing). //-// Named lex_* rather than the bare start/current/line: compiler/state.h+// Named lex_* rather than the bare start/current/line: compiler/H/state.h // already declares its own global `Token current`, and since these now // need external linkage to be shared across the two .c files, a second // plain `current` global here would collide with it at link time.ashvm/src/lexer/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
ashvm/src/value/C/hashmap.cmodified
+1−1@@ -1,6 +1,6 @@ #include <stdlib.h> #include <string.h>-#include "value/hashmap.h"+#include "value/H/hashmap.h" static unsigned long hash_string(const char *s) { unsigned long h = 5381;ashvm/src/value/C/value.cmodified
+2−2@@ -1,8 +1,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "value/value.h"-#include "value/hashmap.h"+#include "value/H/value.h"+#include "value/H/hashmap.h" VMValue vm_num(double n) { VMValue v; v.type = VM_NUM; v.number = n; v.str = NULL; v.array = NULL; v.map = NULL; v.closure = NULL; return v;ashvm/src/value/H/hashmap.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef ASH_VM_HASHMAP_H #define ASH_VM_HASHMAP_H-#include "value/value.h"+#include "value/H/value.h" typedef struct { char *key;ashvm/src/value/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
ashvm/src/vm/C/api.cmodified
+3−3@@ -1,8 +1,8 @@ #include <stdio.h> #include <stdlib.h>-#include "vm/vm.h"-#include "vm/state.h"-#include "compiler/compiler.h"+#include "vm/H/vm.h"+#include "vm/H/state.h"+#include "compiler/H/compiler.h" void vm_set_repl_recovery(jmp_buf *jb) { repl_recovery_jmp = jb;ashvm/src/vm/C/chunk.cmodified
+1−1@@ -1,5 +1,5 @@ #include <stdlib.h>-#include "vm/chunk.h"+#include "vm/H/chunk.h" void chunk_init(Chunk *c) { c->count = 0; c->capacity = 0; c->code = NULL;ashvm/src/vm/C/dispatch.cmodified
+5−5@@ -3,11 +3,11 @@ #include <string.h> #include <setjmp.h> #include <math.h>-#include "vm/vm.h"-#include "vm/state.h"-#include "compiler/compiler.h"-#include "builtins/builtins.h"-#include "value/hashmap.h"+#include "vm/H/vm.h"+#include "vm/H/state.h"+#include "compiler/H/compiler.h"+#include "builtins/H/builtins.h"+#include "value/H/hashmap.h" // The dispatch loop stays one function despite exceeding this project's // usual 200-line target: computed-goto (`&&label` / `goto *table[i]`)ashvm/src/vm/C/errors.cmodified
+3−3@@ -1,9 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include <stdarg.h>-#include "vm/vm.h"-#include "vm/state.h"-#include "diagnostics/diagnostics.h"+#include "vm/H/vm.h"+#include "vm/H/state.h"+#include "diagnostics/H/diagnostics.h" // Every genuinely-runtime error (as opposed to a compile-time/structural one, // which stays a hard crash since ashvm resolves names at compile time) funnelsashvm/src/vm/C/state.cmodified
+1−1@@ -1,5 +1,5 @@ #include <stddef.h>-#include "vm/state.h"+#include "vm/H/state.h" VMValue stack[STACK_MAX]; VMValue *stack_top;ashvm/src/vm/H/chunk.hmodified
+1−1@@ -1,7 +1,7 @@ #ifndef ASH_VM_CHUNK_H #define ASH_VM_CHUNK_H #include <stdint.h>-#include "value/value.h"+#include "value/H/value.h" typedef enum { OP_CONST,ashvm/src/vm/H/state.hmodified
+1−1@@ -1,7 +1,7 @@ #ifndef ASH_VM_STATE_H #define ASH_VM_STATE_H #include <setjmp.h>-#include "vm/chunk.h"+#include "vm/H/chunk.h" // Internal VM state shared between vm_dispatch.c, vm_errors.c, and vm_api.c // -- not part of the public API (vm.h). Mirrors the sameashvm/src/vm/H/vm.hmodified
+1−1@@ -1,7 +1,7 @@ #ifndef ASH_VM_VM_H #define ASH_VM_VM_H #include <setjmp.h>-#include "vm/chunk.h"+#include "vm/H/chunk.h" void vm_run(Chunk *main_chunk); void vm_run_from(Chunk *chunk, int start_offset, int is_first_call);ashvm/src/vm/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
ashvm/tests/scripts/imports_circular_check.shmodified
+2−2@@ -1,8 +1,8 @@ #!/usr/bin/env bash set -uo pipefail-cd "$(dirname "$0")/.."+cd "$(dirname "$0")/../.." -OUT=$(../bin/ashvm tests/fixtures/imports_circular_a.ash 2>&1)+OUT=$(../bin/ashvm tests/cases/imports/fixtures/imports_circular_a.ash 2>&1) STATUS=$? if [[ $STATUS -eq 0 ]]; thenashvm/tests/scripts/imports_collision_check.shmodified
+2−2@@ -1,8 +1,8 @@ #!/usr/bin/env bash set -uo pipefail-cd "$(dirname "$0")/.."+cd "$(dirname "$0")/../.." -OUT=$(../bin/ashvm tests/fixtures/imports_collision_main.ash 2>&1)+OUT=$(../bin/ashvm tests/cases/imports/fixtures/imports_collision_main.ash 2>&1) STATUS=$? if [[ $STATUS -eq 0 ]]; thenashvm/tests/scripts/run_regression.shmodified
+7−7@@ -1,11 +1,11 @@ #!/usr/bin/env bash-# ashvm/tests/run_regression.sh baseline|check-# Compiles+runs every ashvm/tests/*.ash and diffs stdout against a-# captured baseline -- mirrors kiln/tests/run_regression.sh. ashvm has no+# ashvm/tests/scripts/run_regression.sh baseline|check+# Compiles+runs every ashvm/tests/cases/*/*.ash and diffs stdout against a+# captured baseline -- mirrors kiln/tests/scripts/run_regression.sh. ashvm has no # --target/--link flags and no input()-driven test today, so this is # simpler than kiln's version. set -uo pipefail-cd "$(dirname "$0")/.." # -> ashvm/+cd "$(dirname "$0")/../.." # -> ashvm/ MODE="${1:-check}" if [[ "$MODE" != "baseline" && "$MODE" != "check" ]]; then@@ -21,7 +21,7 @@ rm -f /tmp/ash_test.txt make -s || { echo "build failed"; exit 1; } -for f in tests/*.ash; do+for f in tests/cases/*/*.ash; do name=$(basename "$f" .ash) out="$OUTDIR/${name}.out" if ! ../bin/ashvm "$f" > "$out" 2>&1; then@@ -50,10 +50,10 @@ for f in "$OUTDIR"/*.out; do fail=1 fi done-if ! ./tests/imports_circular_check.sh; then+if ! ./tests/scripts/imports_circular_check.sh; then fail=1 fi-if ! ./tests/imports_collision_check.sh; then+if ! ./tests/scripts/imports_collision_check.sh; then fail=1 fi kiln/Makefilemodified
+85−23@@ -1,34 +1,96 @@ CC = gcc+.DEFAULT_GOAL := all+CFLAGS = -Wall -Wextra -std=c11 -O2 -Isrc+LDFLAGS =++KILN_SRC = \+ src/app/C/main.c \+ src/app/C/target.c \+ src/lexer/C/lexer.c \+ src/lexer/C/lexer_import.c \+ src/parser/C/core/parser.c \+ src/parser/C/declarations/constants.c \+ src/parser/C/declarations/functions.c \+ src/parser/C/declarations/vars.c \+ src/parser/C/imports/import_paths.c \+ src/parser/C/imports/imports.c \+ src/parser/C/statements/for_loop.c \+ src/parser/C/statements/loop_stack.c \+ src/parser/C/statements/parser_control.c \+ src/parser/C/statements/try_catch.c \+ src/codegen/C/builtins/builtins.c \+ src/codegen/C/builtins/filter_builtin.c \+ src/codegen/C/builtins/map_builtin.c \+ src/codegen/C/builtins/math_builtins.c \+ src/codegen/C/builtins/num_builtin.c \+ src/codegen/C/builtins/reduce_builtin.c \+ src/codegen/C/builtins/str_builtin.c \+ src/codegen/C/collections/arrays.c \+ src/codegen/C/collections/keys_values.c \+ src/codegen/C/collections/maps.c \+ src/codegen/C/collections/maps_mutate.c \+ src/codegen/C/emit/bytes.c \+ src/codegen/C/emit/emit.c \+ src/codegen/C/emit/emit_mem.c \+ src/codegen/C/emit/emit_sse.c \+ src/codegen/C/emit/layout.c \+ src/codegen/C/expressions/expr.c \+ src/codegen/C/expressions/expr_bool.c \+ src/codegen/C/expressions/expr_call.c \+ src/codegen/C/functions/closures.c \+ src/codegen/C/functions/lambda.c \+ src/codegen/C/io/argv_builtin.c \+ src/codegen/C/io/argv_builtin_windows.c \+ src/codegen/C/io/file_path.c \+ src/codegen/C/io/input_builtin.c \+ src/codegen/C/io/read_file_builtin.c \+ src/codegen/C/io/write_file_builtins.c \+ src/codegen/C/platform/platform_console.c \+ src/codegen/C/platform/platform_file.c \+ src/codegen/C/platform/win_call.c \+ src/codegen/C/platform/win_file_call.c \+ src/codegen/C/runtime/errors.c \+ src/codegen/C/runtime/heap.c \+ src/codegen/C/runtime/print_int.c \+ src/codegen/C/strings/case_builtins.c \+ src/codegen/C/strings/indexof_builtin.c \+ src/codegen/C/strings/join_builtin.c \+ src/codegen/C/strings/replace_builtin.c \+ src/codegen/C/strings/split_builtin.c \+ src/codegen/C/strings/string_alloc.c \+ src/codegen/C/strings/strings.c \+ src/codegen/C/strings/substring_builtin.c \+ src/codegen/C/strings/trim_builtin.c \+ src/elf/C/elf_dynamic.c \+ src/elf/C/elf_dynamic_call.c \+ src/elf/C/elf_so_writer.c \+ src/elf/C/elf_writer.c \+ src/pe/C/pe_dll_writer.c \+ src/pe/C/pe_dynamic.c \+ src/pe/C/pe_writer.c \+ src/diagnostics/C/diagnostics.c++# Objects and dependency files live in trees parallel to each C tree:+# src/<subsystem>/C/<feature>/x.c -> src/<subsystem>/O/<feature>/x.o+# src/<subsystem>/D/<feature>/x.d+obj_of = $(patsubst %.c,%.o,$(subst /C/,/O/,$(1)))+dep_of = $(patsubst %.c,%.d,$(subst /C/,/D/,$(1)))+KILN_OBJ = $(foreach s,$(KILN_SRC),$(call obj_of,$(s)))+KILN_DEP = $(foreach s,$(KILN_SRC),$(call dep_of,$(s)))+ # -MMD -MP: emit a per-object .d file listing the headers it includes, so # editing a shared header (e.g. vars.h) correctly triggers a rebuild of # every .o that includes it, not just files whose own .c changed. Without # this, make's only dependency is "the .c is newer than the .o" -- a # header-only edit silently produces a binary built from mismatched # offsets/constants across files, with no error, until something crashes # at runtime for reasons the source doesn't explain.-CFLAGS = -Wall -Wextra -std=c11 -O2 -Isrc -MMD -MP-LDFLAGS =--KILN_SRC = src/main.c src/target.c src/lexer/lexer.c src/lexer/lexer_import.c \- src/parser/parser.c src/parser/parser_control.c src/parser/vars.c src/parser/functions.c src/parser/try_catch.c src/parser/for_loop.c src/parser/loop_stack.c \- src/parser/import_paths.c src/parser/imports.c src/parser/constants.c \- src/codegen/emit.c src/codegen/emit_mem.c src/codegen/emit_sse.c src/codegen/heap.c src/codegen/bytes.c src/codegen/layout.c \- src/codegen/strings.c src/codegen/errors.c src/codegen/arrays.c src/codegen/maps.c src/codegen/maps_mutate.c src/codegen/builtins.c \- src/codegen/math_builtins.c src/codegen/str_builtin.c src/codegen/num_builtin.c \- src/codegen/map_builtin.c src/codegen/filter_builtin.c src/codegen/reduce_builtin.c src/codegen/keys_values.c \- src/codegen/string_alloc.c src/codegen/case_builtins.c src/codegen/trim_builtin.c \- src/codegen/substring_builtin.c src/codegen/indexof_builtin.c \- src/codegen/join_builtin.c src/codegen/split_builtin.c src/codegen/replace_builtin.c \- src/codegen/file_path.c src/codegen/read_file_builtin.c src/codegen/write_file_builtins.c \- src/codegen/input_builtin.c src/codegen/argv_builtin.c src/codegen/argv_builtin_windows.c \- src/codegen/expr.c src/codegen/expr_call.c src/codegen/expr_bool.c src/codegen/print_int.c \- src/codegen/closures.c src/codegen/lambda.c src/codegen/win_call.c src/codegen/win_file_call.c \- src/codegen/platform_console.c src/codegen/platform_file.c \- src/elf/elf_writer.c src/elf/elf_dynamic.c src/elf/elf_dynamic_call.c src/elf/elf_so_writer.c \- src/pe/pe_writer.c src/pe/pe_dynamic.c src/pe/pe_dll_writer.c \- src/diagnostics/diagnostics.c-KILN_OBJ = $(KILN_SRC:.c=.o)-KILN_DEP = $(KILN_SRC:.c=.d)+define compile_rule+$(call obj_of,$(1)): $(1)+ @mkdir -p $$(dir $$@) $$(dir $(call dep_of,$(1)))+ $$(CC) $$(CFLAGS) -MMD -MP -MF $(call dep_of,$(1)) -MT $$@ -c $$< -o $$@+endef+$(foreach s,$(KILN_SRC),$(eval $(call compile_rule,$(s)))) BIN = ../bin/kiln kiln/README.mdmodified
+24−13@@ -19,7 +19,7 @@ standalone, freestanding ELF64 executable - no libc, raw syscalls only. ```bash cd kiln && make # builds ../bin/kiln-../bin/kiln tests/hello.ash -o /tmp/hello+../bin/kiln tests/cases/basics/hello.ash -o /tmp/hello /tmp/hello # prints 7 (1 + 2 * 3) ``` @@ -40,16 +40,27 @@ cd kiln && make # builds ../bin/kiln ``` kiln/- Makefile builds ../bin/kiln- src/- lexer/ tokenizer (own copy, same shape as ashvm's)- parser/ token state + statement grammar- codegen/- emit.c/.h raw x86-64 instruction encoding primitives- expr.c/.h expression -> real arithmetic instructions- print_int.c/.h int-to-decimal-ASCII + write(2) + exit(2)- elf/- elf_writer.c/.h minimal "tiny ELF" executable writer- main.c argv parsing, drives the pipeline- tests/ *.ash programs exercised by hand for now+ Makefile builds ../bin/kiln+ src/ each subsystem: C/ (sources), H/ (headers), D/ (deps), O/ (objects), mirrored+ app/ main.c argv parsing, drives the pipeline; target.c/.h+ lexer/ tokenizer (own copy, same shape as ashvm's)+ parser/C/ H/ D/ O/+ core/ parser entry, shared parser state+ statements/ control flow, for loops, try/catch, loop stack+ declarations/ variables, functions, constants+ imports/ import resolution+ codegen/C/ H/ D/ O/ (same feature folders in each tree)+ emit/ raw x86-64 encoding, byte buffers, memory layout, value tags+ expressions/ expression -> arithmetic instructions, calls, booleans+ functions/ closures and lambdas+ runtime/ heap, runtime errors, int printing+ collections/ arrays, maps, keys/values+ strings/ string values, allocation, string builtins+ builtins/ builtin dispatch, math, map/filter/reduce, str/num+ io/ file, stdin and argv builtins+ platform/ console/file and Windows-call wrappers+ elf/ ELF executable and shared-object writers+ pe/ PE executable and DLL writers+ diagnostics/ error reporting+ tests/ cases/<feature>/*.ash programs (+ scripts/run_regression.sh) ```\ No newline at end of filekiln/src/app/C/main.cmodified
+10−10@@ -1,15 +1,15 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "parser/parser.h"-#include "codegen/emit.h"-#include "elf/elf_writer.h"-#include "elf/elf_dynamic.h"-#include "elf/elf_so_writer.h"-#include "pe/pe_writer.h"-#include "pe/pe_dll_writer.h"-#include "diagnostics/diagnostics.h"-#include "target.h"+#include "parser/H/core/parser.h"+#include "codegen/H/emit/emit.h"+#include "elf/H/elf_writer.h"+#include "elf/H/elf_dynamic.h"+#include "elf/H/elf_so_writer.h"+#include "pe/H/pe_writer.h"+#include "pe/H/pe_dll_writer.h"+#include "diagnostics/H/diagnostics.h"+#include "app/H/target.h" static char *read_file(const char *path) { FILE *file = fopen(path, "rb");@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) { // mode from compiling a program. if (argc >= 4 && argc <= 5 && strcmp(argv[1], "--emit-runtime") == 0 && strcmp(argv[2], "-o") == 0) { if (argc == 5) kiln_set_target(parse_target(argv[4], argv[0]));- // The runtime's own globals-address computation (codegen/layout.c)+ // The runtime's own globals-address computation (codegen/C/emit/layout.c) // needs to resolve as if for a --link=shared executable, since // that's whose globals this code reads/writes at runtime -- // elf_write_shared_runtime/pe_write_shared_runtime additionallykiln/src/app/C/target.cmodified
+1−1@@ -1,4 +1,4 @@-#include "target.h"+#include "app/H/target.h" static KilnTarget current_target = KILN_TARGET_LINUX; kiln/src/app/D/main.dadded
+21−0@@ -0,0 +1,21 @@+src/app/O/main.o: src/app/C/main.c src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h src/elf/H/elf_writer.h \+ src/codegen/H/emit/runtime_layout.h src/elf/H/elf_dynamic.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_so_writer.h \+ src/pe/H/pe_writer.h src/pe/H/pe_imports.def src/pe/H/pe_dll_writer.h \+ src/diagnostics/H/diagnostics.h src/app/H/target.h+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/elf/H/elf_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/elf/H/elf_dynamic.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/elf/H/elf_so_writer.h:+src/pe/H/pe_writer.h:+src/pe/H/pe_imports.def:+src/pe/H/pe_dll_writer.h:+src/diagnostics/H/diagnostics.h:+src/app/H/target.h:kiln/src/app/D/target.dadded
+2−0@@ -0,0 +1,2 @@+src/app/O/target.o: src/app/C/target.c src/app/H/target.h+src/app/H/target.h:kiln/src/app/H/target.hmodified
+2−2@@ -31,15 +31,15 @@ KilnLinkMode kiln_get_link_mode(void); // Separate from KilnLinkMode on purpose: link mode answers "should THIS // routine's own call sites (heap_emit_alloc etc.) reach their callee via-// a local call or a GOT call" -- but codegen/layout.c's globals-address+// a local call or a GOT call" -- but codegen/C/emit/layout.c's globals-address // selection needs to answer a DIFFERENT question, "which executable // layout owns the globals this code will read at runtime", and that // answer is the shared-mode layout in BOTH cases: when compiling a // normal --link=shared executable AND when compiling the runtime that // goes into libkilnrt.so (its heap_alloc etc. always run on behalf of // some shared-mode executable's globals, never its own). Conflating // these into one flag was a real bug caught by testing (see-// elf/elf_so_writer.c's comment) -- kiln_set_link_mode(STATIC) to get+// elf/C/elf_so_writer.c's comment) -- kiln_set_link_mode(STATIC) to get // local intra-.so calls also silently broke the globals address. void kiln_set_compiling_so(int flag); int kiln_is_compiling_so(void);kiln/src/app/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/C/builtins/builtins.cmodified
+13−13@@ -1,17 +1,17 @@ #include <string.h>-#include "codegen/builtins.h"-#include "codegen/expr.h"-#include "codegen/arrays.h"-#include "codegen/maps.h"-#include "codegen/math_builtins.h"-#include "codegen/convert_builtins.h"-#include "codegen/higher_order.h"-#include "codegen/keys_values.h"-#include "codegen/string_builtins.h"-#include "codegen/file_builtins.h"-#include "codegen/input_builtin.h"-#include "codegen/argv_builtin.h"-#include "parser/parser.h"+#include "codegen/H/builtins/builtins.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/collections/arrays.h"+#include "codegen/H/collections/maps.h"+#include "codegen/H/builtins/math_builtins.h"+#include "codegen/H/builtins/convert_builtins.h"+#include "codegen/H/builtins/higher_order.h"+#include "codegen/H/collections/keys_values.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/io/file_builtins.h"+#include "codegen/H/io/input_builtin.h"+#include "codegen/H/io/argv_builtin.h"+#include "parser/H/core/parser.h" int codegen_try_builtin_call(const char *name, int len) { if (len == 4 && strncmp(name, "argv", 4) == 0) {kiln/src/codegen/C/builtins/filter_builtin.cmodified
+9−9@@ -1,12 +1,12 @@-#include "codegen/higher_order.h"-#include "codegen/expr.h"-#include "codegen/closures.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/builtins/higher_order.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/functions/closures.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Scratch layout: [0]=fn_tag [8]=fn_payload [16]=data_ptr [24]=count // [32]=out_data_ptr [40]=i [48]=out_countkiln/src/codegen/C/builtins/map_builtin.cmodified
+8−8@@ -1,11 +1,11 @@-#include "codegen/higher_order.h"-#include "codegen/expr.h"-#include "codegen/closures.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/builtins/higher_order.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/functions/closures.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Scratch layout (see vars.h's higher_order_scratch_offset -- everything // needed after codegen_call_closure_value must live here, never in akiln/src/codegen/C/builtins/math_builtins.cmodified
+5−5@@ -1,8 +1,8 @@-#include "codegen/math_builtins.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "parser/parser.h"+#include "codegen/H/builtins/math_builtins.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h" void codegen_builtin_sqrt(void) { emit_pop_reg(code, REG_RAX); // payloadkiln/src/codegen/C/builtins/num_builtin.cmodified
+5−5@@ -1,9 +1,9 @@ #include <string.h>-#include "codegen/convert_builtins.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "parser/parser.h"+#include "codegen/H/builtins/convert_builtins.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h" static void load_double_const(XReg dst, double v) { uint64_t bits;kiln/src/codegen/C/builtins/reduce_builtin.cmodified
+6−6@@ -1,9 +1,9 @@-#include "codegen/higher_order.h"-#include "codegen/expr.h"-#include "codegen/closures.h"-#include "codegen/emit.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/builtins/higher_order.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/functions/closures.h"+#include "codegen/H/emit/emit.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Scratch layout: [0]=acc_tag [8]=acc_payload [16]=fn_tag [24]=fn_payload // [32]=data_ptr [40]=count [48]=ikiln/src/codegen/C/builtins/str_builtin.cmodified
+7−7@@ -1,11 +1,11 @@ #include <string.h>-#include "codegen/convert_builtins.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "codegen/bytes.h"-#include "parser/parser.h"+#include "codegen/H/builtins/convert_builtins.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/bytes.h"+#include "parser/H/core/parser.h" static void load_double_const(XReg dst, double v) { uint64_t bits;kiln/src/codegen/C/collections/arrays.cmodified
+9−9@@ -1,12 +1,12 @@-#include "codegen/arrays.h"-#include "codegen/expr.h"-#include "codegen/emit_internal.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "codegen/bytes.h"-#include "codegen/errors.h"-#include "parser/parser.h"+#include "codegen/H/collections/arrays.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/emit_internal.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/runtime/errors.h"+#include "parser/H/core/parser.h" void codegen_array_literal(void) { advance_token(); // consume '['kiln/src/codegen/C/collections/keys_values.cmodified
+7−7@@ -1,14 +1,14 @@-#include "codegen/keys_values.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/collections/keys_values.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // This implementation's map (unlike ashvm's capacity-sized hash table // with scattered "used" flags) keeps every live entry packed into // [0, count) -- delete() swaps the last entry into a removed slot rather-// than leaving a hole (see codegen/maps_mutate.c) -- so both builtins+// than leaving a hole (see codegen/C/collections/maps_mutate.c) -- so both builtins // below can just iterate 0..count directly, no "used" check needed. // // Scratch layout: [0]=count [8]=entries_ptr [16]=out_block [24]=ikiln/src/codegen/C/collections/maps.cmodified
+9−9@@ -1,12 +1,12 @@-#include "codegen/maps.h"-#include "codegen/maps_internal.h"-#include "codegen/expr.h"-#include "codegen/strings.h"-#include "codegen/emit_internal.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "codegen/errors.h"-#include "parser/parser.h"+#include "codegen/H/collections/maps.h"+#include "codegen/H/collections/maps_internal.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/strings/strings.h"+#include "codegen/H/emit/emit_internal.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/runtime/errors.h"+#include "parser/H/core/parser.h" void codegen_map_literal(void) { advance_token(); // consume '{'kiln/src/codegen/C/collections/maps_mutate.cmodified
+8−8@@ -1,10 +1,10 @@-#include "codegen/maps.h"-#include "codegen/maps_internal.h"-#include "codegen/emit_internal.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "codegen/bytes.h"-#include "parser/parser.h"+#include "codegen/H/collections/maps.h"+#include "codegen/H/collections/maps_internal.h"+#include "codegen/H/emit/emit_internal.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/bytes.h"+#include "parser/H/core/parser.h" static void push_number_local(double v) { uint64_t bits;@@ -17,7 +17,7 @@ static void push_number_local(double v) { // Scratch layout (base recomputed via `mov reg,rsp` after any call that // might have clobbered whichever register held it -- same technique-// codegen/arrays.c's codegen_builtin_push uses): [0]=val_tag+// codegen/C/collections/arrays.c's codegen_builtin_push uses): [0]=val_tag // [8]=val_payload [16]=key_payload [24]=map_object [32]=new_capacity // (grow path only) [40]=new_entries_block (grow path only) void codegen_map_index_store(void) {kiln/src/codegen/C/emit/bytes.cmodified
+5−5@@ -1,11 +1,11 @@-#include "codegen/bytes.h"-#include "codegen/win_call.h"-#include "elf/elf_dynamic_call.h"-#include "target.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/platform/win_call.h"+#include "elf/H/elf_dynamic_call.h"+#include "app/H/target.h" // Plan B, phase B1: emitted once (jumped over), called via emit_call_back // from all 18 call sites instead of each re-emitting this loop inline ---// same pattern as codegen/heap.c's alloc routine. Phase B3/B4: skipped+// same pattern as codegen/C/runtime/heap.c's alloc routine. Phase B3/B4: skipped // entirely under --link=shared (this routine lives in libkilnrt.so/.dll // instead, emitted by the separate "compile the runtime" driver via // bytes_emit_copy_routine_only), and bytes_emit_copy becomes a callkiln/src/codegen/C/emit/emit.cmodified
+1−1@@ -1,6 +1,6 @@ #include <stdlib.h> #include <string.h>-#include "codegen/emit_internal.h"+#include "codegen/H/emit/emit_internal.h" void code_init(CodeBuf *buf) { buf->code = NULL;kiln/src/codegen/C/emit/emit_mem.cmodified
+1−1@@ -1,5 +1,5 @@ #include <string.h>-#include "codegen/emit_internal.h"+#include "codegen/H/emit/emit_internal.h" void emit_store_mem_disp32(CodeBuf *buf, Reg base, int32_t disp, Reg src) { emit_byte(buf, REX_W);kiln/src/codegen/C/emit/emit_sse.cmodified
+2−2@@ -1,5 +1,5 @@-#include "codegen/emit_sse.h"-#include "codegen/emit_internal.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/emit_internal.h" // ModRM for two xmm operands (or GP<->xmm), register-direct -- same // mod=11 shape modrm_reg() builds, xmm register numbers 0-7 encodekiln/src/codegen/C/emit/layout.cmodified
+6−6@@ -1,9 +1,9 @@-#include "codegen/layout.h"-#include "target.h"-#include "elf/elf_writer.h"-#include "elf/elf_dynamic.h"-#include "pe/pe_writer.h"-#include "pe/pe_dll_writer.h"+#include "codegen/H/emit/layout.h"+#include "app/H/target.h"+#include "elf/H/elf_writer.h"+#include "elf/H/elf_dynamic.h"+#include "pe/H/pe_writer.h"+#include "pe/H/pe_dll_writer.h" static int is_linux_shared(void) { return kiln_get_target() == KILN_TARGET_LINUX && kiln_get_link_mode() == KILN_LINK_SHARED;kiln/src/codegen/C/expressions/expr.cmodified
+16−16@@ -1,20 +1,20 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "codegen/expr.h"-#include "codegen/expr_internal.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/strings.h"-#include "codegen/arrays.h"-#include "codegen/maps.h"-#include "codegen/builtins.h"-#include "codegen/closures.h"-#include "parser/parser.h"-#include "parser/vars.h"-#include "parser/functions.h"-#include "parser/constants.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/expressions/expr_internal.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/strings/strings.h"+#include "codegen/H/collections/arrays.h"+#include "codegen/H/collections/maps.h"+#include "codegen/H/builtins/builtins.h"+#include "codegen/H/functions/closures.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h"+#include "parser/H/declarations/functions.h"+#include "parser/H/declarations/constants.h" // Precedence climbing: expression -> logical_or -> logical_and -> // comparison -> additive -> term -> unary -> postfix -> primary@@ -23,7 +23,7 @@ // one (tag, payload) pair onto the real CPU stack -- tag first (deeper), // payload second (on top), so popping retrieves payload then tag. //-// Milestone 5: a value can now be a number OR a string (codegen/value.h),+// Milestone 5: a value can now be a number OR a string (codegen/H/emit/value.h), // so both halves travel generically via GP registers (raw bit-copying // doesn't care what the bits mean). XMM registers only ever hold the // payload transiently, at the point of actually doing floating-point@@ -131,7 +131,7 @@ static void primary(void) { } // Not a variable -- fall back to a bare named-function reference // used as a value (not immediately called), wrapped as a- // zero-capture closure (see codegen/closures.c).+ // zero-capture closure (see codegen/C/functions/closures.c). KilnFunction *fn = resolve_function_in_context(id.start, id.length); if (fn != NULL) { codegen_named_function_value(fn);kiln/src/codegen/C/expressions/expr_bool.cmodified
+8−8@@ -1,11 +1,11 @@ #include <string.h>-#include "codegen/expr.h"-#include "codegen/expr_internal.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/strings.h"-#include "parser/parser.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/expressions/expr_internal.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/strings/strings.h"+#include "parser/H/core/parser.h" // Precedence climbing continued from expr.c: comparison -> logical_and -> // logical_or -> expression. See expr.c's header comment for the full@@ -29,7 +29,7 @@ static void push_number_literal(double v) { // Turns "condition true/false" (as of the last ucomisd) into a clean // pushed 0.0/1.0, via the same jcc-and-patch technique-// codegen/print_int.c already uses for its digit loop -- just applied to+// codegen/C/runtime/print_int.c already uses for its digit loop -- just applied to // a general boolean result instead of a hardcoded loop exit. `cc_if_true` // must be one of ucomisd's unsigned-style condition codes (COND_B/BE/A/AE // or COND_E/NE), never the signed integer ones.kiln/src/codegen/C/expressions/expr_call.cmodified
+7−7@@ -1,11 +1,11 @@ #include <stdio.h>-#include "codegen/expr.h"-#include "codegen/emit.h"-#include "codegen/builtins.h"-#include "codegen/closures.h"-#include "parser/parser.h"-#include "parser/functions.h"-#include "parser/vars.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/builtins/builtins.h"+#include "codegen/H/functions/closures.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/functions.h"+#include "parser/H/declarations/vars.h" // Call codegen -- its own file since it's used from two places // (expr.c's primary(), for calls used as expressions, and parser.c'skiln/src/codegen/C/functions/closures.cmodified
+9−9@@ -1,12 +1,12 @@-#include "codegen/closures.h"-#include "codegen/closures_internal.h"-#include "codegen/emit.h"-#include "codegen/expr.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "codegen/layout.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/functions/closures.h"+#include "codegen/H/functions/closures_internal.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/layout.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Closure-object creation and the two ways a TAG_FUNCTION value gets // built (a lambda literal's runtime header, and a zero-capture wrapperkiln/src/codegen/C/functions/lambda.cmodified
+12−12@@ -1,16 +1,16 @@ #include <string.h>-#include "codegen/closures.h"-#include "codegen/closures_internal.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "codegen/expr.h"-#include "codegen/layout.h"-#include "parser/parser.h"-#include "parser/parser_internal.h"-#include "parser/vars.h"-#include "parser/functions.h"-#include "parser/for_loop.h"-#include "parser/loop_stack.h"+#include "codegen/H/functions/closures.h"+#include "codegen/H/functions/closures_internal.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/layout.h"+#include "parser/H/core/parser.h"+#include "parser/H/core/parser_internal.h"+#include "parser/H/declarations/vars.h"+#include "parser/H/declarations/functions.h"+#include "parser/H/statements/for_loop.h"+#include "parser/H/statements/loop_stack.h" // `fn (params) { body }` as an expression. The closure-object creation // code (which runs in the OUTER frame, snapshotting captures by value)kiln/src/codegen/C/io/argv_builtin.cmodified
+10−10@@ -1,14 +1,14 @@ #include <stdint.h>-#include "codegen/argv_builtin.h"-#include "codegen/argv_builtin_internal.h"-#include "codegen/string_alloc.h"-#include "codegen/bytes.h"-#include "codegen/heap.h"-#include "codegen/value.h"-#include "elf/elf_writer.h"-#include "parser/parser.h"-#include "parser/vars.h"-#include "target.h"+#include "codegen/H/io/argv_builtin.h"+#include "codegen/H/io/argv_builtin_internal.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/value.h"+#include "elf/H/elf_writer.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h"+#include "app/H/target.h" static void codegen_builtin_argv_linux(void); kiln/src/codegen/C/io/argv_builtin_windows.cmodified
+8−8@@ -1,12 +1,12 @@ #include <stdint.h>-#include "codegen/argv_builtin_internal.h"-#include "codegen/string_alloc.h"-#include "codegen/bytes.h"-#include "codegen/heap.h"-#include "codegen/value.h"-#include "codegen/win_call.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/io/argv_builtin_internal.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/platform/win_call.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // GetCommandLineA() returns the whole command line as one string (e.g. // `prog.exe arg1 arg2`), not a pre-split argv array -- so unlike thekiln/src/codegen/C/io/file_path.cmodified
+4−4@@ -1,8 +1,8 @@ #include <stdint.h>-#include "codegen/file_path.h"-#include "codegen/bytes.h"-#include "codegen/heap.h"-#include "parser/vars.h"+#include "codegen/H/io/file_path.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/runtime/heap.h"+#include "parser/H/declarations/vars.h" void filepath_emit_nullterm(CodeBuf *code) { int32_t base = higher_order_scratch_offset();kiln/src/codegen/C/io/input_builtin.cmodified
+8−8@@ -1,12 +1,12 @@ #include <stdint.h>-#include "codegen/input_builtin.h"-#include "codegen/string_alloc.h"-#include "codegen/bytes.h"-#include "codegen/heap.h"-#include "codegen/value.h"-#include "codegen/platform_console.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/io/input_builtin.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/platform/platform_console.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Reads one line from stdin (matching ashvm's fgets(buf,1024,stdin) + // trailing-newline-strip): a fixed 1024-byte cap, same as ashvm's ownkiln/src/codegen/C/io/read_file_builtin.cmodified
+8−8@@ -1,12 +1,12 @@ #include <stdint.h>-#include "codegen/file_builtins.h"-#include "codegen/file_path.h"-#include "codegen/string_alloc.h"-#include "codegen/errors.h"-#include "codegen/value.h"-#include "codegen/platform_file.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/io/file_builtins.h"+#include "codegen/H/io/file_path.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/runtime/errors.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/platform/platform_file.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // A single read() call is assumed to fill the whole file in one go (matches // ashvm's own single fread call, not a retry loop) -- reasonable forkiln/src/codegen/C/io/write_file_builtins.cmodified
+8−8@@ -1,12 +1,12 @@ #include <stdint.h>-#include "codegen/file_builtins.h"-#include "codegen/file_path.h"-#include "codegen/expr.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/platform_file.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/io/file_builtins.h"+#include "codegen/H/io/file_path.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/platform/platform_file.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" static void push_number(double v) { emit_mov_reg_imm64(code, REG_RBX, TAG_NUMBER);kiln/src/codegen/C/platform/platform_console.cmodified
+5−5@@ -1,8 +1,8 @@-#include "codegen/platform_console.h"-#include "codegen/win_call.h"-#include "codegen/win_file_call.h"-#include "parser/vars.h"-#include "target.h"+#include "codegen/H/platform/platform_console.h"+#include "codegen/H/platform/win_call.h"+#include "codegen/H/platform/win_file_call.h"+#include "parser/H/declarations/vars.h"+#include "app/H/target.h" #define STD_INPUT_HANDLE ((uint64_t)(int64_t)-10) #define STD_OUTPUT_HANDLE ((uint64_t)(int64_t)-11)kiln/src/codegen/C/platform/platform_file.cmodified
+4−4@@ -1,7 +1,7 @@-#include "codegen/platform_file.h"-#include "codegen/win_call.h"-#include "codegen/win_file_call.h"-#include "target.h"+#include "codegen/H/platform/platform_file.h"+#include "codegen/H/platform/win_call.h"+#include "codegen/H/platform/win_file_call.h"+#include "app/H/target.h" #define GENERIC_READ 0x80000000u #define GENERIC_WRITE 0x40000000ukiln/src/codegen/C/platform/win_call.cmodified
+6−6@@ -1,7 +1,7 @@-#include "codegen/win_call.h"-#include "codegen/emit_internal.h"-#include "codegen/layout.h"-#include "parser/vars.h"+#include "codegen/H/platform/win_call.h"+#include "codegen/H/emit/emit_internal.h"+#include "codegen/H/emit/layout.h"+#include "parser/H/declarations/vars.h" // AND RSP, imm8 (sign-extended) -- opcode 0x83 /4. Nothing else in kiln // needs a register-immediate AND, so this stays local instead of joining@@ -94,8 +94,8 @@ void win_call_end(CodeBuf *code) { // Windows API, needs the full shadow-space dance above), libkilnrt.dll's // exports are kiln's OWN code using kiln's OWN simple per-routine // register conventions (RAX/RBX/RDI/RDX depending on which routine, see-// codegen/heap.c etc.) -- exactly like the Linux GOT call-// (elf/elf_dynamic_call.c's emit_call_abs32), no register is safe to+// codegen/C/runtime/heap.c etc.) -- exactly like the Linux GOT call+// (elf/C/elf_dynamic_call.c's emit_call_abs32), no register is safe to // clobber loading the IAT address first. Can't reuse emit_call_abs32's // technique directly, though: kiln's PE image base (0x140000000) is // already past the 32-bit absolute-displacement addressing mode'skiln/src/codegen/C/platform/win_file_call.cmodified
+3−3@@ -1,6 +1,6 @@-#include "codegen/win_file_call.h"-#include "codegen/win_call.h"-#include "parser/vars.h"+#include "codegen/H/platform/win_file_call.h"+#include "codegen/H/platform/win_call.h"+#include "parser/H/declarations/vars.h" // &ignored_out needs to be a real writable address (Windows doesn't // accept NULL there for synchronous handles), so it points at akiln/src/codegen/C/runtime/errors.cmodified
+11−11@@ -1,13 +1,13 @@ #include <string.h>-#include "codegen/errors.h"-#include "codegen/emit_internal.h"-#include "codegen/value.h"-#include "codegen/layout.h"-#include "codegen/runtime_layout.h"-#include "codegen/platform_console.h"-#include "codegen/win_call.h"-#include "elf/elf_dynamic_call.h"-#include "target.h"+#include "codegen/H/runtime/errors.h"+#include "codegen/H/emit/emit_internal.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/emit/layout.h"+#include "codegen/H/emit/runtime_layout.h"+#include "codegen/H/platform/platform_console.h"+#include "codegen/H/platform/win_call.h"+#include "elf/H/elf_dynamic_call.h"+#include "app/H/target.h" static int raise_routine_offset = -1; @@ -16,7 +16,7 @@ static int is_shared(void) { } // Embeds `msg` as a proper length-prefixed string (jumped over, never-// executed as instructions) -- the SAME layout codegen/strings.c's+// executed as instructions) -- the SAME layout codegen/C/strings/strings.c's // literals use ([payload-8]=length, no trailing newline in the data // itself), since milestone 9 makes a caught error a real, usable // TAG_STRING value (print/concat/equality all assume this layout). This@@ -131,7 +131,7 @@ void errors_emit_die(CodeBuf *code, const char *msg) { // The ONE case that must never be "catchable" (exceeding // MAX_KILN_TRY_DEPTH itself -- silently continuing there would mean // pushing a handler past the fixed table, corrupting the adjacent code-// segment). Only ever called from one site (parser/try_catch.c), so+// segment). Only ever called from one site (parser/C/statements/try_catch.c), so // there's no deduplication payoff in routing it through the shared // runtime at all -- it just emits its own small inline write+exit // sequence directly, in every link mode, decoupled from wherever RAISEkiln/src/codegen/C/runtime/heap.cmodified
+6−6@@ -1,8 +1,8 @@-#include "codegen/heap.h"-#include "codegen/layout.h"-#include "codegen/win_call.h"-#include "elf/elf_dynamic_call.h"-#include "target.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/layout.h"+#include "codegen/H/platform/win_call.h"+#include "elf/H/elf_dynamic_call.h"+#include "app/H/target.h" #define HEAP_SIZE (16 * 1024 * 1024) #define MEM_COMMIT_RESERVE 0x3000u // MEM_COMMIT(0x1000) | MEM_RESERVE(0x2000)@@ -30,7 +30,7 @@ static void emit_alloc_routine(CodeBuf *code) { } // Called by the dedicated "compile the runtime" driver (see-// elf/elf_so_writer.c) to emit this routine into libkilnrt.so's OWN code+// elf/C/elf_so_writer.c) to emit this routine into libkilnrt.so's OWN code // buffer, completely separate from any executable's compile_program. void heap_emit_alloc_routine_only(CodeBuf *code) { emit_alloc_routine(code);kiln/src/codegen/C/runtime/print_int.cmodified
+13−13@@ -1,17 +1,17 @@ #include <string.h>-#include "codegen/print_int.h"-#include "codegen/emit_internal.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/layout.h"-#include "codegen/win_call.h"-#include "codegen/platform_console.h"-#include "elf/elf_dynamic_call.h"-#include "target.h"+#include "codegen/H/runtime/print_int.h"+#include "codegen/H/emit/emit_internal.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/emit/layout.h"+#include "codegen/H/platform/win_call.h"+#include "codegen/H/platform/platform_console.h"+#include "elf/H/elf_dynamic_call.h"+#include "app/H/target.h" // Loads a compile-time-known double literal into an xmm register, via a // GP register holding its raw IEEE-754 bit pattern -- same technique-// codegen/expr.c uses for user-written number literals (there's no "mov+// codegen/C/expressions/expr.c uses for user-written number literals (there's no "mov // xmm, imm64" instruction). static void load_double_const(CodeBuf *code, XReg dst, double v) { uint64_t bits;@@ -48,7 +48,7 @@ static void load_double_const(CodeBuf *code, XReg dst, double v) { // RBX=tag (NOT by popping them itself): a real CALL pushes a return // address on top of whatever the caller already pushed, so a `pop` here // would grab the return address instead of the caller's value -- same-// register-based-argument reasoning codegen/heap.c's alloc routine+// register-based-argument reasoning codegen/C/runtime/heap.c's alloc routine // already uses, not something print specifically needed before this // became a real subroutine. Each of its three paths (string/nil/number) // still balances its own RSP usage back to the entry value, which a real@@ -88,9 +88,9 @@ static void emit_print_routine(CodeBuf *code) { // Position-independent path: needed only for libkilnrt.so, whose // load address ld.so chooses at runtime. libkilnrt.dll (Windows) // is fixed-base like everything else kiln emits (see- // pe/pe_dll_writer.h), so kiln_code_base() already resolves+ // pe/H/pe_dll_writer.h), so kiln_code_base() already resolves // correctly there without RIP-relative addressing -- it now- // knows about DLL compilation specifically (see codegen/layout.c).+ // knows about DLL compilation specifically (see codegen/C/emit/layout.c). if (kiln_is_compiling_so() && kiln_get_target() == KILN_TARGET_LINUX) { emit_lea_rip_back(code, REG_RSI, data_offset); } else {kiln/src/codegen/C/strings/case_builtins.cmodified
+6−6@@ -1,14 +1,14 @@ #include <stdint.h>-#include "codegen/string_builtins.h"-#include "codegen/string_alloc.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "parser/parser.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h" // Shared shape for upper()/lower(): allocate a same-length copy, then a // byte-by-byte transform loop advancing two raw pointers (source cursor // in RSI, dest cursor in RDI) rather than indexing -- same technique-// codegen/closures.c's capture-copy loop uses, avoiding any need for a+// codegen/C/functions/closures.c's capture-copy loop uses, avoiding any need for a // scaled-index addressing mode this project's emitter doesn't support. static void case_transform(char lo, char hi, int8_t delta) { emit_pop_reg(code, REG_RAX); // src payloadkiln/src/codegen/C/strings/indexof_builtin.cmodified
+7−7@@ -1,10 +1,10 @@-#include "codegen/string_builtins.h"-#include "codegen/expr.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" static void push_number(double v) { emit_mov_reg_imm64(code, REG_RBX, TAG_NUMBER);kiln/src/codegen/C/strings/join_builtin.cmodified
+8−8@@ -1,11 +1,11 @@-#include "codegen/string_builtins.h"-#include "codegen/string_alloc.h"-#include "codegen/expr.h"-#include "codegen/bytes.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Two-pass: pass 1 sums each element's length (+ delim length between // consecutive elements) to get the exact output size; pass 2 allocateskiln/src/codegen/C/strings/replace_builtin.cmodified
+8−8@@ -1,12 +1,12 @@ #include <stdint.h>-#include "codegen/string_builtins.h"-#include "codegen/string_alloc.h"-#include "codegen/expr.h"-#include "codegen/bytes.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Scratch layout: [0]=s_ptr [8]=s_len [16]=search_ptr [24]=search_len // [32]=cur [40]=total_len/occurrences [48]=out_block [56]=cursorkiln/src/codegen/C/strings/split_builtin.cmodified
+9−9@@ -1,13 +1,13 @@ #include <stdint.h>-#include "codegen/string_builtins.h"-#include "codegen/string_alloc.h"-#include "codegen/expr.h"-#include "codegen/bytes.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "parser/parser.h"-#include "parser/vars.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "parser/H/core/parser.h"+#include "parser/H/declarations/vars.h" // Scratch layout: [0]=s_ptr [8]=s_len [16]=delim_ptr [24]=delim_len // [32]=cur [40]=count [48]=out_data_ptr [56]=out_indexkiln/src/codegen/C/strings/string_alloc.cmodified
+7−7@@ -1,12 +1,12 @@-#include "codegen/string_alloc.h"-#include "codegen/heap.h"-#include "codegen/win_call.h"-#include "elf/elf_dynamic_call.h"-#include "target.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/platform/win_call.h"+#include "elf/H/elf_dynamic_call.h"+#include "app/H/target.h" // Plan B, phase B1: emitted once (jumped over), called via emit_call_back-// from all 13 call sites -- same pattern as codegen/heap.c's alloc-// routine and codegen/bytes.c's copy routine (which this one itself+// from all 13 call sites -- same pattern as codegen/C/runtime/heap.c's alloc+// routine and codegen/C/emit/bytes.c's copy routine (which this one itself // calls, via heap_emit_alloc -- routines calling other routines nest // exactly like any other CALL/RET, no special handling needed). Note this // stays a LOCAL call even when compiling libkilnrt.so/.dll: the "compilekiln/src/codegen/C/strings/strings.cmodified
+11−11@@ -1,13 +1,13 @@-#include "codegen/strings.h"-#include "codegen/emit_internal.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "codegen/bytes.h"-#include "codegen/string_alloc.h"-#include "codegen/errors.h"-#include "codegen/layout.h"-#include "parser/parser.h"+#include "codegen/H/strings/strings.h"+#include "codegen/H/emit/emit_internal.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/runtime/errors.h"+#include "codegen/H/emit/layout.h"+#include "parser/H/core/parser.h" static void push_number_literal(double v) { uint64_t bits;@@ -60,7 +60,7 @@ void codegen_string_literal(void) { // Scratch layout (a stable base pointer copied from RSP into RSI, since // [rsp+disp] itself needs a SIB byte this project's encoders don't-// support -- same technique codegen/print_int.c uses):+// support -- same technique codegen/C/runtime/print_int.c uses): // [0]=a_payload [8]=b_payload [16]=length_a [24]=length_b [32]=new_block void codegen_string_concat(void) { emit_sub_reg_imm8(code, REG_RSP, 40);kiln/src/codegen/C/strings/substring_builtin.cmodified
+8−8@@ -1,11 +1,11 @@-#include "codegen/string_builtins.h"-#include "codegen/string_alloc.h"-#include "codegen/expr.h"-#include "codegen/bytes.h"-#include "codegen/emit.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "parser/parser.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h" // substring(str, start, end): clamps start>=0, end<=len, start>end->start=end // (matching ashvm's own clamping exactly, not erroring on out-of-range).kiln/src/codegen/C/strings/trim_builtin.cmodified
+6−6@@ -1,9 +1,9 @@-#include "codegen/string_builtins.h"-#include "codegen/string_alloc.h"-#include "codegen/bytes.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "parser/parser.h"+#include "codegen/H/strings/string_builtins.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "parser/H/core/parser.h" // Advances RSI forward past leading whitespace, then RDI backward past // trailing whitespace (RDI starts as the exclusive end pointer), each viakiln/src/codegen/D/builtins/builtins.dadded
+25−0@@ -0,0 +1,25 @@+src/codegen/O/builtins/builtins.o: src/codegen/C/builtins/builtins.c \+ src/codegen/H/builtins/builtins.h src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/collections/arrays.h \+ src/codegen/H/collections/maps.h src/codegen/H/builtins/math_builtins.h \+ src/codegen/H/builtins/convert_builtins.h \+ src/codegen/H/builtins/higher_order.h \+ src/codegen/H/collections/keys_values.h \+ src/codegen/H/strings/string_builtins.h src/codegen/H/io/file_builtins.h \+ src/codegen/H/io/input_builtin.h src/codegen/H/io/argv_builtin.h \+ src/parser/H/core/parser.h src/codegen/H/emit/emit.h+src/codegen/H/builtins/builtins.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/collections/arrays.h:+src/codegen/H/collections/maps.h:+src/codegen/H/builtins/math_builtins.h:+src/codegen/H/builtins/convert_builtins.h:+src/codegen/H/builtins/higher_order.h:+src/codegen/H/collections/keys_values.h:+src/codegen/H/strings/string_builtins.h:+src/codegen/H/io/file_builtins.h:+src/codegen/H/io/input_builtin.h:+src/codegen/H/io/argv_builtin.h:+src/parser/H/core/parser.h:+src/codegen/H/emit/emit.h:kiln/src/codegen/D/builtins/filter_builtin.dadded
+19−0@@ -0,0 +1,19 @@+src/codegen/O/builtins/filter_builtin.o: \+ src/codegen/C/builtins/filter_builtin.c \+ src/codegen/H/builtins/higher_order.h src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/functions/closures.h \+ src/parser/H/declarations/functions.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/codegen/H/runtime/heap.h src/parser/H/core/parser.h \+ src/parser/H/declarations/vars.h+src/codegen/H/builtins/higher_order.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/functions/closures.h:+src/parser/H/declarations/functions.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/builtins/map_builtin.dadded
+17−0@@ -0,0 +1,17 @@+src/codegen/O/builtins/map_builtin.o: \+ src/codegen/C/builtins/map_builtin.c \+ src/codegen/H/builtins/higher_order.h src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/functions/closures.h \+ src/parser/H/declarations/functions.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h+src/codegen/H/builtins/higher_order.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/functions/closures.h:+src/parser/H/declarations/functions.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/builtins/math_builtins.dadded
+11−0@@ -0,0 +1,11 @@+src/codegen/O/builtins/math_builtins.o: \+ src/codegen/C/builtins/math_builtins.c \+ src/codegen/H/builtins/math_builtins.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h+src/codegen/H/builtins/math_builtins.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:kiln/src/codegen/D/builtins/num_builtin.dadded
+11−0@@ -0,0 +1,11 @@+src/codegen/O/builtins/num_builtin.o: \+ src/codegen/C/builtins/num_builtin.c \+ src/codegen/H/builtins/convert_builtins.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h+src/codegen/H/builtins/convert_builtins.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:kiln/src/codegen/D/builtins/reduce_builtin.dadded
+14−0@@ -0,0 +1,14 @@+src/codegen/O/builtins/reduce_builtin.o: \+ src/codegen/C/builtins/reduce_builtin.c \+ src/codegen/H/builtins/higher_order.h src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/functions/closures.h \+ src/parser/H/declarations/functions.h src/codegen/H/emit/emit.h \+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h+src/codegen/H/builtins/higher_order.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/functions/closures.h:+src/parser/H/declarations/functions.h:+src/codegen/H/emit/emit.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/builtins/str_builtin.dadded
+14−0@@ -0,0 +1,14 @@+src/codegen/O/builtins/str_builtin.o: \+ src/codegen/C/builtins/str_builtin.c \+ src/codegen/H/builtins/convert_builtins.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/codegen/H/runtime/heap.h src/codegen/H/emit/bytes.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h+src/codegen/H/builtins/convert_builtins.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/bytes.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:kiln/src/codegen/D/collections/arrays.dadded
+18−0@@ -0,0 +1,18 @@+src/codegen/O/collections/arrays.o: src/codegen/C/collections/arrays.c \+ src/codegen/H/collections/arrays.h src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit_internal.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/emit_sse.h \+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \+ src/codegen/H/emit/bytes.h src/codegen/H/runtime/errors.h \+ src/parser/H/core/parser.h+src/codegen/H/collections/arrays.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/runtime/errors.h:+src/parser/H/core/parser.h:kiln/src/codegen/D/collections/keys_values.dadded
+13−0@@ -0,0 +1,13 @@+src/codegen/O/collections/keys_values.o: \+ src/codegen/C/collections/keys_values.c \+ src/codegen/H/collections/keys_values.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h \+ src/parser/H/declarations/vars.h+src/codegen/H/collections/keys_values.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/collections/maps.dadded
+19−0@@ -0,0 +1,19 @@+src/codegen/O/collections/maps.o: src/codegen/C/collections/maps.c \+ src/codegen/H/collections/maps.h \+ src/codegen/H/collections/maps_internal.h \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/strings/strings.h src/codegen/H/emit/emit_internal.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/value.h \+ src/codegen/H/runtime/heap.h src/codegen/H/runtime/errors.h \+ src/parser/H/core/parser.h+src/codegen/H/collections/maps.h:+src/codegen/H/collections/maps_internal.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/strings/strings.h:+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/runtime/errors.h:+src/parser/H/core/parser.h:kiln/src/codegen/D/collections/maps_mutate.dadded
+16−0@@ -0,0 +1,16 @@+src/codegen/O/collections/maps_mutate.o: \+ src/codegen/C/collections/maps_mutate.c src/codegen/H/collections/maps.h \+ src/codegen/H/collections/maps_internal.h \+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \+ src/codegen/H/emit/bytes.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h+src/codegen/H/collections/maps.h:+src/codegen/H/collections/maps_internal.h:+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/bytes.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:kiln/src/codegen/D/emit/bytes.dadded
+20−0@@ -0,0 +1,20 @@+src/codegen/O/emit/bytes.o: src/codegen/C/emit/bytes.c \+ src/codegen/H/emit/bytes.h src/codegen/H/emit/emit.h \+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \+ src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \+ src/elf/H/elf_writer.h src/app/H/target.h+src/codegen/H/emit/bytes.h:+src/codegen/H/emit/emit.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/elf/H/elf_dynamic_call.h:+src/elf/H/elf_dynamic.h:+src/elf/H/elf_writer.h:+src/app/H/target.h:kiln/src/codegen/D/emit/emit.dadded
+4−0@@ -0,0 +1,4 @@+src/codegen/O/emit/emit.o: src/codegen/C/emit/emit.c \+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit.h+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/emit.h:kiln/src/codegen/D/emit/emit_mem.dadded
+4−0@@ -0,0 +1,4 @@+src/codegen/O/emit/emit_mem.o: src/codegen/C/emit/emit_mem.c \+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit.h+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/emit.h:kiln/src/codegen/D/emit/emit_sse.dadded
+6−0@@ -0,0 +1,6 @@+src/codegen/O/emit/emit_sse.o: src/codegen/C/emit/emit_sse.c \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_internal.h+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_internal.h:kiln/src/codegen/D/emit/layout.dadded
+17−0@@ -0,0 +1,17 @@+src/codegen/O/emit/layout.o: src/codegen/C/emit/layout.c \+ src/codegen/H/emit/layout.h src/app/H/target.h src/elf/H/elf_writer.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \+ src/elf/H/elf_dynamic.h src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_writer.h \+ src/pe/H/pe_imports.def src/pe/H/pe_dll_writer.h+src/codegen/H/emit/layout.h:+src/app/H/target.h:+src/elf/H/elf_writer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_layout.h:+src/elf/H/elf_dynamic.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_writer.h:+src/pe/H/pe_imports.def:+src/pe/H/pe_dll_writer.h:kiln/src/codegen/D/expressions/expr.dadded
+24−0@@ -0,0 +1,24 @@+src/codegen/O/expressions/expr.o: src/codegen/C/expressions/expr.c \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/expressions/expr_internal.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/codegen/H/strings/strings.h src/codegen/H/collections/arrays.h \+ src/codegen/H/collections/maps.h src/codegen/H/builtins/builtins.h \+ src/codegen/H/functions/closures.h src/parser/H/declarations/functions.h \+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h \+ src/parser/H/declarations/constants.h+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/expressions/expr_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/strings/strings.h:+src/codegen/H/collections/arrays.h:+src/codegen/H/collections/maps.h:+src/codegen/H/builtins/builtins.h:+src/codegen/H/functions/closures.h:+src/parser/H/declarations/functions.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:+src/parser/H/declarations/constants.h:kiln/src/codegen/D/expressions/expr_bool.dadded
+14−0@@ -0,0 +1,14 @@+src/codegen/O/expressions/expr_bool.o: \+ src/codegen/C/expressions/expr_bool.c src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/expressions/expr_internal.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/emit_sse.h \+ src/codegen/H/emit/value.h src/codegen/H/strings/strings.h \+ src/parser/H/core/parser.h+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/expressions/expr_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/strings/strings.h:+src/parser/H/core/parser.h:kiln/src/codegen/D/expressions/expr_call.dadded
+14−0@@ -0,0 +1,14 @@+src/codegen/O/expressions/expr_call.o: \+ src/codegen/C/expressions/expr_call.c src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \+ src/codegen/H/builtins/builtins.h src/codegen/H/functions/closures.h \+ src/parser/H/declarations/functions.h src/parser/H/core/parser.h \+ src/parser/H/declarations/vars.h+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/builtins/builtins.h:+src/codegen/H/functions/closures.h:+src/parser/H/declarations/functions.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/functions/closures.dadded
+18−0@@ -0,0 +1,18 @@+src/codegen/O/functions/closures.o: src/codegen/C/functions/closures.c \+ src/codegen/H/functions/closures.h src/parser/H/declarations/functions.h \+ src/codegen/H/functions/closures_internal.h src/codegen/H/emit/emit.h \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \+ src/codegen/H/emit/layout.h src/parser/H/core/parser.h \+ src/parser/H/declarations/vars.h+src/codegen/H/functions/closures.h:+src/parser/H/declarations/functions.h:+src/codegen/H/functions/closures_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/layout.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/functions/lambda.dadded
+21−0@@ -0,0 +1,21 @@+src/codegen/O/functions/lambda.o: src/codegen/C/functions/lambda.c \+ src/codegen/H/functions/closures.h src/parser/H/declarations/functions.h \+ src/codegen/H/functions/closures_internal.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/value.h src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/emit/layout.h \+ src/parser/H/core/parser.h src/parser/H/core/parser_internal.h \+ src/parser/H/declarations/vars.h src/parser/H/statements/for_loop.h \+ src/parser/H/statements/loop_stack.h+src/codegen/H/functions/closures.h:+src/parser/H/declarations/functions.h:+src/codegen/H/functions/closures_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/value.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/layout.h:+src/parser/H/core/parser.h:+src/parser/H/core/parser_internal.h:+src/parser/H/declarations/vars.h:+src/parser/H/statements/for_loop.h:+src/parser/H/statements/loop_stack.h:kiln/src/codegen/D/io/argv_builtin.dadded
+20−0@@ -0,0 +1,20 @@+src/codegen/O/io/argv_builtin.o: src/codegen/C/io/argv_builtin.c \+ src/codegen/H/io/argv_builtin.h src/codegen/H/io/argv_builtin_internal.h \+ src/codegen/H/emit/emit.h src/codegen/H/strings/string_alloc.h \+ src/codegen/H/emit/bytes.h src/codegen/H/runtime/heap.h \+ src/codegen/H/emit/value.h src/elf/H/elf_writer.h \+ src/codegen/H/emit/runtime_layout.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/parser/H/declarations/vars.h src/app/H/target.h+src/codegen/H/io/argv_builtin.h:+src/codegen/H/io/argv_builtin_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/value.h:+src/elf/H/elf_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/parser/H/declarations/vars.h:+src/app/H/target.h:kiln/src/codegen/D/io/argv_builtin_windows.dadded
+26−0@@ -0,0 +1,26 @@+src/codegen/O/io/argv_builtin_windows.o: \+ src/codegen/C/io/argv_builtin_windows.c \+ src/codegen/H/io/argv_builtin_internal.h src/codegen/H/emit/emit.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/bytes.h \+ src/codegen/H/runtime/heap.h src/codegen/H/emit/value.h \+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \+ src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/parser/H/core/parser.h src/lexer/H/lexer.h \+ src/parser/H/declarations/vars.h+src/codegen/H/io/argv_builtin_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/value.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/io/file_path.dadded
+9−0@@ -0,0 +1,9 @@+src/codegen/O/io/file_path.o: src/codegen/C/io/file_path.c \+ src/codegen/H/io/file_path.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/bytes.h src/codegen/H/runtime/heap.h \+ src/parser/H/declarations/vars.h+src/codegen/H/io/file_path.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/runtime/heap.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/io/input_builtin.dadded
+16−0@@ -0,0 +1,16 @@+src/codegen/O/io/input_builtin.o: src/codegen/C/io/input_builtin.c \+ src/codegen/H/io/input_builtin.h src/codegen/H/strings/string_alloc.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/bytes.h \+ src/codegen/H/runtime/heap.h src/codegen/H/emit/value.h \+ src/codegen/H/platform/platform_console.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/parser/H/declarations/vars.h+src/codegen/H/io/input_builtin.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/value.h:+src/codegen/H/platform/platform_console.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/io/read_file_builtin.dadded
+17−0@@ -0,0 +1,17 @@+src/codegen/O/io/read_file_builtin.o: \+ src/codegen/C/io/read_file_builtin.c src/codegen/H/io/file_builtins.h \+ src/codegen/H/io/file_path.h src/codegen/H/emit/emit.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/runtime/errors.h \+ src/codegen/H/emit/value.h src/codegen/H/platform/platform_file.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h \+ src/parser/H/declarations/vars.h+src/codegen/H/io/file_builtins.h:+src/codegen/H/io/file_path.h:+src/codegen/H/emit/emit.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/runtime/errors.h:+src/codegen/H/emit/value.h:+src/codegen/H/platform/platform_file.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/io/write_file_builtins.dadded
+17−0@@ -0,0 +1,17 @@+src/codegen/O/io/write_file_builtins.o: \+ src/codegen/C/io/write_file_builtins.c src/codegen/H/io/file_builtins.h \+ src/codegen/H/io/file_path.h src/codegen/H/emit/emit.h \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/codegen/H/platform/platform_file.h src/parser/H/core/parser.h \+ src/parser/H/declarations/vars.h+src/codegen/H/io/file_builtins.h:+src/codegen/H/io/file_path.h:+src/codegen/H/emit/emit.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/platform/platform_file.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/platform/platform_console.dadded
+20−0@@ -0,0 +1,20 @@+src/codegen/O/platform/platform_console.o: \+ src/codegen/C/platform/platform_console.c \+ src/codegen/H/platform/platform_console.h src/codegen/H/emit/emit.h \+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \+ src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/codegen/H/platform/win_file_call.h src/parser/H/declarations/vars.h \+ src/app/H/target.h+src/codegen/H/platform/platform_console.h:+src/codegen/H/emit/emit.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/codegen/H/platform/win_file_call.h:+src/parser/H/declarations/vars.h:+src/app/H/target.h:kiln/src/codegen/D/platform/platform_file.dadded
+18−0@@ -0,0 +1,18 @@+src/codegen/O/platform/platform_file.o: \+ src/codegen/C/platform/platform_file.c \+ src/codegen/H/platform/platform_file.h src/codegen/H/emit/emit.h \+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \+ src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/codegen/H/platform/win_file_call.h src/app/H/target.h+src/codegen/H/platform/platform_file.h:+src/codegen/H/emit/emit.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/codegen/H/platform/win_file_call.h:+src/app/H/target.h:kiln/src/codegen/D/platform/win_call.dadded
+17−0@@ -0,0 +1,17 @@+src/codegen/O/platform/win_call.o: src/codegen/C/platform/win_call.c \+ src/codegen/H/platform/win_call.h src/codegen/H/emit/emit.h \+ src/pe/H/pe_writer.h src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/layout.h \+ src/parser/H/declarations/vars.h+src/codegen/H/platform/win_call.h:+src/codegen/H/emit/emit.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/layout.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/platform/win_file_call.dadded
+16−0@@ -0,0 +1,16 @@+src/codegen/O/platform/win_file_call.o: \+ src/codegen/C/platform/win_file_call.c \+ src/codegen/H/platform/win_file_call.h src/pe/H/pe_writer.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/codegen/H/platform/win_call.h src/parser/H/declarations/vars.h+src/codegen/H/platform/win_file_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/codegen/H/platform/win_call.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/runtime/errors.dadded
+26−0@@ -0,0 +1,26 @@+src/codegen/O/runtime/errors.o: src/codegen/C/runtime/errors.c \+ src/codegen/H/runtime/errors.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/value.h \+ src/codegen/H/emit/layout.h src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/platform/platform_console.h \+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \+ src/elf/H/elf_writer.h src/app/H/target.h+src/codegen/H/runtime/errors.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/value.h:+src/codegen/H/emit/layout.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/platform/platform_console.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/elf/H/elf_dynamic_call.h:+src/elf/H/elf_dynamic.h:+src/elf/H/elf_writer.h:+src/app/H/target.h:kiln/src/codegen/D/runtime/heap.dadded
+21−0@@ -0,0 +1,21 @@+src/codegen/O/runtime/heap.o: src/codegen/C/runtime/heap.c \+ src/codegen/H/runtime/heap.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/layout.h src/codegen/H/platform/win_call.h \+ src/pe/H/pe_writer.h src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \+ src/elf/H/elf_writer.h src/app/H/target.h+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/layout.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/elf/H/elf_dynamic_call.h:+src/elf/H/elf_dynamic.h:+src/elf/H/elf_writer.h:+src/app/H/target.h:kiln/src/codegen/D/runtime/print_int.dadded
+27−0@@ -0,0 +1,27 @@+src/codegen/O/runtime/print_int.o: src/codegen/C/runtime/print_int.c \+ src/codegen/H/runtime/print_int.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit_sse.h \+ src/codegen/H/emit/value.h src/codegen/H/emit/layout.h \+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \+ src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/codegen/H/platform/platform_console.h src/elf/H/elf_dynamic_call.h \+ src/elf/H/elf_dynamic.h src/elf/H/elf_writer.h src/app/H/target.h+src/codegen/H/runtime/print_int.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/emit/layout.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/codegen/H/platform/platform_console.h:+src/elf/H/elf_dynamic_call.h:+src/elf/H/elf_dynamic.h:+src/elf/H/elf_writer.h:+src/app/H/target.h:kiln/src/codegen/D/strings/case_builtins.dadded
+12−0@@ -0,0 +1,12 @@+src/codegen/O/strings/case_builtins.o: \+ src/codegen/C/strings/case_builtins.c \+ src/codegen/H/strings/string_builtins.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/value.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h+src/codegen/H/strings/string_builtins.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:kiln/src/codegen/D/strings/indexof_builtin.dadded
+14−0@@ -0,0 +1,14 @@+src/codegen/O/strings/indexof_builtin.o: \+ src/codegen/C/strings/indexof_builtin.c \+ src/codegen/H/strings/string_builtins.h src/codegen/H/expressions/expr.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h+src/codegen/H/strings/string_builtins.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/strings/join_builtin.dadded
+16−0@@ -0,0 +1,16 @@+src/codegen/O/strings/join_builtin.o: \+ src/codegen/C/strings/join_builtin.c \+ src/codegen/H/strings/string_builtins.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h+src/codegen/H/strings/string_builtins.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/strings/replace_builtin.dadded
+16−0@@ -0,0 +1,16 @@+src/codegen/O/strings/replace_builtin.o: \+ src/codegen/C/strings/replace_builtin.c \+ src/codegen/H/strings/string_builtins.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h+src/codegen/H/strings/string_builtins.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/strings/split_builtin.dadded
+18−0@@ -0,0 +1,18 @@+src/codegen/O/strings/split_builtin.o: \+ src/codegen/C/strings/split_builtin.c \+ src/codegen/H/strings/string_builtins.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \+ src/codegen/H/runtime/heap.h src/parser/H/core/parser.h \+ src/parser/H/declarations/vars.h+src/codegen/H/strings/string_builtins.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/parser/H/core/parser.h:+src/parser/H/declarations/vars.h:kiln/src/codegen/D/strings/string_alloc.dadded
+22−0@@ -0,0 +1,22 @@+src/codegen/O/strings/string_alloc.o: \+ src/codegen/C/strings/string_alloc.c \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \+ src/codegen/H/runtime/heap.h src/codegen/H/platform/win_call.h \+ src/pe/H/pe_writer.h src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \+ src/elf/H/elf_writer.h src/app/H/target.h+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/platform/win_call.h:+src/pe/H/pe_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/elf/H/elf_dynamic_call.h:+src/elf/H/elf_dynamic.h:+src/elf/H/elf_writer.h:+src/app/H/target.h:kiln/src/codegen/D/strings/strings.dadded
+19−0@@ -0,0 +1,19 @@+src/codegen/O/strings/strings.o: src/codegen/C/strings/strings.c \+ src/codegen/H/strings/strings.h src/codegen/H/emit/emit_internal.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/emit_sse.h \+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \+ src/codegen/H/emit/bytes.h src/codegen/H/strings/string_alloc.h \+ src/codegen/H/runtime/errors.h src/codegen/H/emit/layout.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h+src/codegen/H/strings/strings.h:+src/codegen/H/emit/emit_internal.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/runtime/errors.h:+src/codegen/H/emit/layout.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:kiln/src/codegen/D/strings/substring_builtin.dadded
+16−0@@ -0,0 +1,16 @@+src/codegen/O/strings/substring_builtin.o: \+ src/codegen/C/strings/substring_builtin.c \+ src/codegen/H/strings/string_builtins.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \+ src/codegen/H/emit/bytes.h src/codegen/H/emit/emit_sse.h \+ src/codegen/H/emit/value.h src/parser/H/core/parser.h+src/codegen/H/strings/string_builtins.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/expressions/expr.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:kiln/src/codegen/D/strings/trim_builtin.dadded
+13−0@@ -0,0 +1,13 @@+src/codegen/O/strings/trim_builtin.o: \+ src/codegen/C/strings/trim_builtin.c \+ src/codegen/H/strings/string_builtins.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h+src/codegen/H/strings/string_builtins.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/emit/value.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:kiln/src/codegen/H/builtins/convert_builtins.hmodified
+2−2@@ -1,12 +1,12 @@ #ifndef KILN_CONVERT_BUILTINS_H #define KILN_CONVERT_BUILTINS_H -// Assumes its one argument already pushed -- codegen/builtins.c's dispatch+// Assumes its one argument already pushed -- codegen/C/builtins/builtins.c's dispatch // calls these after parsing str(x)/num(x)'s argument. // str(number): formats into a heap-allocated, length-prefixed string // (same layout as any other TAG_STRING value) -- the exact same digit-// algorithm codegen/print_int.c uses (sign, integer part backward, up to+// algorithm codegen/C/runtime/print_int.c uses (sign, integer part backward, up to // 6 fraction digits with round-half-up and trailing-zero trim), just // targeting a heap block instead of a direct stdout write. Kept as its // own self-contained copy rather than sharing code with print_int.c'skiln/src/codegen/H/builtins/math_builtins.hmodified
+1−1@@ -1,7 +1,7 @@ #ifndef KILN_MATH_BUILTINS_H #define KILN_MATH_BUILTINS_H -// Each assumes its one NUMBER argument already pushed -- codegen/builtins.c's+// Each assumes its one NUMBER argument already pushed -- codegen/C/builtins/builtins.c's // dispatch calls these after parsing sqrt(x)/abs(x)/floor(x)'s argument. void codegen_builtin_sqrt(void); void codegen_builtin_abs(void);kiln/src/codegen/H/collections/arrays.hmodified
+2−2@@ -2,7 +2,7 @@ #define KILN_ARRAYS_H // primary()'s '[' handling: parses `[e0, e1, ...]`, allocates a heap-// block sized for exactly that many elements (see codegen/value.h for+// block sized for exactly that many elements (see codegen/H/emit/value.h for // the layout), and pushes (tag=TAG_ARRAY, payload=<block address>). void codegen_array_literal(void); @@ -17,7 +17,7 @@ void codegen_array_index_read(void); void codegen_array_index_store(void); // Both assume their arguments already pushed left-to-right (matching-// the normal call-argument convention) -- codegen/builtins.c's dispatch+// the normal call-argument convention) -- codegen/C/builtins/builtins.c's dispatch // calls these after parsing push(arr, val) / len(arr)'s arguments. // push(array, value): appends, growing (a fresh, bigger heap block pluskiln/src/codegen/H/collections/keys_values.hmodified
+1−1@@ -1,7 +1,7 @@ #ifndef KILN_KEYS_VALUES_H #define KILN_KEYS_VALUES_H -// Both assume their one MAP argument already pushed -- codegen/builtins.c's+// Both assume their one MAP argument already pushed -- codegen/C/builtins/builtins.c's // dispatch calls these after parsing keys(m)/values(m)'s argument. void codegen_builtin_keys(void); void codegen_builtin_values(void);kiln/src/codegen/H/collections/maps.hmodified
+1−1@@ -16,7 +16,7 @@ void codegen_map_index_read(void); // exists, otherwise appends a new entry (growing if needed). void codegen_map_index_store(void); -// Builtins, dispatched from codegen/builtins.c -- each assumes its+// Builtins, dispatched from codegen/C/builtins/builtins.c -- each assumes its // arguments already pushed left to right, matching the normal // call-argument convention. keys()/values() (each needs to build a new // ARRAY sized only-known-at-runtime, real extra complexity forkiln/src/codegen/H/emit/bytes.hmodified
+3−3@@ -1,6 +1,6 @@ #ifndef KILN_BYTES_H #define KILN_BYTES_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Emitted once, at program start (see parser.c's compile_program) -- // must run before any call to bytes_emit_copy below.@@ -13,8 +13,8 @@ int bytes_copy_routine_offset(void); // RDI=dest, RBX=src, RDX=count (input) -- clobbers RAX,RBX,RCX,RDX,RDI. // Deliberately doesn't touch RSI, so callers can keep a stable scratch-// pointer there across multiple calls. Shared between codegen/strings.c-// (concatenation) and codegen/arrays.c (growth). Plan B, phase B1: a real+// pointer there across multiple calls. Shared between codegen/C/strings/strings.c+// (concatenation) and codegen/C/collections/arrays.c (growth). Plan B, phase B1: a real // CALL to one shared copy (emitted by bytes_emit_startup) rather than // re-emitting this loop inline at each of its ~18 call sites. void bytes_emit_copy(CodeBuf *code);kiln/src/codegen/H/emit/emit.hmodified
+1−1@@ -77,7 +77,7 @@ void emit_load_mem_disp32(CodeBuf *buf, Reg dst, Reg base, int32_t disp); // Byte (8-bit) memory stores through a register-indirect address [reg] -- // `reg` must not be RSP/RBP (both need a SIB/disp encoding this module // deliberately doesn't support; callers route byte-buffer pointers through-// RCX instead, see codegen/print_int.c).+// RCX instead, see codegen/C/runtime/print_int.c). void emit_store_byte_imm(CodeBuf *buf, Reg base, uint8_t imm); void emit_store_byte_reg(CodeBuf *buf, Reg base, Reg src); // src must be RAX/RCX/RDX/RBX (low byte AL/CL/DL/BL) void emit_load_byte_reg(CodeBuf *buf, Reg dst, Reg base); // dst = zero-extended byte from [base] (MOVZX)kiln/src/codegen/H/emit/emit_internal.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef KILN_EMIT_INTERNAL_H #define KILN_EMIT_INTERNAL_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Shared byte-buffer primitives and ModRM builders, used by both emit.c // (register arithmetic) and emit_mem.c (memory/stack/jump instructions).kiln/src/codegen/H/emit/emit_sse.hmodified
+2−2@@ -1,6 +1,6 @@ #ifndef KILN_EMIT_SSE_H #define KILN_EMIT_SSE_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Scalar double-precision (SSE2) primitives -- milestone 4 replaces // kiln's integer-only numbers with real doubles throughout, matching@@ -12,7 +12,7 @@ typedef enum { XMM0 = 0, XMM1 = 1, XMM2 = 2, XMM3 = 3 } XReg; void emit_movq_xmm_from_reg(CodeBuf *buf, XReg dst, Reg src); // MOVQ xmm, r64 -- loads a GP register's raw 64 bits as a double's bit pattern (used for literals: the literal's IEEE-754 bits are computed once in kiln itself, at compile time)-void emit_movq_reg_from_xmm(CodeBuf *buf, Reg dst, XReg src); // MOVQ r64, xmm -- the reverse: extracts a computed double's raw bits into a GP register, milestone 5's generic (tag, payload) values are always GP-transported (see codegen/value.h), so an arithmetic result has to come back out of XMM before it can be pushed+void emit_movq_reg_from_xmm(CodeBuf *buf, Reg dst, XReg src); // MOVQ r64, xmm -- the reverse: extracts a computed double's raw bits into a GP register, milestone 5's generic (tag, payload) values are always GP-transported (see codegen/H/emit/value.h), so an arithmetic result has to come back out of XMM before it can be pushed void emit_movsd_xmm_xmm(CodeBuf *buf, XReg dst, XReg src); void emit_movsd_load_disp32(CodeBuf *buf, XReg dst, Reg base, int32_t disp); void emit_movsd_store_disp32(CodeBuf *buf, Reg base, int32_t disp, XReg src);kiln/src/codegen/H/emit/layout.hmodified
+2−2@@ -5,9 +5,9 @@ // Every place in codegen that needs "the absolute address of code offset // N" or "the absolute address of a globals-region field" used to hardcode // KILN_LOAD_BASE+KILN_CODE_START_OFFSET / KILN_TRY_DEPTH_ADDR / etc.-// directly from elf/elf_writer.h. Now that kiln can target two different+// directly from elf/H/elf_writer.h. Now that kiln can target two different // executable formats with two different fixed base addresses (see-// elf/elf_writer.h vs pe/pe_writer.h), those hardcodes would each need+// elf/H/elf_writer.h vs pe/H/pe_writer.h), those hardcodes would each need // their own target check -- so instead every call site goes through one // of these, and the target check lives here exactly once. uint64_t kiln_code_base(void); // add a code offset to get an absolute addresskiln/src/codegen/H/emit/runtime_exports.defmodified
+1−1@@ -3,7 +3,7 @@ // between the .so writer (which needs to export these by name) and the // executable's codegen (which needs a GOT slot per import) -- same // "adding one means adding one line here, nowhere else" reasoning as-// pe/pe_imports.def.+// pe/H/pe_imports.def. // // RUNTIME_EXPORT(enum_suffix, "exported symbol name") RUNTIME_EXPORT(HEAP_ALLOC, "kiln_heap_alloc")kiln/src/codegen/H/emit/runtime_import_enum.hmodified
+3−3@@ -1,14 +1,14 @@ #ifndef KILN_RUNTIME_IMPORT_ENUM_H #define KILN_RUNTIME_IMPORT_ENUM_H -// The RuntimeImport enum itself, factored out of elf/elf_dynamic.h so-// pe/pe_dll_writer.h can share it too (Windows --link=shared imports the+// The RuntimeImport enum itself, factored out of elf/H/elf_dynamic.h so+// pe/H/pe_dll_writer.h can share it too (Windows --link=shared imports the // exact same 5 functions from libkilnrt.dll that Linux imports from // libkilnrt.so) without two conflicting `typedef enum RuntimeImport` // definitions in the same translation unit. typedef enum { #define RUNTIME_EXPORT(name, str) RUNTIME_IMPORT_##name,-#include "codegen/runtime_exports.def"+#include "codegen/H/emit/runtime_exports.def" #undef RUNTIME_EXPORT RUNTIME_IMPORT_COUNT_ } RuntimeImport;kiln/src/codegen/H/emit/runtime_layout.hmodified
+2−2@@ -2,9 +2,9 @@ #define KILN_RUNTIME_LAYOUT_H // OS-agnostic sizes for kiln's own hand-rolled try/catch handler stack-// (see codegen/errors.c's raise routine, parser/try_catch.c) -- the byte+// (see codegen/C/runtime/errors.c's raise routine, parser/C/statements/try_catch.c) -- the byte // layout is a kiln-internal invention, not tied to ELF or PE, so both-// elf/elf_writer.h and pe/pe_writer.h include this rather than each+// elf/H/elf_writer.h and pe/H/pe_writer.h include this rather than each // re-declaring the same numbers. #define MAX_KILN_TRY_DEPTH 16 #define KILN_TRY_HANDLER_SIZE 32kiln/src/codegen/H/emit/value.hmodified
+8−8@@ -4,7 +4,7 @@ // Milestone 5: an ash value is no longer always a bare double -- it can // also be a string. Every value is now a (tag, payload) pair, 16 bytes // total, moved around generically via GP registers (raw bit-copying-// doesn't care what the bits mean -- see codegen/expr.c's header+// doesn't care what the bits mean -- see codegen/C/expressions/expr.c's header // comment). XMM registers only ever hold the payload transiently, at the // point of actually doing floating-point arithmetic on a NUMBER-tagged // value.@@ -13,8 +13,8 @@ // non-PIE executable, so absolute addresses are stable and known at // compile time) pointing at a length-prefixed byte block: 8 bytes of // length, followed by that many raw bytes. String literals are embedded-// directly in the code buffer (see codegen/strings.c); concatenation-// results are heap-allocated (see codegen/heap.c) since their size is+// directly in the code buffer (see codegen/C/strings/strings.c); concatenation+// results are heap-allocated (see codegen/C/runtime/heap.c) since their size is // only known at runtime. #define TAG_NUMBER 0 #define TAG_STRING 1@@ -26,9 +26,9 @@ // coincides with +0.0's bit pattern. That's what lets nil ride the // EXISTING truthy-test and numeric-comparison codegen (both just // ucomisd the payload against 0.0) without needing its own special case-// anywhere except print (see codegen/print_int.c's dispatch) and the+// anywhere except print (see codegen/C/runtime/print_int.c's dispatch) and the // tag-equality short-circuit in comparisons (already tag-aware since-// M5's `==`/`!=`, see codegen/expr_bool.c -- nil==nil compares equal+// M5's `==`/`!=`, see codegen/C/expressions/expr_bool.c -- nil==nil compares equal // tags then falls into the numeric path, 0.0==0.0; nil compared against // any other tag is caught by the tags-differ branch before ever // touching the payload). `true`/`false` are NOT a separate tag --@@ -40,7 +40,7 @@ #define TAG_NIL 5 // An array's payload is the address of a small, fixed-size, STABLE-// "array object" (see codegen/strings.h's comment on why absolute+// "array object" (see codegen/H/strings/strings.h's comment on why absolute // addresses are safe: kiln is always a fixed, non-PIE executable): // [0] capacity (int64, how many elements the data block has room for) // [8] count (int64, how many are actually in use)@@ -75,13 +75,13 @@ // arrays/maps) heap block: // [0] absolute code address (already resolved to KILN_LOAD_BASE + // KILN_CODE_START_OFFSET + code_offset at compile time -- kiln is-// a fixed non-PIE executable, see elf/elf_writer.h, so this is+// a fixed non-PIE executable, see elf/H/elf_writer.h, so this is // known and stable) // [8] capture_count (int64) // [16+16*i] capture i's tag [16+16*i+8] capture i's payload // A plain named function used as a value (not immediately called) gets // capture_count=0 -- the same shape as any closure with zero captures, so-// codegen/closures.c's indirect-call codegen never special-cases "0+// codegen/C/functions/closures.c's indirect-call codegen never special-cases "0 // captures", it just runs a 0-iteration loop. // // Scope limit (documented, not silently pretended away -- same spirit askiln/src/codegen/H/expressions/expr.hmodified
+3−3@@ -1,9 +1,9 @@ #ifndef KILN_CODEGEN_EXPR_H #define KILN_CODEGEN_EXPR_H-#include "lexer/lexer.h"+#include "lexer/H/lexer.h" // Parses one expression and emits real x86-64 code for it via the-// shared `code` buffer (see parser/parser.h) -- consumes tokens+// shared `code` buffer (see parser/H/core/parser.h) -- consumes tokens // directly, no AST. Leaves the computed value's (tag, payload) pushed on // the (simulated, real CPU) stack. void codegen_expression(void);@@ -21,7 +21,7 @@ void codegen_call(Token id); // than a contiguous span of the source text, so there's no single Token // to hand codegen_call. Already-fully-qualified name -- resolved via // resolve_function (not resolve_function_in_context), since the caller-// (codegen/expr.c's primary()) has already done the namespace lookup by+// (codegen/C/expressions/expr.c's primary()) has already done the namespace lookup by // building the combined name. void codegen_call_named(const char *name, int len); kiln/src/codegen/H/expressions/expr_internal.hmodified
+1−1@@ -3,7 +3,7 @@ // Cross-file link between expr.c (arithmetic: primary -> unary -> term -> // additive) and expr_bool.c (comparison -> logical_and -> logical_or ->-// codegen_expression), not part of the public API (codegen/expr.h).+// codegen_expression), not part of the public API (codegen/H/expressions/expr.h). void additive(void); #endifkiln/src/codegen/H/functions/closures.hmodified
+3−3@@ -1,10 +1,10 @@ #ifndef KILN_CLOSURES_H #define KILN_CLOSURES_H-#include "parser/functions.h"+#include "parser/H/declarations/functions.h" // `fn (params) { body }` as an EXPRESSION -- current sits on the 'fn' // token. Captures (by value, snapshotted at creation time -- see the-// scope-limit note in codegen/value.h) every variable currently visible+// scope-limit note in codegen/H/emit/value.h) every variable currently visible // in the enclosing scope, then pushes a TAG_FUNCTION value. void codegen_lambda_expr(void); @@ -16,7 +16,7 @@ void codegen_named_function_value(KilnFunction *fn); // `id` already resolved to variable `slot` holding a TAG_FUNCTION value; // current sits on the first argument or ')' (the '(' already consumed,-// same convention as codegen/expr_call.c's codegen_call). Parses args,+// same convention as codegen/C/expressions/expr_call.c's codegen_call). Parses args, // calls indirectly through the closure object, and pushes the (tag, // payload) result. void codegen_indirect_call(int slot);kiln/src/codegen/H/io/argv_builtin.hmodified
+1−1@@ -1,7 +1,7 @@ #ifndef KILN_ARGV_BUILTIN_H #define KILN_ARGV_BUILTIN_H -// argv(): no arguments -- codegen/builtins.c's dispatch just expects the+// argv(): no arguments -- codegen/C/builtins/builtins.c's dispatch just expects the // closing ')' before calling this. Pushes an array of strings, one per // process argument (argv[0] is the executable's own path, same // convention as C's main(argc, argv)).kiln/src/codegen/H/io/argv_builtin_internal.hmodified
+2−2@@ -1,13 +1,13 @@ #ifndef KILN_ARGV_BUILTIN_INTERNAL_H #define KILN_ARGV_BUILTIN_INTERNAL_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Windows has no kernel-provided argv array to read (see // argv_builtin.c's header comment) -- GetCommandLineA() returns the raw // command-line string instead, so the Windows path needs its own tokenizer // rather than sharing codegen with the Linux path. Split into its own // file to keep argv_builtin.c under ~200 lines; not part of the public-// codegen/argv_builtin.h surface, only argv_builtin.c calls this.+// codegen/H/io/argv_builtin.h surface, only argv_builtin.c calls this. void codegen_builtin_argv_windows(void); #endifkiln/src/codegen/H/io/file_path.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef KILN_FILE_PATH_H #define KILN_FILE_PATH_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Kiln strings are length-prefixed, not null-terminated -- but the raw // `open` syscall (like libc's) requires a null-terminated path. Input:kiln/src/codegen/H/io/input_builtin.hmodified
+1−1@@ -1,7 +1,7 @@ #ifndef KILN_INPUT_BUILTIN_H #define KILN_INPUT_BUILTIN_H -// input(): no arguments -- codegen/builtins.c's dispatch just expects the+// input(): no arguments -- codegen/C/builtins/builtins.c's dispatch just expects the // closing ')' before calling this. void codegen_builtin_input(void); kiln/src/codegen/H/platform/platform_console.hmodified
+3−3@@ -1,9 +1,9 @@ #ifndef KILN_PLATFORM_CONSOLE_H #define KILN_PLATFORM_CONSOLE_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Console I/O, dispatching on kiln_get_target() internally so call sites-// (codegen/print_int.c, codegen/errors.c, codegen/input_builtin.c) don't+// (codegen/C/runtime/print_int.c, codegen/C/runtime/errors.c, codegen/C/io/input_builtin.c) don't // need their own target branch. Linux writes/reads a fixed fd (1/2/0) // directly via raw syscall; Windows has no such fixed handle -- it has to // call GetStdHandle first, so each of these costs one extra call there.@@ -18,7 +18,7 @@ void platform_emit_write_stderr(CodeBuf *code); void platform_emit_read_stdin_byte(CodeBuf *code); // Split out of platform_emit_read_stdin_byte for callers that read many-// bytes in a loop (codegen/input_builtin.c): looking the handle up once+// bytes in a loop (codegen/C/io/input_builtin.c): looking the handle up once // outside the loop instead of once per byte cuts a multi-byte line's // worth of GetStdHandle round-trips down to one, which matters on // Windows -- unlike Linux's fixed fd 0, nothing here is free.kiln/src/codegen/H/platform/platform_file.hmodified
+2−2@@ -1,9 +1,9 @@ #ifndef KILN_PLATFORM_FILE_H #define KILN_PLATFORM_FILE_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Real file I/O, dispatching on kiln_get_target() internally so call-// sites (codegen/read_file_builtin.c, codegen/write_file_builtins.c)+// sites (codegen/C/io/read_file_builtin.c, codegen/C/io/write_file_builtins.c) // don't need their own target branch. The fd/HANDLE kiln gets back is // used the same way on both targets: a signed value, negative means // "open failed" (Linux's -1 and Windows' INVALID_HANDLE_VALUE, which iskiln/src/codegen/H/platform/win_call.hmodified
+3−3@@ -1,12 +1,12 @@ #ifndef KILN_WIN_CALL_H #define KILN_WIN_CALL_H-#include "codegen/emit.h"-#include "pe/pe_writer.h"+#include "codegen/H/emit/emit.h"+#include "pe/H/pe_writer.h" // Windows x64 calling convention -- the caller-side sequence for calling // an imported kernel32.dll function. New territory for this codebase: // unlike kiln's own internal `fn` convention (stack-push based, see-// parser/parser_control.c), this has to match a REAL external ABI, with+// parser/C/statements/parser_control.c), this has to match a REAL external ABI, with // rules kiln has never had to satisfy before: // - first four integer/pointer args in RCX, RDX, R8, R9 // - a mandatory 32-byte "shadow space" the CALLEE is allowed to spillkiln/src/codegen/H/platform/win_file_call.hmodified
+3−3@@ -1,11 +1,11 @@ #ifndef KILN_WIN_FILE_CALL_H #define KILN_WIN_FILE_CALL_H-#include "pe/pe_writer.h"+#include "pe/H/pe_writer.h" // Shared shape between ReadFile and WriteFile's argument lists (both are // (handle, buffer, length, &ignored_out, NULL)) -- used by both-// codegen/platform_console.c (stdin/stdout/stderr) and-// codegen/platform_file.c (real files), so it lives here instead of+// codegen/C/platform/platform_console.c (stdin/stdout/stderr) and+// codegen/C/platform/platform_file.c (real files), so it lives here instead of // being duplicated in each. // // In: RAX=handle, RSI=buf, RDI=len. `which` must be PE_IMPORT_READ_FILEkiln/src/codegen/H/runtime/errors.hmodified
+5−5@@ -1,11 +1,11 @@ #ifndef KILN_ERRORS_H #define KILN_ERRORS_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" -// Runtime (not compile-time -- see parser/parser.h's parse_error for+// Runtime (not compile-time -- see parser/H/core/parser.h's parse_error for // that) errors: array out of bounds, missing map key, and so on. // Emitted once, at the very start of the generated program (right after-// codegen/heap.c's heap_emit_startup): a single reusable "raise" routine+// codegen/C/runtime/heap.c's heap_emit_startup): a single reusable "raise" routine // that every runtime error jumps to (never called -- there's nothing to // return to, control either resumes at a catch block or the process // exits).@@ -17,9 +17,9 @@ void errors_emit_raise_routine_only(CodeBuf *code); int errors_raise_routine_offset(void); // Embeds `msg` (compile-time-known, jumped over so it's never executed-// as instructions -- same technique codegen/strings.c uses for string+// as instructions -- same technique codegen/C/strings/strings.c uses for string // literals) and raises it: if a `try` is currently active (see-// parser/try_catch.c), unwinds to its `catch` block with `msg` bound as+// parser/C/statements/try_catch.c), unwinds to its `catch` block with `msg` bound as // a TAG_STRING value; otherwise writes it to stderr and exits with // status 1, same as before milestone 9. void errors_emit_die(CodeBuf *code, const char *msg);kiln/src/codegen/H/runtime/heap.hmodified
+2−2@@ -1,6 +1,6 @@ #ifndef KILN_HEAP_H #define KILN_HEAP_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // A bump allocator, no free (matches ashvm's own lack of GC -- neither // engine reclaims memory during a run, only at process exit). Backed by@@ -13,7 +13,7 @@ // Emitted once, at the very start of the generated program (before the // top-level statement loop): grabs a 16MB arena and records its start as-// the heap bump pointer at KILN_GLOBALS_ADDR (see elf/elf_writer.h).+// the heap bump pointer at KILN_GLOBALS_ADDR (see elf/H/elf_writer.h). void heap_emit_startup(CodeBuf *code); // Plan B: emits ONLY the alloc routine's body (no arena grab) -- used bykiln/src/codegen/H/runtime/print_int.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef KILN_CODEGEN_PRINT_INT_H #define KILN_CODEGEN_PRINT_INT_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Emitted once, at program start (see parser.c's compile_program) -- // must run before any call to codegen_print_top below.kiln/src/codegen/H/strings/string_alloc.hmodified
+3−3@@ -1,6 +1,6 @@ #ifndef KILN_STRING_ALLOC_H #define KILN_STRING_ALLOC_H-#include "codegen/emit.h"+#include "codegen/H/emit/emit.h" // Emitted once, at program start (see parser.c's compile_program) -- // must run after heap_emit_startup (this calls heap_emit_alloc) and@@ -15,8 +15,8 @@ int string_alloc_prefixed_routine_offset(void); // Allocates a heap block for a new TAG_STRING value's content: input // RDX=content length, output RAX=block address with the length prefix // already written at [RAX+0] (the payload is RAX+8, same layout-// codegen/strings.c's literals use). Clobbers RSI, RDI (via-// codegen/heap.c's heap_emit_alloc) -- RDX itself survives untouched.+// codegen/C/strings/strings.c's literals use). Clobbers RSI, RDI (via+// codegen/C/runtime/heap.c's heap_emit_alloc) -- RDX itself survives untouched. // Shared by every milestone-10 string builtin that produces a new string // (upper/lower/trim/substring/join/replace) so the "+8 for the length // prefix" arithmetic exists in exactly one place. Plan B, phase B1: akiln/src/codegen/H/strings/string_builtins.hmodified
+2−2@@ -2,14 +2,14 @@ #define KILN_STRING_BUILTINS_H // upper/lower/trim assume their one STRING argument already pushed ---// codegen/builtins.c's dispatch calls these after parsing the argument.+// codegen/C/builtins/builtins.c's dispatch calls these after parsing the argument. void codegen_builtin_upper(void); void codegen_builtin_lower(void); void codegen_builtin_trim(void); // substring/indexOf/split/join/replace self-parse their (multiple) // arguments starting right after the already-consumed '(', same-// convention as codegen/higher_order.h's map/filter/reduce.+// convention as codegen/H/builtins/higher_order.h's map/filter/reduce. void codegen_builtin_substring(void); void codegen_builtin_indexof(void); void codegen_builtin_split(void);kiln/src/codegen/H/strings/strings.hmodified
+1−1@@ -20,7 +20,7 @@ void codegen_string_literal_bytes(const char *text, int len); // saved BEFORE calling -- these clobber RAX,RBX,RCX,RDX,RSI,RDI freely). // Pushes (tag=STRING, payload=<new heap address>) -- the concatenation.-// Needs a real heap allocation (see codegen/heap.h) since the combined+// Needs a real heap allocation (see codegen/H/runtime/heap.h) since the combined // size is only known at runtime. void codegen_string_concat(void); kiln/src/codegen/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/builtins/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/collections/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/emit/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/expressions/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/functions/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/io/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/platform/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/runtime/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/codegen/O/strings/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/diagnostics/C/diagnostics.cmodified
+1−1@@ -2,7 +2,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h>-#include "diagnostics/diagnostics.h"+#include "diagnostics/H/diagnostics.h" static const char *g_source = NULL; static const char *g_filename = "source";kiln/src/diagnostics/D/diagnostics.dadded
+3−0@@ -0,0 +1,3 @@+src/diagnostics/O/diagnostics.o: src/diagnostics/C/diagnostics.c \+ src/diagnostics/H/diagnostics.h+src/diagnostics/H/diagnostics.h:kiln/src/diagnostics/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/elf/C/elf_dynamic.cmodified
+2−2@@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> #include <sys/stat.h>-#include "elf/elf_dynamic.h"+#include "elf/H/elf_dynamic.h" // Hand-written dynamically-linked ELF64 executable: PT_INTERP so the // kernel hands off to the REAL system dynamic linker, PT_DYNAMIC with@@ -18,7 +18,7 @@ static const char *const runtime_names[] = { #define RUNTIME_EXPORT(name, str) str,-#include "codegen/runtime_exports.def"+#include "codegen/H/emit/runtime_exports.def" #undef RUNTIME_EXPORT }; kiln/src/elf/C/elf_dynamic_call.cmodified
+1−1@@ -1,4 +1,4 @@-#include "elf/elf_dynamic_call.h"+#include "elf/H/elf_dynamic_call.h" void elf_dynamic_call(CodeBuf *code, RuntimeImport which) { emit_call_abs32(code, (uint32_t)elf_dynamic_got_addr(which));kiln/src/elf/C/elf_so_writer.cmodified
+10−10@@ -2,18 +2,18 @@ #include <stdlib.h> #include <string.h> #include <sys/stat.h>-#include "elf/elf_so_writer.h"-#include "elf/elf_dynamic.h"-#include "codegen/heap.h"-#include "codegen/bytes.h"-#include "codegen/string_alloc.h"-#include "codegen/print_int.h"-#include "codegen/errors.h"-#include "target.h"+#include "elf/H/elf_so_writer.h"+#include "elf/H/elf_dynamic.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/runtime/print_int.h"+#include "codegen/H/runtime/errors.h"+#include "app/H/target.h" static const char *const export_names[] = { #define RUNTIME_EXPORT(name, str) str,-#include "codegen/runtime_exports.def"+#include "codegen/H/emit/runtime_exports.def" #undef RUNTIME_EXPORT }; @@ -44,7 +44,7 @@ static uint32_t elf_hash(const char *name) { int elf_write_shared_runtime(const char *path) { // ---- compile the runtime itself, position-independent, into its own // fresh CodeBuf. Link mode STAYS shared (main.c sets it before- // calling this) so codegen/layout.c resolves globals addresses using+ // calling this) so codegen/C/emit/layout.c resolves globals addresses using // the shared-mode executable layout -- but kiln_set_compiling_so(1) // makes each routine's OWN call sites (e.g. string_alloc_prefixed // calling heap_emit_alloc) resolve as ordinary same-buffer relativekiln/src/elf/C/elf_writer.cmodified
+2−2@@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> #include <sys/stat.h>-#include "elf/elf_writer.h"+#include "elf/H/elf_writer.h" static void put8(CodeBuf *f, uint8_t v) { if (f->count >= f->capacity) {@@ -48,7 +48,7 @@ int elf_write_executable(const char *path, const CodeBuf *machine_code) { put32(&file, 1); // p_type = PT_LOAD // p_flags = PF_R | PF_W | PF_X. Milestone 1-4 only needed R|X (code // never wrote into its own segment); milestone 5's heap bump pointer- // (see elf_writer.h / codegen/heap.c) is a global living inside this+ // (see elf_writer.h / codegen/C/runtime/heap.c) is a global living inside this // same segment, so it needs to be writable too. A real compiler would // split .text (R|X) from .data (R|W) into separate segments -- kiln // doesn't do that yet, so the whole thing is RWX for now.kiln/src/elf/D/elf_dynamic.dadded
+10−0@@ -0,0 +1,10 @@+src/elf/O/elf_dynamic.o: src/elf/C/elf_dynamic.c src/elf/H/elf_dynamic.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_writer.h \+ src/codegen/H/emit/runtime_layout.h+src/elf/H/elf_dynamic.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/elf/H/elf_writer.h:+src/codegen/H/emit/runtime_layout.h:kiln/src/elf/D/elf_dynamic_call.dadded
+12−0@@ -0,0 +1,12 @@+src/elf/O/elf_dynamic_call.o: src/elf/C/elf_dynamic_call.c \+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_writer.h \+ src/codegen/H/emit/runtime_layout.h+src/elf/H/elf_dynamic_call.h:+src/elf/H/elf_dynamic.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/elf/H/elf_writer.h:+src/codegen/H/emit/runtime_layout.h:kiln/src/elf/D/elf_so_writer.dadded
+21−0@@ -0,0 +1,21 @@+src/elf/O/elf_so_writer.o: src/elf/C/elf_so_writer.c \+ src/elf/H/elf_so_writer.h src/elf/H/elf_dynamic.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_writer.h \+ src/codegen/H/emit/runtime_layout.h src/codegen/H/runtime/heap.h \+ src/codegen/H/emit/bytes.h src/codegen/H/strings/string_alloc.h \+ src/codegen/H/runtime/print_int.h src/codegen/H/runtime/errors.h \+ src/app/H/target.h+src/elf/H/elf_so_writer.h:+src/elf/H/elf_dynamic.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/elf/H/elf_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/runtime/print_int.h:+src/codegen/H/runtime/errors.h:+src/app/H/target.h:kiln/src/elf/D/elf_writer.dadded
+5−0@@ -0,0 +1,5 @@+src/elf/O/elf_writer.o: src/elf/C/elf_writer.c src/elf/H/elf_writer.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h+src/elf/H/elf_writer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_layout.h:kiln/src/elf/H/elf_dynamic.hmodified
+3−3@@ -1,8 +1,8 @@ #ifndef KILN_ELF_DYNAMIC_H #define KILN_ELF_DYNAMIC_H-#include "codegen/emit.h"-#include "codegen/runtime_import_enum.h"-#include "elf/elf_writer.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/runtime_import_enum.h"+#include "elf/H/elf_writer.h" // Layout for a --link=shared kiln executable: real dynamic linking, the // kernel hands off to the system's actual /lib64/ld-linux-x86-64.so.2 (akiln/src/elf/H/elf_dynamic_call.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef KILN_ELF_DYNAMIC_CALL_H #define KILN_ELF_DYNAMIC_CALL_H-#include "elf/elf_dynamic.h"+#include "elf/H/elf_dynamic.h" // Calls `which` through its GOT slot (filled in by ld.so before this // program's own code ever runs) -- a single `call [addr]` touching nokiln/src/elf/H/elf_so_writer.hmodified
+2−2@@ -4,8 +4,8 @@ // Compiles the runtime (heap/bytes/string_alloc/print/errors-raise) into // a fresh, position-independent CodeBuf and writes it as a real ET_DYN // ELF64 shared object at `path` -- one exported symbol per-// codegen/runtime_exports.def entry, loadable by the system's real-// dynamic linker (validated structure, see elf/elf_dynamic.h's header+// codegen/H/emit/runtime_exports.def entry, loadable by the system's real+// dynamic linker (validated structure, see elf/H/elf_dynamic.h's header // comment). Returns 0 on success. int elf_write_shared_runtime(const char *path); kiln/src/elf/H/elf_writer.hmodified
+6−6@@ -1,9 +1,9 @@ #ifndef KILN_ELF_WRITER_H #define KILN_ELF_WRITER_H-#include "codegen/emit.h"-#include "codegen/runtime_layout.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/runtime_layout.h" -// Layout constants shared with codegen/heap.c: kiln generates a fixed,+// Layout constants shared with codegen/C/runtime/heap.c: kiln generates a fixed, // non-PIE executable (always loaded at KILN_LOAD_BASE), so absolute // addresses are known at compile time. Milestone 5 needs one such fixed // address for the heap bump pointer (a "global" -- there's no per-call@@ -15,8 +15,8 @@ #define KILN_PHDR_SIZE 56 // Milestone 9: the globals region also holds kiln's own hand-rolled-// setjmp/longjmp equivalent for try/catch (see codegen/errors.c's raise-// routine and parser/try_catch.c) -- a fixed-depth stack of "handler"+// setjmp/longjmp equivalent for try/catch (see codegen/C/runtime/errors.c's raise+// routine and parser/C/statements/try_catch.c) -- a fixed-depth stack of "handler" // records, since this is a freestanding binary with no libc setjmp to // call. Each handler is {saved_rsp, saved_rbp, target_addr, // error_slot_rbp_offset}, 4 x int64. Bounded the same way every other@@ -31,7 +31,7 @@ // saves that original RSP here -- a fixed absolute address, reachable // from any frame later on, since a called function's own RBP is no // longer the original one by the time argv() might be called from-// inside it (see codegen/argv_builtin.c).+// inside it (see codegen/C/io/argv_builtin.c). #define KILN_ARGV_SIZE 8 #define KILN_GLOBALS_SIZE (8 + KILN_TRY_DEPTH_SIZE + KILN_TRY_HANDLERS_SIZE + KILN_ARGV_SIZE) // heap_ptr, try_depth, handler stack, argvkiln/src/elf/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/lexer/C/lexer.cmodified
+3−3@@ -1,7 +1,7 @@ #include <string.h> #include <ctype.h>-#include "lexer/lexer.h"-#include "lexer/lexer_import.h"+#include "lexer/H/lexer.h"+#include "lexer/H/lexer_import.h" // lex_* (not the bare start/current/line these had as file-static // before) -- shared with lexer_import.c now, and a plain `current` would@@ -89,7 +89,7 @@ Token error_token(const char *message) { // lexer just has to not stop early and hand back a truncated token. // Underscore digit separators (1_000_000) are the one thing strtod // itself doesn't understand -- primary() strips those out of the token-// text before calling strtod, see codegen/expr.c.+// text before calling strtod, see codegen/C/expressions/expr.c. static Token number(void) { if (lex_start[0] == '0' && (peek() == 'x' || peek() == 'X')) { advance(); // consume 'x'/'X'kiln/src/lexer/C/lexer_import.cmodified
+1−1@@ -1,4 +1,4 @@-#include "lexer/lexer_import.h"+#include "lexer/H/lexer_import.h" LexerState lexer_save_state(void) { LexerState state;kiln/src/lexer/D/lexer.dadded
+4−0@@ -0,0 +1,4 @@+src/lexer/O/lexer.o: src/lexer/C/lexer.c src/lexer/H/lexer.h \+ src/lexer/H/lexer_import.h+src/lexer/H/lexer.h:+src/lexer/H/lexer_import.h:kiln/src/lexer/D/lexer_import.dadded
+4−0@@ -0,0 +1,4 @@+src/lexer/O/lexer_import.o: src/lexer/C/lexer_import.c \+ src/lexer/H/lexer_import.h src/lexer/H/lexer.h+src/lexer/H/lexer_import.h:+src/lexer/H/lexer.h:kiln/src/lexer/H/lexer_import.hmodified
+1−1@@ -1,6 +1,6 @@ #ifndef KILN_LEXER_IMPORT_H #define KILN_LEXER_IMPORT_H-#include "lexer/lexer.h"+#include "lexer/H/lexer.h" // Cross-file link between lexer.c (the tokenizer's cursor state and its // low-level scan primitives) and lexer_import.c (state save/restore pluskiln/src/lexer/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/parser/C/core/parser.cmodified
+25−25@@ -1,26 +1,26 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "parser/parser.h"-#include "parser/parser_internal.h"-#include "parser/vars.h"-#include "parser/loop_stack.h"-#include "parser/functions.h"-#include "parser/imports.h"-#include "parser/constants.h"-#include "codegen/expr.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"-#include "codegen/heap.h"-#include "codegen/bytes.h"-#include "codegen/string_alloc.h"-#include "codegen/arrays.h"-#include "codegen/maps.h"-#include "codegen/errors.h"-#include "codegen/print_int.h"-#include "diagnostics/diagnostics.h"-#include "elf/elf_writer.h"-#include "target.h"+#include "parser/H/core/parser.h"+#include "parser/H/core/parser_internal.h"+#include "parser/H/declarations/vars.h"+#include "parser/H/statements/loop_stack.h"+#include "parser/H/declarations/functions.h"+#include "parser/H/imports/imports.h"+#include "parser/H/declarations/constants.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/collections/arrays.h"+#include "codegen/H/collections/maps.h"+#include "codegen/H/runtime/errors.h"+#include "codegen/H/runtime/print_int.h"+#include "diagnostics/H/diagnostics.h"+#include "elf/H/elf_writer.h"+#include "app/H/target.h" Token current; Token previous;@@ -264,7 +264,7 @@ static void assignment_statement(void) { } // return [expr] ; -- bare `return;` returns 0, matching ashc/ashvm.-// Return value comes back as RBX=tag, RAX=payload (see codegen/expr.c's+// Return value comes back as RBX=tag, RAX=payload (see codegen/C/expressions/expr.c's // call-site handling). static void return_statement(void) { advance_token();@@ -285,7 +285,7 @@ static void return_statement(void) { // throw expr ; -- expr must be a STRING (matches try/catch's own // convention: every caught error, built-in or user-thrown, is a plain-// string). Reuses codegen/errors.c's raise routine directly -- the exact+// string). Reuses codegen/C/runtime/errors.c's raise routine directly -- the exact // same catch/unwind mechanism M9's built-in errors (array bounds, missing // map key) already go through, just with a runtime message instead of a // compile-time-constant one.@@ -302,7 +302,7 @@ static void throw_statement(void) { // break ; -- jumps past the innermost loop; the jump is recorded, not // resolved here, since the innermost loop's own codegen (parser_control.c's-// while_statement / parser/for_loop.c's for_statement) hasn't emitted the+// while_statement / parser/C/statements/for_loop.c's for_statement) hasn't emitted the // "after the loop" landing point yet. static void break_statement(void) { advance_token();@@ -372,7 +372,7 @@ void compile_program(const char *source, const char *source_path, CodeBuf *out) // the whole program where that original RSP is still available // (nothing has touched it yet), so it's saved to a fixed globals // address here, before anything else, for argv() to read later from- // any frame (see codegen/argv_builtin.c and elf/elf_writer.h's+ // any frame (see codegen/C/io/argv_builtin.c and elf/H/elf_writer.h's // KILN_ARGV_ADDR comment). Windows has no equivalent need: argv() // there calls GetCommandLineA() directly, callable at any point, so // there's nothing to snapshot this early.@@ -387,7 +387,7 @@ void compile_program(const char *source, const char *source_path, CodeBuf *out) // frame (see parser_control.c's fn_statement/parser.c's // return_statement) without disturbing this one -- the callee always // restores RBP before returning. Milestone 5: each slot is now 16- // bytes (tag + payload, see codegen/value.h), not 8.+ // bytes (tag + payload, see codegen/H/emit/value.h), not 8. emit_mov_reg_reg(code, REG_RBP, REG_RSP); emit_sub_reg_imm32(code, REG_RSP, KILN_FRAME_RESERVE); kiln/src/parser/C/declarations/constants.cmodified
+5−5@@ -1,10 +1,10 @@ #include <string.h> #include <stdint.h>-#include "parser/constants.h"-#include "parser/parser.h"-#include "codegen/emit.h"-#include "codegen/value.h"-#include "codegen/strings.h"+#include "parser/H/declarations/constants.h"+#include "parser/H/core/parser.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/value.h"+#include "codegen/H/strings/strings.h" static KilnConstant constants[MAX_KILN_CONSTS]; static int constant_count = 0;kiln/src/parser/C/declarations/functions.cmodified
+2−2@@ -1,7 +1,7 @@ #include <string.h> #include <stdio.h>-#include "parser/functions.h"-#include "parser/parser.h"+#include "parser/H/declarations/functions.h"+#include "parser/H/core/parser.h" static KilnFunction functions[MAX_KILN_FUNCS]; static int function_count = 0;kiln/src/parser/C/declarations/vars.cmodified
+3−3@@ -1,13 +1,13 @@ #include <string.h>-#include "parser/vars.h"-#include "parser/parser.h"+#include "parser/H/declarations/vars.h"+#include "parser/H/core/parser.h" static char var_names[MAX_KILN_VARS][64]; static int var_count = 0; static int scope_start = 0; // Scans newest-first (most-recently-declared wins), standard shadowing-// semantics -- required for try/catch: parser/try_catch.c reserves each+// semantics -- required for try/catch: parser/C/statements/try_catch.c reserves each // catch variable's slot with a synthetic placeholder name and renames it // to the real name only after the fact (the slot's rbp-offset has to be // known before the try body compiles, before the real name is evenkiln/src/parser/C/imports/import_paths.cmodified
+1−1@@ -2,7 +2,7 @@ #include <string.h> #include <stdio.h> #include <stdlib.h>-#include "parser/import_paths.h"+#include "parser/H/imports/import_paths.h" void import_path_dirname(const char *path, char *out, int out_size) { const char *slash = strrchr(path, '/');kiln/src/parser/C/imports/imports.cmodified
+7−7@@ -3,13 +3,13 @@ #include <stdio.h> #include <stdlib.h> #include <limits.h>-#include "parser/imports.h"-#include "parser/import_paths.h"-#include "parser/parser.h"-#include "parser/parser_internal.h"-#include "parser/functions.h"-#include "lexer/lexer.h"-#include "diagnostics/diagnostics.h"+#include "parser/H/imports/imports.h"+#include "parser/H/imports/import_paths.h"+#include "parser/H/core/parser.h"+#include "parser/H/core/parser_internal.h"+#include "parser/H/declarations/functions.h"+#include "lexer/H/lexer.h"+#include "diagnostics/H/diagnostics.h" #define MAX_KILN_IMPORTS 16 #define MAX_KILN_IMPORT_DEPTH 8kiln/src/parser/C/statements/for_loop.cmodified
+7−7@@ -1,10 +1,10 @@-#include "parser/for_loop.h"-#include "parser/parser.h"-#include "parser/parser_internal.h"-#include "parser/vars.h"-#include "parser/loop_stack.h"-#include "codegen/expr.h"-#include "codegen/emit.h"+#include "parser/H/statements/for_loop.h"+#include "parser/H/core/parser.h"+#include "parser/H/core/parser_internal.h"+#include "parser/H/declarations/vars.h"+#include "parser/H/statements/loop_stack.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/emit.h" static int for_nesting_depth = 0; kiln/src/parser/C/statements/loop_stack.cmodified
+2−2@@ -1,5 +1,5 @@-#include "parser/loop_stack.h"-#include "parser/parser.h"+#include "parser/H/statements/loop_stack.h"+#include "parser/H/core/parser.h" #define MAX_LOOP_NESTING 16 #define MAX_LOOP_JUMPS 64kiln/src/parser/C/statements/parser_control.cmodified
+9−9@@ -1,13 +1,13 @@ #include <string.h>-#include "parser/parser.h"-#include "parser/parser_internal.h"-#include "parser/vars.h"-#include "parser/functions.h"-#include "parser/for_loop.h"-#include "parser/loop_stack.h"-#include "codegen/expr.h"-#include "codegen/emit_sse.h"-#include "codegen/value.h"+#include "parser/H/core/parser.h"+#include "parser/H/core/parser_internal.h"+#include "parser/H/declarations/vars.h"+#include "parser/H/declarations/functions.h"+#include "parser/H/statements/for_loop.h"+#include "parser/H/statements/loop_stack.h"+#include "codegen/H/expressions/expr.h"+#include "codegen/H/emit/emit_sse.h"+#include "codegen/H/emit/value.h" // Truthiness test for if/while conditions: pop the value (tag discarded, // assumed NUMBER -- matches ashvm's own truthy(), which requires akiln/src/parser/C/statements/try_catch.cmodified
+9−9@@ -1,18 +1,18 @@-#include "parser/parser.h"-#include "parser/parser_internal.h"-#include "parser/vars.h"-#include "codegen/emit.h"-#include "codegen/errors.h"-#include "codegen/layout.h"-#include "codegen/runtime_layout.h"+#include "parser/H/core/parser.h"+#include "parser/H/core/parser_internal.h"+#include "parser/H/declarations/vars.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/runtime/errors.h"+#include "codegen/H/emit/layout.h"+#include "codegen/H/emit/runtime_layout.h" // try { A } catch (e) { B } // // A handler stack living in the fixed globals region (see-// elf/elf_writer.h) holds, per active try, the (rsp, rbp) to restore and+// elf/H/elf_writer.h) holds, per active try, the (rsp, rbp) to restore and // the (target address, error-variable rbp-offset) to resume at -- kiln's // own setjmp/longjmp equivalent, hand-rolled since this is a freestanding-// binary with no libc to call into (see codegen/errors.c's raise routine+// binary with no libc to call into (see codegen/C/runtime/errors.c's raise routine // for the runtime half of this). // // The catch variable's slot has to be reserved BEFORE compiling A: itskiln/src/parser/D/core/parser.dadded
+36−0@@ -0,0 +1,36 @@+src/parser/O/core/parser.o: src/parser/C/core/parser.c \+ src/parser/H/core/parser.h src/lexer/H/lexer.h src/codegen/H/emit/emit.h \+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \+ src/parser/H/statements/loop_stack.h \+ src/parser/H/declarations/functions.h src/parser/H/imports/imports.h \+ src/parser/H/declarations/constants.h src/codegen/H/expressions/expr.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \+ src/codegen/H/runtime/heap.h src/codegen/H/emit/bytes.h \+ src/codegen/H/strings/string_alloc.h src/codegen/H/collections/arrays.h \+ src/codegen/H/collections/maps.h src/codegen/H/runtime/errors.h \+ src/codegen/H/runtime/print_int.h src/diagnostics/H/diagnostics.h \+ src/elf/H/elf_writer.h src/codegen/H/emit/runtime_layout.h \+ src/app/H/target.h+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/parser/H/core/parser_internal.h:+src/parser/H/declarations/vars.h:+src/parser/H/statements/loop_stack.h:+src/parser/H/declarations/functions.h:+src/parser/H/imports/imports.h:+src/parser/H/declarations/constants.h:+src/codegen/H/expressions/expr.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/collections/arrays.h:+src/codegen/H/collections/maps.h:+src/codegen/H/runtime/errors.h:+src/codegen/H/runtime/print_int.h:+src/diagnostics/H/diagnostics.h:+src/elf/H/elf_writer.h:+src/codegen/H/emit/runtime_layout.h:+src/app/H/target.h:kiln/src/parser/D/declarations/constants.dadded
+11−0@@ -0,0 +1,11 @@+src/parser/O/declarations/constants.o: \+ src/parser/C/declarations/constants.c \+ src/parser/H/declarations/constants.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h src/codegen/H/emit/value.h \+ src/codegen/H/strings/strings.h+src/parser/H/declarations/constants.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/value.h:+src/codegen/H/strings/strings.h:kiln/src/parser/D/declarations/functions.dadded
+8−0@@ -0,0 +1,8 @@+src/parser/O/declarations/functions.o: \+ src/parser/C/declarations/functions.c \+ src/parser/H/declarations/functions.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h+src/parser/H/declarations/functions.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:kiln/src/parser/D/declarations/vars.dadded
+7−0@@ -0,0 +1,7 @@+src/parser/O/declarations/vars.o: src/parser/C/declarations/vars.c \+ src/parser/H/declarations/vars.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h+src/parser/H/declarations/vars.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:kiln/src/parser/D/imports/import_paths.dadded
+3−0@@ -0,0 +1,3 @@+src/parser/O/imports/import_paths.o: src/parser/C/imports/import_paths.c \+ src/parser/H/imports/import_paths.h+src/parser/H/imports/import_paths.h:kiln/src/parser/D/imports/imports.dadded
+13−0@@ -0,0 +1,13 @@+src/parser/O/imports/imports.o: src/parser/C/imports/imports.c \+ src/parser/H/imports/imports.h src/parser/H/imports/import_paths.h \+ src/parser/H/core/parser.h src/lexer/H/lexer.h src/codegen/H/emit/emit.h \+ src/parser/H/core/parser_internal.h \+ src/parser/H/declarations/functions.h src/diagnostics/H/diagnostics.h+src/parser/H/imports/imports.h:+src/parser/H/imports/import_paths.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/parser/H/core/parser_internal.h:+src/parser/H/declarations/functions.h:+src/diagnostics/H/diagnostics.h:kiln/src/parser/D/statements/for_loop.dadded
+13−0@@ -0,0 +1,13 @@+src/parser/O/statements/for_loop.o: src/parser/C/statements/for_loop.c \+ src/parser/H/statements/for_loop.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \+ src/parser/H/statements/loop_stack.h src/codegen/H/expressions/expr.h+src/parser/H/statements/for_loop.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/parser/H/core/parser_internal.h:+src/parser/H/declarations/vars.h:+src/parser/H/statements/loop_stack.h:+src/codegen/H/expressions/expr.h:kiln/src/parser/D/statements/loop_stack.dadded
+8−0@@ -0,0 +1,8 @@+src/parser/O/statements/loop_stack.o: \+ src/parser/C/statements/loop_stack.c \+ src/parser/H/statements/loop_stack.h src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h+src/parser/H/statements/loop_stack.h:+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:kiln/src/parser/D/statements/parser_control.dadded
+18−0@@ -0,0 +1,18 @@+src/parser/O/statements/parser_control.o: \+ src/parser/C/statements/parser_control.c src/parser/H/core/parser.h \+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \+ src/parser/H/declarations/functions.h src/parser/H/statements/for_loop.h \+ src/parser/H/statements/loop_stack.h src/codegen/H/expressions/expr.h \+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/parser/H/core/parser_internal.h:+src/parser/H/declarations/vars.h:+src/parser/H/declarations/functions.h:+src/parser/H/statements/for_loop.h:+src/parser/H/statements/loop_stack.h:+src/codegen/H/expressions/expr.h:+src/codegen/H/emit/emit_sse.h:+src/codegen/H/emit/value.h:kiln/src/parser/D/statements/try_catch.dadded
+13−0@@ -0,0 +1,13 @@+src/parser/O/statements/try_catch.o: src/parser/C/statements/try_catch.c \+ src/parser/H/core/parser.h src/lexer/H/lexer.h src/codegen/H/emit/emit.h \+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \+ src/codegen/H/runtime/errors.h src/codegen/H/emit/layout.h \+ src/codegen/H/emit/runtime_layout.h+src/parser/H/core/parser.h:+src/lexer/H/lexer.h:+src/codegen/H/emit/emit.h:+src/parser/H/core/parser_internal.h:+src/parser/H/declarations/vars.h:+src/codegen/H/runtime/errors.h:+src/codegen/H/emit/layout.h:+src/codegen/H/emit/runtime_layout.h:kiln/src/parser/H/core/parser.hmodified
+3−3@@ -1,9 +1,9 @@ #ifndef KILN_PARSER_H #define KILN_PARSER_H-#include "lexer/lexer.h"-#include "codegen/emit.h"+#include "lexer/H/lexer.h"+#include "codegen/H/emit/emit.h" -// Shared parser state, read by codegen/expr.c as well as parser.c --+// Shared parser state, read by codegen/C/expressions/expr.c as well as parser.c -- // mirrors ashvm/src/compiler/state.h's split (state lives in a small // header, expression codegen and statement parsing both consume it). extern Token current;kiln/src/parser/H/declarations/functions.hmodified
+3−3@@ -7,7 +7,7 @@ // ashvm's compiler has (see emit_call_back's comment) -- so by the time a // call site compiles, the callee's code_offset is always already known. //-// Imports (see parser/imports.c) don't change this table's shape at all+// Imports (see parser/C/imports/imports.c) don't change this table's shape at all // -- an imported function is declared under a namespaced string (e.g. // "math.add") in the exact same flat array. 64 (up from 32) gives real // programs room to import a handful of libraries without hitting the cap@@ -31,9 +31,9 @@ KilnFunction *resolve_function(const char *name, int len); // doesn't fit in the 64-byte name field. KilnFunction *declare_function(const char *name, int len); -// --- Import namespace context (parser/imports.c sets/restores this around+// --- Import namespace context (parser/C/imports/imports.c sets/restores this around // each recursively-parsed imported file; parser_control.c's fn_statement-// and codegen/expr.c + expr_call.c's call-site resolution consult it) ---+// and codegen/C/expressions/expr.c + expr_call.c's call-site resolution consult it) --- // Sets the namespace prefix every subsequent declare_function_in_context/ // resolve_function_in_context call should use. Pass len=0 (ns may be NULL)kiln/src/parser/H/declarations/vars.hmodified
+5−5@@ -16,14 +16,14 @@ int resolve_var(const char *name, int len); int declare_var(const char *name, int len); // Milestone 9: overwrites an already-declared slot's name in place (same-// slot index, new name) -- parser/try_catch.c needs a catch variable's+// slot index, new name) -- parser/C/statements/try_catch.c needs a catch variable's // slot reserved BEFORE its real name (`catch (e)`) is parsed, since the // slot's rbp-relative offset must be embedded into the handler struct at // try-entry, ahead of the try block's body. void rename_var(int slot, const char *name, int len); // Milestone 5: each variable now holds a (tag, payload) pair (16 bytes,-// see codegen/value.h), not a bare 8-byte double -- so each slot takes+// see codegen/H/emit/value.h), not a bare 8-byte double -- so each slot takes // 16 bytes: tag at [rbp - 16*(i+1)], payload right after it at // [rbp - 16*(i+1) + 8], below the frame pointer set up by parser.c's // prologue (`mov rbp, rsp; sub rsp, MAX_KILN_VARS*16`). Shared here so@@ -67,7 +67,7 @@ void vars_scope_end(VarBlockScope saved); int resolve_var_in_current_scope(const char *name, int len); // Milestone 8: one extra RBP-relative slot beyond the normal variable-// table, reserved for codegen/closures.c's indirect-call codegen to stash+// table, reserved for codegen/C/functions/closures.c's indirect-call codegen to stash // a runtime-only capture_count across the `call` instruction (GP // registers are all freely clobbered by the callee; RBP is the one thing // provably restored to the caller's own value by the time any call@@ -97,7 +97,7 @@ int32_t higher_order_scratch_offset(void); // at COMPILE TIME (nested `for` statements are literally nested calls in // this single-pass compiler), so each nesting level just gets its own // fixed offset rather than a runtime-tracked stack. Bounded the same way-// every other table here is; parser/for_loop.c resets its nesting+// every other table here is; parser/C/statements/for_loop.c resets its nesting // counter to 0 when entering a function or lambda body (mirroring // vars_save/vars_clear/vars_restore), since that body gets its own RBP // at runtime and can safely reuse the same offsets independently of how@@ -107,7 +107,7 @@ int32_t higher_order_scratch_offset(void); #define KILN_FOR_STACK_SIZE (MAX_KILN_FOR_DEPTH * KILN_FOR_LEVEL_SIZE) int32_t for_level_offset(int depth); -// Plan A, phase A3: one 8-byte RBP-relative slot for codegen/win_call.c to+// Plan A, phase A3: one 8-byte RBP-relative slot for codegen/C/platform/win_call.c to // stash the original RSP across a Windows API call (dynamic 16-byte align // + shadow space reservation clobbers RSP by an amount only known at // runtime, so it can't be undone with a fixed `add rsp, N` -- seekiln/src/parser/H/statements/for_loop.hmodified
+1−1@@ -8,7 +8,7 @@ // // The compile-time for-nesting-depth counter's save/reset/restore, for // fn_statement/lambda.c to wrap around a called body's compilation (same-// spirit as parser/vars.h's vars_save/vars_clear/vars_restore): a+// spirit as parser/H/declarations/vars.h's vars_save/vars_clear/vars_restore): a // function or lambda body gets its own RBP at runtime, so its own `for` // loops can safely reuse the same offsets independently of how deep the // enclosing code's nesting was -- see vars.h's for_level_offset comment.kiln/src/parser/H/statements/loop_stack.hmodified
+1−1@@ -36,7 +36,7 @@ void loop_pop_and_patch_breaks(void); // Save/reset/restore the loop-nesting depth, for fn_statement/lambda.c // to wrap around a called body's compilation (same spirit as-// parser/vars.h's vars_save/vars_clear/vars_restore and for_loop.h's+// parser/H/declarations/vars.h's vars_save/vars_clear/vars_restore and for_loop.h's // for_depth_save/reset/restore): a break/continue inside a function or // lambda body must never reach past that body into an ENCLOSING loop it // happens to be textually written inside.kiln/src/parser/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/parser/O/core/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/parser/O/declarations/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/parser/O/imports/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/parser/O/statements/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/src/pe/C/pe_dll_writer.cmodified
+9−9@@ -1,25 +1,25 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "pe/pe_dll_writer.h"-#include "codegen/heap.h"-#include "codegen/bytes.h"-#include "codegen/string_alloc.h"-#include "codegen/print_int.h"-#include "codegen/errors.h"-#include "target.h"+#include "pe/H/pe_dll_writer.h"+#include "codegen/H/runtime/heap.h"+#include "codegen/H/emit/bytes.h"+#include "codegen/H/strings/string_alloc.h"+#include "codegen/H/runtime/print_int.h"+#include "codegen/H/runtime/errors.h"+#include "app/H/target.h" // Hand-written PE32+ DLL: IMAGE_FILE_DLL characteristic, an Export Data // Directory instead of an Import one -- the Windows-side twin of-// elf/elf_so_writer.c. The Windows loader resolves imports-by-name via a+// elf/C/elf_so_writer.c. The Windows loader resolves imports-by-name via a // BINARY SEARCH over the DLL's Name Pointer Table, which means (unlike // ELF's hash-table symbol lookup) that table must be in sorted order, or // GetProcAddress-style resolution silently fails to find some exports -- // see the sort below. static const char *const export_names[] = { #define RUNTIME_EXPORT(name, str) str,-#include "codegen/runtime_exports.def"+#include "codegen/H/emit/runtime_exports.def" #undef RUNTIME_EXPORT }; kiln/src/pe/C/pe_dynamic.cmodified
+4−4@@ -1,26 +1,26 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "pe/pe_writer.h"+#include "pe/H/pe_writer.h" // --link=shared PE executable: same "tiny PE" single-RWX-section // technique as pe_writer.c's static-mode writer, but importing from TWO // DLLs (kernel32.dll for OS calls, libkilnrt.dll for the runtime -- see-// pe/pe_dll_writer.h for the library side).+// pe/H/pe_dll_writer.h for the library side). // // Section layout: // [globals][import dir: k32,rt,null][ILT k32][IAT k32][ILT rt][IAT rt] // [code][hint/name: k32's 9, rt's 5][kernel32.dll][libkilnrt.dll] static const char *const pe_import_names[] = { #define PE_IMPORT(name, str) str,-#include "pe/pe_imports.def"+#include "pe/H/pe_imports.def" #undef PE_IMPORT }; static const char *const runtime_import_names[] = { #define RUNTIME_EXPORT(name, str) str,-#include "codegen/runtime_exports.def"+#include "codegen/H/emit/runtime_exports.def" #undef RUNTIME_EXPORT }; kiln/src/pe/C/pe_writer.cmodified
+4−4@@ -1,11 +1,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h>-#include "pe/pe_writer.h"-#include "target.h"+#include "pe/H/pe_writer.h"+#include "app/H/target.h" // Hand-written minimal PE32+ console executable -- the Windows-side twin-// of elf/elf_writer.c's "tiny ELF" technique: one RWX section holding+// of elf/C/elf_writer.c's "tiny ELF" technique: one RWX section holding // everything (globals, import tables, code), a fixed non-relocated image // base, no external linker involved. //@@ -20,7 +20,7 @@ static const char *const pe_import_names[] = { #define PE_IMPORT(name, str) str,-#include "pe/pe_imports.def"+#include "pe/H/pe_imports.def" #undef PE_IMPORT }; kiln/src/pe/D/pe_dll_writer.dadded
+21−0@@ -0,0 +1,21 @@+src/pe/O/pe_dll_writer.o: src/pe/C/pe_dll_writer.c \+ src/pe/H/pe_dll_writer.h src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_writer.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \+ src/pe/H/pe_imports.def src/codegen/H/runtime/heap.h \+ src/codegen/H/emit/bytes.h src/codegen/H/strings/string_alloc.h \+ src/codegen/H/runtime/print_int.h src/codegen/H/runtime/errors.h \+ src/app/H/target.h+src/pe/H/pe_dll_writer.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_writer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_layout.h:+src/pe/H/pe_imports.def:+src/codegen/H/runtime/heap.h:+src/codegen/H/emit/bytes.h:+src/codegen/H/strings/string_alloc.h:+src/codegen/H/runtime/print_int.h:+src/codegen/H/runtime/errors.h:+src/app/H/target.h:kiln/src/pe/D/pe_dynamic.dadded
+10−0@@ -0,0 +1,10 @@+src/pe/O/pe_dynamic.o: src/pe/C/pe_dynamic.c src/pe/H/pe_writer.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def+src/pe/H/pe_writer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:kiln/src/pe/D/pe_writer.dadded
+12−0@@ -0,0 +1,12 @@+src/pe/O/pe_writer.o: src/pe/C/pe_writer.c src/pe/H/pe_writer.h \+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \+ src/codegen/H/emit/runtime_import_enum.h \+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \+ src/app/H/target.h+src/pe/H/pe_writer.h:+src/codegen/H/emit/emit.h:+src/codegen/H/emit/runtime_layout.h:+src/codegen/H/emit/runtime_import_enum.h:+src/codegen/H/emit/runtime_exports.def:+src/pe/H/pe_imports.def:+src/app/H/target.h:kiln/src/pe/H/pe_dll_writer.hmodified
+3−3@@ -1,7 +1,7 @@ #ifndef KILN_PE_DLL_WRITER_H #define KILN_PE_DLL_WRITER_H-#include "codegen/runtime_import_enum.h"-#include "pe/pe_writer.h"+#include "codegen/H/emit/runtime_import_enum.h"+#include "pe/H/pe_writer.h" // libkilnrt.dll: same fixed-base, no-ASLR, no-relocations philosophy as // every other kiln output (a real DLL would normally get a .reloc@@ -16,7 +16,7 @@ // IMAGE_EXPORT_DIRECTORY (40 bytes) + 3 fixed-size arrays (sized only by // RUNTIME_IMPORT_COUNT_, never by name length) -- code starts right after, // so its address is a compile-time constant kiln_code_base() can use-// (see codegen/layout.c); the variable-length name strings go in the+// (see codegen/C/emit/layout.c); the variable-length name strings go in the // tail after code, same trick as pe_writer.h's hint/name table. #define KILN_PE_DLL_EXPORT_DIR_ADDR (KILN_PE_DLL_IMAGE_BASE + KILN_PE_DLL_SECTION_RVA) #define KILN_PE_DLL_EXPORT_DIR_SIZE 40ukiln/src/pe/H/pe_writer.hmodified
+8−8@@ -1,11 +1,11 @@ #ifndef KILN_PE_WRITER_H #define KILN_PE_WRITER_H-#include "codegen/emit.h"-#include "codegen/runtime_layout.h"-#include "codegen/runtime_import_enum.h"+#include "codegen/H/emit/emit.h"+#include "codegen/H/emit/runtime_layout.h"+#include "codegen/H/emit/runtime_import_enum.h" // Kiln generates a fixed, non-relocated PE32+ executable, same "always-// loaded at one known address" philosophy as elf/elf_writer.h's+// loaded at one known address" philosophy as elf/H/elf_writer.h's // KILN_LOAD_BASE -- absolute addresses for string literals, closure code // addresses, and (this file's addition) imported-function IAT slots are // all known at compile time, no relocation table needed. 0x140000000 is@@ -33,15 +33,15 @@ #define KILN_PE_TRY_HANDLERS_ADDR (KILN_PE_TRY_DEPTH_ADDR + KILN_TRY_DEPTH_SIZE) // No argv slot: GetCommandLineA() can be called at any point, unlike // Linux's argv() which has to snapshot the kernel's original RSP before-// anything else touches it (see codegen/argv_builtin.c).+// anything else touches it (see codegen/C/io/argv_builtin.c). #define KILN_PE_GLOBALS_SIZE (8 + KILN_TRY_DEPTH_SIZE + KILN_TRY_HANDLERS_SIZE) // Every kernel32.dll function kiln's Windows codegen calls -- single list // in pe_imports.def, shared by this enum and pe_writer.c's actual table // bytes, so the two can never silently drift out of sync. typedef enum { #define PE_IMPORT(name, str) PE_IMPORT_##name,-#include "pe/pe_imports.def"+#include "pe/H/pe_imports.def" #undef PE_IMPORT PE_IMPORT_COUNT_ } PeImport;@@ -65,13 +65,13 @@ typedef enum { (KILN_PE_SECTION_RVA + (KILN_PE_GLOBALS_SIZE + KILN_PE_IMPORT_DIR_SIZE + KILN_PE_ILT_SIZE + KILN_PE_IAT_SIZE)) // Absolute VA of `which`'s IAT slot -- what the loader overwrites with-// the resolved function pointer at load time. codegen/win_call.c loads+// the resolved function pointer at load time. codegen/C/platform/win_call.c loads // this address, dereferences it, and calls through the result (see that // file for why no RIP-relative addressing is needed here). uint64_t pe_import_addr(PeImport which); // ---- --link=shared layout: a SECOND imported DLL (libkilnrt.dll,-// see pe/pe_dll_writer.h) alongside kernel32.dll. Kept as a fully+// see pe/H/pe_dll_writer.h) alongside kernel32.dll. Kept as a fully // parallel set of constants, never touched by the static-mode ones // above, so --link=static output stays byte-for-byte unchanged -- // pe_writer.c picks one whole layout or the other based on link mode,kiln/src/pe/O/.gitkeepadded
+0−0No content changes. View the file on GitHub
kiln/tests/scripts/imports_circular_check.shmodified
+3−3@@ -1,11 +1,11 @@ #!/usr/bin/env bash-# kiln/tests/imports_circular_check.sh -- not part of run_regression.sh's+# kiln/tests/scripts/imports_circular_check.sh -- not part of run_regression.sh's # stdout-diff loop, since this test asserts a COMPILE FAILURE with # specific message content, not a successful program's stdout. set -uo pipefail-cd "$(dirname "$0")/.."+cd "$(dirname "$0")/../.." -OUT=$(../bin/kiln tests/fixtures/imports_circular_a.ash -o /tmp/imports_circular_a 2>&1)+OUT=$(../bin/kiln tests/cases/imports/fixtures/imports_circular_a.ash -o /tmp/imports_circular_a 2>&1) STATUS=$? if [[ $STATUS -eq 0 ]]; thenkiln/tests/scripts/imports_collision_check.shmodified
+3−3@@ -1,12 +1,12 @@ #!/usr/bin/env bash-# kiln/tests/imports_collision_check.sh -- asserts BOTH resolved paths+# kiln/tests/scripts/imports_collision_check.sh -- asserts BOTH resolved paths # appear in the error message, not just that a compile error fires (see # the design spec's "Testing plan" section -- with no `as` clause to # disambiguate, this message is the only diagnostic a user gets). set -uo pipefail-cd "$(dirname "$0")/.."+cd "$(dirname "$0")/../.." -OUT=$(../bin/kiln tests/fixtures/imports_collision_main.ash -o /tmp/imports_collision_main 2>&1)+OUT=$(../bin/kiln tests/cases/imports/fixtures/imports_collision_main.ash -o /tmp/imports_collision_main 2>&1) STATUS=$? if [[ $STATUS -eq 0 ]]; thenkiln/tests/scripts/run_regression.shmodified
+3−3@@ -1,7 +1,7 @@ #!/usr/bin/env bash-# kiln/tests/run_regression.sh baseline|check+# kiln/tests/scripts/run_regression.sh baseline|check set -uo pipefail-cd "$(dirname "$0")/.." # -> kiln/+cd "$(dirname "$0")/../.." # -> kiln/ MODE="${1:-check}" if [[ "$MODE" != "baseline" && "$MODE" != "check" ]]; then@@ -21,7 +21,7 @@ rm -f /tmp/kiln_file_test.txt make -s || { echo "build failed"; exit 1; } fail=0-for f in tests/*.ash; do+for f in tests/cases/*/*.ash; do name=$(basename "$f" .ash) bin="$BINDIR/${name}.bin" out="$OUTDIR/${name}.out"