← Commit history

Look at CHANGELOG.md for Info

lennoxrose committed on Oct 7, 2026 at 00:35 UTC

712bdeaparentc71f74d

248 files changed+1771−677

.gitignoremodified

+2−1
@@ -15,8 +15,9 @@ ashvm/benchmarks/native_jit
1515 *~
1616
1717 # Dont put ai Slop in my Code
18-.claude
1918 CLAUDE.md
19+AGENTS.md
20+.claude
2021 .agents
2122 skills-lock.json
2223

CHANGELOG.mdmodified

+15−0
@@ -1,3 +1,18 @@
1+## 2026-10-07 (back on Ash + source and test restructure)
2+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.
3+
4+**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.
5+
6+- **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.
7+- **ashvm:** same four-tree layout for every subsystem (no `D/` tree, because its Makefile never produced dependency files); `common.h` moved to `app/H/`.
8+- **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.
9+- **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.
10+- **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.
11+
12+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.
13+
14+Next up: the high-level, Lua-style syntax from `plans.md`, without losing the VM's and Kiln's speed.
15+
116 ## 2026-07-21 (modules/imports + library storage, both engines)
217 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/`.
318

README.mdmodified

+6−2
@@ -93,9 +93,13 @@ compiler/ single-pass compiler: parser/emitter state, expression chain,
9393 call/lambda emission, statement compilation
9494 builtins/ len, map, filter, reduce, string/file ops
9595 diagnostics/ shared Rust-style error reporting (compile-time and runtime)
96-main.c entry point (file mode + REPL)
96+
97+Every subsystem keeps sources in `C/`, headers in `H/`, and build output in a
98+mirrored `O/` tree (kiln also has `D/` for dependency files), e.g.
99+`src/vm/C/dispatch.c` includes `src/vm/H/vm.h` and builds to `src/vm/O/dispatch.o`.
100+app/ main.c entry point (file mode + REPL)
97101 benchmarks/ .ash and .cpp benchmark programs, plus the x86-64 JIT experiment
98-tests/ example programs covering each language feature
102+tests/ cases/<feature>/*.ash programs covering each language feature; scripts/ holds the regression runners
99103 kiln/ a standalone .ash compiler (Windows + Linux). Not started yet.
100104
101105 ## Editor support

ashvm/Makefilemodified

+38−7
@@ -1,14 +1,45 @@
11 CC = gcc
2+.DEFAULT_GOAL := all
23 CFLAGS = -Wall -Wextra -std=c11 -O2 -Isrc
34 LDFLAGS = -lm
45
5-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 \
6- src/compiler/state.c src/compiler/expr.c src/compiler/calls.c src/compiler/stmt.c src/compiler/stmt_control.c \
7- src/compiler/import_paths.c src/compiler/stmt_import.c src/compiler/constants.c \
8- src/builtins/builtins.c src/builtins/core.c src/builtins/collection.c src/builtins/string.c src/builtins/file.c \
9- src/vm/state.c src/vm/errors.c src/vm/dispatch.c src/vm/api.c \
10- src/diagnostics/diagnostics.c
11-ASHVM_OBJ = $(ASHVM_SRC:.c=.o)
6+ASHVM_SRC = \
7+ src/app/C/main.c \
8+ src/lexer/C/lexer.c \
9+ src/lexer/C/lexer_import.c \
10+ src/value/C/hashmap.c \
11+ src/value/C/value.c \
12+ src/vm/C/api.c \
13+ src/vm/C/chunk.c \
14+ src/vm/C/dispatch.c \
15+ src/vm/C/errors.c \
16+ src/vm/C/state.c \
17+ src/compiler/C/calls.c \
18+ src/compiler/C/constants.c \
19+ src/compiler/C/expr.c \
20+ src/compiler/C/import_paths.c \
21+ src/compiler/C/state.c \
22+ src/compiler/C/stmt.c \
23+ src/compiler/C/stmt_control.c \
24+ src/compiler/C/stmt_import.c \
25+ src/builtins/C/builtins.c \
26+ src/builtins/C/collection.c \
27+ src/builtins/C/core.c \
28+ src/builtins/C/file.c \
29+ src/builtins/C/string.c \
30+ src/diagnostics/C/diagnostics.c
31+
32+# Objects and dependency files live in trees parallel to each C tree:
33+# src/<subsystem>/C/<feature>/x.c -> src/<subsystem>/O/<feature>/x.o
34+obj_of = $(patsubst %.c,%.o,$(subst /C/,/O/,$(1)))
35+ASHVM_OBJ = $(foreach s,$(ASHVM_SRC),$(call obj_of,$(s)))
36+
37+define compile_rule
38+$(call obj_of,$(1)): $(1)
39+ @mkdir -p $$(dir $$@)
40+ $$(CC) $$(CFLAGS) -c $$< -o $$@
41+endef
42+$(foreach s,$(ASHVM_SRC),$(eval $(call compile_rule,$(s))))
1243
1344 BIN = ../bin/ashvm
1445

ashvm/src/app/C/main.cmodified

+3−3
@@ -2,9 +2,9 @@
22 #include <stdlib.h>
33 #include <string.h>
44 #include <setjmp.h>
5-#include "compiler/compiler.h"
6-#include "vm/vm.h"
7-#include "diagnostics/diagnostics.h"
5+#include "compiler/H/compiler.h"
6+#include "vm/H/vm.h"
7+#include "diagnostics/H/diagnostics.h"
88
99 static char *read_file(const char *path) {
1010 FILE *file = fopen(path, "rb");

ashvm/src/app/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

ashvm/src/builtins/C/builtins.cmodified

+3−3
@@ -1,7 +1,7 @@
11 #include <string.h>
2-#include "builtins/builtins.h"
3-#include "builtins/internal.h"
4-#include "vm/vm.h"
2+#include "builtins/H/builtins.h"
3+#include "builtins/H/internal.h"
4+#include "vm/H/vm.h"
55
66 static const char *builtin_names[] = {
77 "len", "push", "input", "str", "num", "sqrt", "abs", "floor",

ashvm/src/builtins/C/collection.cmodified

+3−3
@@ -1,8 +1,8 @@
11 #include <stdlib.h>
22 #include <string.h>
3-#include "builtins/internal.h"
4-#include "vm/vm.h"
5-#include "value/hashmap.h"
3+#include "builtins/H/internal.h"
4+#include "vm/H/vm.h"
5+#include "value/H/hashmap.h"
66
77 VMValue vm_call_builtin_collection(int id, VMValue *args, int argc) {
88 switch (id) {

ashvm/src/builtins/C/core.cmodified

+3−3
@@ -2,9 +2,9 @@
22 #include <stdlib.h>
33 #include <string.h>
44 #include <math.h>
5-#include "builtins/internal.h"
6-#include "vm/vm.h"
7-#include "value/hashmap.h"
5+#include "builtins/H/internal.h"
6+#include "vm/H/vm.h"
7+#include "value/H/hashmap.h"
88
99 VMValue vm_call_builtin_core(int id, VMValue *args, int argc) {
1010 switch (id) {

ashvm/src/builtins/C/file.cmodified

+2−2
@@ -1,8 +1,8 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "builtins/internal.h"
5-#include "vm/vm.h"
4+#include "builtins/H/internal.h"
5+#include "vm/H/vm.h"
66
77 VMValue vm_call_builtin_file(int id, VMValue *args, int argc) {
88 switch (id) {

ashvm/src/builtins/C/string.cmodified

+2−2
@@ -1,8 +1,8 @@
11 #include <stdlib.h>
22 #include <string.h>
33 #include <ctype.h>
4-#include "builtins/internal.h"
5-#include "vm/vm.h"
4+#include "builtins/H/internal.h"
5+#include "vm/H/vm.h"
66
77 VMValue vm_call_builtin_string(int id, VMValue *args, int argc) {
88 switch (id) {

ashvm/src/builtins/H/builtins.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef ASH_VM_BUILTINS_H
22 #define ASH_VM_BUILTINS_H
3-#include "value/value.h"
3+#include "value/H/value.h"
44
55 int vm_builtin_lookup(const char *name, int len);
66 VMValue vm_call_builtin(int id, VMValue *args, int argc);

ashvm/src/builtins/H/internal.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef ASH_VM_BUILTINS_INTERNAL_H
22 #define ASH_VM_BUILTINS_INTERNAL_H
3-#include "value/value.h"
3+#include "value/H/value.h"
44
55 // Each group handles a contiguous id range within vm_call_builtin's switch;
66 // see builtins.c for the range -> group mapping and the shared name table.

ashvm/src/builtins/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

ashvm/src/compiler/C/calls.cmodified

+3−3
@@ -1,9 +1,9 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "compiler/internal.h"
5-#include "builtins/builtins.h"
6-#include "diagnostics/diagnostics.h"
4+#include "compiler/H/internal.h"
5+#include "builtins/H/builtins.h"
6+#include "diagnostics/H/diagnostics.h"
77
88 void emit_call(Token id) {
99 int builtin_id = vm_builtin_lookup(id.start, id.length);

ashvm/src/compiler/C/constants.cmodified

+3−3
@@ -1,9 +1,9 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "compiler/constants.h"
5-#include "compiler/internal.h"
6-#include "diagnostics/diagnostics.h"
4+#include "compiler/H/constants.h"
5+#include "compiler/H/internal.h"
6+#include "diagnostics/H/diagnostics.h"
77
88 static VMConstant constants[MAX_VM_CONSTS];
99 static int constant_count = 0;

ashvm/src/compiler/C/expr.cmodified

+2−2
@@ -1,7 +1,7 @@
11 #include <stdio.h>
22 #include <stdlib.h>
3-#include "compiler/internal.h"
4-#include "diagnostics/diagnostics.h"
3+#include "compiler/H/internal.h"
4+#include "diagnostics/H/diagnostics.h"
55
66 // Precedence climbing: expression -> logical_or -> logical_and ->
77 // comparison -> additive -> term -> unary -> postfix -> primary.

ashvm/src/compiler/C/import_paths.cmodified

+1−1
@@ -2,7 +2,7 @@
22 #include <string.h>
33 #include <stdio.h>
44 #include <stdlib.h>
5-#include "compiler/import_paths.h"
5+#include "compiler/H/import_paths.h"
66
77 void import_path_dirname(const char *path, char *out, int out_size) {
88 const char *slash = strrchr(path, '/');

ashvm/src/compiler/C/state.cmodified

+2−2
@@ -1,7 +1,7 @@
11 #include <stdlib.h>
22 #include <string.h>
3-#include "compiler/state.h"
4-#include "diagnostics/diagnostics.h"
3+#include "compiler/H/state.h"
4+#include "diagnostics/H/diagnostics.h"
55
66 VMFunction vm_functions[MAX_VM_FUNCS];
77 int vm_function_count = 0;

ashvm/src/compiler/C/stmt.cmodified

+2−2
@@ -1,8 +1,8 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "compiler/internal.h"
5-#include "diagnostics/diagnostics.h"
4+#include "compiler/H/internal.h"
5+#include "diagnostics/H/diagnostics.h"
66
77 // statement() is shared between top-level parsing (compile()'s own loop,
88 // and stmt_import.c's parse_imported_file_body()) and here, inside a

ashvm/src/compiler/C/stmt_control.cmodified

+2−2
@@ -1,7 +1,7 @@
11 #include <stdlib.h>
22 #include <string.h>
3-#include "compiler/internal.h"
4-#include "diagnostics/diagnostics.h"
3+#include "compiler/H/internal.h"
4+#include "diagnostics/H/diagnostics.h"
55
66 // Each function here assumes statement() already consumed the keyword token
77 // (TOKEN_FN / TOKEN_IF / TOKEN_TRY / TOKEN_WHILE) that identified it.

ashvm/src/compiler/C/stmt_import.cmodified

+4−4
@@ -3,9 +3,9 @@
33 #include <stdio.h>
44 #include <stdlib.h>
55 #include <limits.h>
6-#include "compiler/internal.h"
7-#include "compiler/import_paths.h"
8-#include "diagnostics/diagnostics.h"
6+#include "compiler/H/internal.h"
7+#include "compiler/H/import_paths.h"
8+#include "diagnostics/H/diagnostics.h"
99
1010 #define MAX_VM_IMPORTS 16
1111 #define MAX_VM_IMPORT_DEPTH 8
@@ -178,7 +178,7 @@ void compile_import_stmt(void) {
178178 resolving_depth++;
179179
180180 // --- Save everything the recursive parse of the imported file will
181- // clobber, mirroring compiler/state.c's own save-recurse-restore
181+ // clobber, mirroring compiler/C/state.c's own save-recurse-restore
182182 // pattern for locals (the C call stack gives correct nesting for
183183 // free, same as those). ---
184184 DiagnosticsSource saved_diag = diagnostics_save_source();

ashvm/src/compiler/H/compiler.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef ASH_VM_COMPILER_H
22 #define ASH_VM_COMPILER_H
3-#include "vm/chunk.h"
3+#include "vm/H/chunk.h"
44
55 #define MAX_VM_FUNCS 64
66 #define MAX_VM_LOCALS 128

ashvm/src/compiler/H/constants.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef ASH_VM_COMPILER_CONSTANTS_H
22 #define ASH_VM_COMPILER_CONSTANTS_H
3-#include "value/value.h"
3+#include "value/H/value.h"
44
55 #define MAX_VM_CONSTS 32
66

ashvm/src/compiler/H/internal.hmodified

+2−2
@@ -1,7 +1,7 @@
11 #ifndef ASH_VM_COMPILER_INTERNAL_H
22 #define ASH_VM_COMPILER_INTERNAL_H
3-#include "compiler/state.h"
4-#include "compiler/constants.h"
3+#include "compiler/H/state.h"
4+#include "compiler/H/constants.h"
55
66 // Cross-file forward declarations between compiler_expr.c and
77 // compiler_stmt.c -- not part of the public API (compiler.h).

ashvm/src/compiler/H/state.hmodified

+2−2
@@ -1,7 +1,7 @@
11 #ifndef ASH_VM_COMPILER_STATE_H
22 #define ASH_VM_COMPILER_STATE_H
3-#include "compiler/compiler.h"
4-#include "lexer/lexer.h"
3+#include "compiler/H/compiler.h"
4+#include "lexer/H/lexer.h"
55
66 // Shared parser/emitter state for compiler_expr.c and compiler_stmt.c --
77 // not part of the public API (compiler.h). Mirrors the same

ashvm/src/compiler/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

ashvm/src/diagnostics/C/diagnostics.cmodified

+1−1
@@ -2,7 +2,7 @@
22 #include <stdio.h>
33 #include <string.h>
44 #include <unistd.h>
5-#include "diagnostics/diagnostics.h"
5+#include "diagnostics/H/diagnostics.h"
66
77 static const char *g_source = NULL;
88 static const char *g_filename = "source";

ashvm/src/diagnostics/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

ashvm/src/lexer/C/lexer.cmodified

+3−3
@@ -1,11 +1,11 @@
11 #include <string.h>
22 #include <ctype.h>
3-#include "lexer/lexer.h"
4-#include "lexer/lexer_import.h"
3+#include "lexer/H/lexer.h"
4+#include "lexer/H/lexer_import.h"
55
66 // lex_* (not the bare start/current/line these had as file-static
77 // before) -- shared with lexer_import.c now, and a plain `current` would
8-// collide with compiler/state.h's own global `Token current` at link time.
8+// collide with compiler/H/state.h's own global `Token current` at link time.
99 const char *lex_start;
1010 const char *lex_current;
1111 int lex_line;

ashvm/src/lexer/C/lexer_import.cmodified

+1−1
@@ -1,4 +1,4 @@
1-#include "lexer/lexer_import.h"
1+#include "lexer/H/lexer_import.h"
22
33 LexerState lexer_save_state(void) {
44 LexerState state;

ashvm/src/lexer/H/lexer_import.hmodified

+2−2
@@ -1,6 +1,6 @@
11 #ifndef ASHVM_LEXER_IMPORT_H
22 #define ASHVM_LEXER_IMPORT_H
3-#include "lexer/lexer.h"
3+#include "lexer/H/lexer.h"
44
55 // Cross-file link between lexer.c (the tokenizer's cursor state and its
66 // low-level scan primitives) and lexer_import.c (state save/restore plus
@@ -13,7 +13,7 @@
1313 // between lexer.h (public surface) and lexer_import.h (private,
1414 // cross-file plumbing).
1515 //
16-// Named lex_* rather than the bare start/current/line: compiler/state.h
16+// Named lex_* rather than the bare start/current/line: compiler/H/state.h
1717 // already declares its own global `Token current`, and since these now
1818 // need external linkage to be shared across the two .c files, a second
1919 // plain `current` global here would collide with it at link time.

ashvm/src/lexer/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

ashvm/src/value/C/hashmap.cmodified

+1−1
@@ -1,6 +1,6 @@
11 #include <stdlib.h>
22 #include <string.h>
3-#include "value/hashmap.h"
3+#include "value/H/hashmap.h"
44
55 static unsigned long hash_string(const char *s) {
66 unsigned long h = 5381;

ashvm/src/value/C/value.cmodified

+2−2
@@ -1,8 +1,8 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "value/value.h"
5-#include "value/hashmap.h"
4+#include "value/H/value.h"
5+#include "value/H/hashmap.h"
66
77 VMValue vm_num(double n) {
88 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 @@
11 #ifndef ASH_VM_HASHMAP_H
22 #define ASH_VM_HASHMAP_H
3-#include "value/value.h"
3+#include "value/H/value.h"
44
55 typedef struct {
66 char *key;

ashvm/src/value/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

ashvm/src/vm/C/api.cmodified

+3−3
@@ -1,8 +1,8 @@
11 #include <stdio.h>
22 #include <stdlib.h>
3-#include "vm/vm.h"
4-#include "vm/state.h"
5-#include "compiler/compiler.h"
3+#include "vm/H/vm.h"
4+#include "vm/H/state.h"
5+#include "compiler/H/compiler.h"
66
77 void vm_set_repl_recovery(jmp_buf *jb) {
88 repl_recovery_jmp = jb;

ashvm/src/vm/C/chunk.cmodified

+1−1
@@ -1,5 +1,5 @@
11 #include <stdlib.h>
2-#include "vm/chunk.h"
2+#include "vm/H/chunk.h"
33
44 void chunk_init(Chunk *c) {
55 c->count = 0; c->capacity = 0; c->code = NULL;

ashvm/src/vm/C/dispatch.cmodified

+5−5
@@ -3,11 +3,11 @@
33 #include <string.h>
44 #include <setjmp.h>
55 #include <math.h>
6-#include "vm/vm.h"
7-#include "vm/state.h"
8-#include "compiler/compiler.h"
9-#include "builtins/builtins.h"
10-#include "value/hashmap.h"
6+#include "vm/H/vm.h"
7+#include "vm/H/state.h"
8+#include "compiler/H/compiler.h"
9+#include "builtins/H/builtins.h"
10+#include "value/H/hashmap.h"
1111
1212 // The dispatch loop stays one function despite exceeding this project's
1313 // usual 200-line target: computed-goto (`&&label` / `goto *table[i]`)

ashvm/src/vm/C/errors.cmodified

+3−3
@@ -1,9 +1,9 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <stdarg.h>
4-#include "vm/vm.h"
5-#include "vm/state.h"
6-#include "diagnostics/diagnostics.h"
4+#include "vm/H/vm.h"
5+#include "vm/H/state.h"
6+#include "diagnostics/H/diagnostics.h"
77
88 // Every genuinely-runtime error (as opposed to a compile-time/structural one,
99 // which stays a hard crash since ashvm resolves names at compile time) funnels

ashvm/src/vm/C/state.cmodified

+1−1
@@ -1,5 +1,5 @@
11 #include <stddef.h>
2-#include "vm/state.h"
2+#include "vm/H/state.h"
33
44 VMValue stack[STACK_MAX];
55 VMValue *stack_top;

ashvm/src/vm/H/chunk.hmodified

+1−1
@@ -1,7 +1,7 @@
11 #ifndef ASH_VM_CHUNK_H
22 #define ASH_VM_CHUNK_H
33 #include <stdint.h>
4-#include "value/value.h"
4+#include "value/H/value.h"
55
66 typedef enum {
77 OP_CONST,

ashvm/src/vm/H/state.hmodified

+1−1
@@ -1,7 +1,7 @@
11 #ifndef ASH_VM_STATE_H
22 #define ASH_VM_STATE_H
33 #include <setjmp.h>
4-#include "vm/chunk.h"
4+#include "vm/H/chunk.h"
55
66 // Internal VM state shared between vm_dispatch.c, vm_errors.c, and vm_api.c
77 // -- not part of the public API (vm.h). Mirrors the same

ashvm/src/vm/H/vm.hmodified

+1−1
@@ -1,7 +1,7 @@
11 #ifndef ASH_VM_VM_H
22 #define ASH_VM_VM_H
33 #include <setjmp.h>
4-#include "vm/chunk.h"
4+#include "vm/H/chunk.h"
55
66 void vm_run(Chunk *main_chunk);
77 void vm_run_from(Chunk *chunk, int start_offset, int is_first_call);

ashvm/src/vm/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

ashvm/tests/scripts/imports_circular_check.shmodified

+2−2
@@ -1,8 +1,8 @@
11 #!/usr/bin/env bash
22 set -uo pipefail
3-cd "$(dirname "$0")/.."
3+cd "$(dirname "$0")/../.."
44
5-OUT=$(../bin/ashvm tests/fixtures/imports_circular_a.ash 2>&1)
5+OUT=$(../bin/ashvm tests/cases/imports/fixtures/imports_circular_a.ash 2>&1)
66 STATUS=$?
77
88 if [[ $STATUS -eq 0 ]]; then

ashvm/tests/scripts/imports_collision_check.shmodified

+2−2
@@ -1,8 +1,8 @@
11 #!/usr/bin/env bash
22 set -uo pipefail
3-cd "$(dirname "$0")/.."
3+cd "$(dirname "$0")/../.."
44
5-OUT=$(../bin/ashvm tests/fixtures/imports_collision_main.ash 2>&1)
5+OUT=$(../bin/ashvm tests/cases/imports/fixtures/imports_collision_main.ash 2>&1)
66 STATUS=$?
77
88 if [[ $STATUS -eq 0 ]]; then

ashvm/tests/scripts/run_regression.shmodified

+7−7
@@ -1,11 +1,11 @@
11 #!/usr/bin/env bash
2-# ashvm/tests/run_regression.sh baseline|check
3-# Compiles+runs every ashvm/tests/*.ash and diffs stdout against a
4-# captured baseline -- mirrors kiln/tests/run_regression.sh. ashvm has no
2+# ashvm/tests/scripts/run_regression.sh baseline|check
3+# Compiles+runs every ashvm/tests/cases/*/*.ash and diffs stdout against a
4+# captured baseline -- mirrors kiln/tests/scripts/run_regression.sh. ashvm has no
55 # --target/--link flags and no input()-driven test today, so this is
66 # simpler than kiln's version.
77 set -uo pipefail
8-cd "$(dirname "$0")/.." # -> ashvm/
8+cd "$(dirname "$0")/../.." # -> ashvm/
99
1010 MODE="${1:-check}"
1111 if [[ "$MODE" != "baseline" && "$MODE" != "check" ]]; then
@@ -21,7 +21,7 @@ rm -f /tmp/ash_test.txt
2121
2222 make -s || { echo "build failed"; exit 1; }
2323
24-for f in tests/*.ash; do
24+for f in tests/cases/*/*.ash; do
2525 name=$(basename "$f" .ash)
2626 out="$OUTDIR/${name}.out"
2727 if ! ../bin/ashvm "$f" > "$out" 2>&1; then
@@ -50,10 +50,10 @@ for f in "$OUTDIR"/*.out; do
5050 fail=1
5151 fi
5252 done
53-if ! ./tests/imports_circular_check.sh; then
53+if ! ./tests/scripts/imports_circular_check.sh; then
5454 fail=1
5555 fi
56-if ! ./tests/imports_collision_check.sh; then
56+if ! ./tests/scripts/imports_collision_check.sh; then
5757 fail=1
5858 fi
5959

kiln/Makefilemodified

+85−23
@@ -1,34 +1,96 @@
11 CC = gcc
2+.DEFAULT_GOAL := all
3+CFLAGS = -Wall -Wextra -std=c11 -O2 -Isrc
4+LDFLAGS =
5+
6+KILN_SRC = \
7+ src/app/C/main.c \
8+ src/app/C/target.c \
9+ src/lexer/C/lexer.c \
10+ src/lexer/C/lexer_import.c \
11+ src/parser/C/core/parser.c \
12+ src/parser/C/declarations/constants.c \
13+ src/parser/C/declarations/functions.c \
14+ src/parser/C/declarations/vars.c \
15+ src/parser/C/imports/import_paths.c \
16+ src/parser/C/imports/imports.c \
17+ src/parser/C/statements/for_loop.c \
18+ src/parser/C/statements/loop_stack.c \
19+ src/parser/C/statements/parser_control.c \
20+ src/parser/C/statements/try_catch.c \
21+ src/codegen/C/builtins/builtins.c \
22+ src/codegen/C/builtins/filter_builtin.c \
23+ src/codegen/C/builtins/map_builtin.c \
24+ src/codegen/C/builtins/math_builtins.c \
25+ src/codegen/C/builtins/num_builtin.c \
26+ src/codegen/C/builtins/reduce_builtin.c \
27+ src/codegen/C/builtins/str_builtin.c \
28+ src/codegen/C/collections/arrays.c \
29+ src/codegen/C/collections/keys_values.c \
30+ src/codegen/C/collections/maps.c \
31+ src/codegen/C/collections/maps_mutate.c \
32+ src/codegen/C/emit/bytes.c \
33+ src/codegen/C/emit/emit.c \
34+ src/codegen/C/emit/emit_mem.c \
35+ src/codegen/C/emit/emit_sse.c \
36+ src/codegen/C/emit/layout.c \
37+ src/codegen/C/expressions/expr.c \
38+ src/codegen/C/expressions/expr_bool.c \
39+ src/codegen/C/expressions/expr_call.c \
40+ src/codegen/C/functions/closures.c \
41+ src/codegen/C/functions/lambda.c \
42+ src/codegen/C/io/argv_builtin.c \
43+ src/codegen/C/io/argv_builtin_windows.c \
44+ src/codegen/C/io/file_path.c \
45+ src/codegen/C/io/input_builtin.c \
46+ src/codegen/C/io/read_file_builtin.c \
47+ src/codegen/C/io/write_file_builtins.c \
48+ src/codegen/C/platform/platform_console.c \
49+ src/codegen/C/platform/platform_file.c \
50+ src/codegen/C/platform/win_call.c \
51+ src/codegen/C/platform/win_file_call.c \
52+ src/codegen/C/runtime/errors.c \
53+ src/codegen/C/runtime/heap.c \
54+ src/codegen/C/runtime/print_int.c \
55+ src/codegen/C/strings/case_builtins.c \
56+ src/codegen/C/strings/indexof_builtin.c \
57+ src/codegen/C/strings/join_builtin.c \
58+ src/codegen/C/strings/replace_builtin.c \
59+ src/codegen/C/strings/split_builtin.c \
60+ src/codegen/C/strings/string_alloc.c \
61+ src/codegen/C/strings/strings.c \
62+ src/codegen/C/strings/substring_builtin.c \
63+ src/codegen/C/strings/trim_builtin.c \
64+ src/elf/C/elf_dynamic.c \
65+ src/elf/C/elf_dynamic_call.c \
66+ src/elf/C/elf_so_writer.c \
67+ src/elf/C/elf_writer.c \
68+ src/pe/C/pe_dll_writer.c \
69+ src/pe/C/pe_dynamic.c \
70+ src/pe/C/pe_writer.c \
71+ src/diagnostics/C/diagnostics.c
72+
73+# Objects and dependency files live in trees parallel to each C tree:
74+# src/<subsystem>/C/<feature>/x.c -> src/<subsystem>/O/<feature>/x.o
75+# src/<subsystem>/D/<feature>/x.d
76+obj_of = $(patsubst %.c,%.o,$(subst /C/,/O/,$(1)))
77+dep_of = $(patsubst %.c,%.d,$(subst /C/,/D/,$(1)))
78+KILN_OBJ = $(foreach s,$(KILN_SRC),$(call obj_of,$(s)))
79+KILN_DEP = $(foreach s,$(KILN_SRC),$(call dep_of,$(s)))
80+
281 # -MMD -MP: emit a per-object .d file listing the headers it includes, so
382 # editing a shared header (e.g. vars.h) correctly triggers a rebuild of
483 # every .o that includes it, not just files whose own .c changed. Without
584 # this, make's only dependency is "the .c is newer than the .o" -- a
685 # header-only edit silently produces a binary built from mismatched
786 # offsets/constants across files, with no error, until something crashes
887 # at runtime for reasons the source doesn't explain.
9-CFLAGS = -Wall -Wextra -std=c11 -O2 -Isrc -MMD -MP
10-LDFLAGS =
11-
12-KILN_SRC = src/main.c src/target.c src/lexer/lexer.c src/lexer/lexer_import.c \
13- 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 \
14- src/parser/import_paths.c src/parser/imports.c src/parser/constants.c \
15- 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 \
16- 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 \
17- src/codegen/math_builtins.c src/codegen/str_builtin.c src/codegen/num_builtin.c \
18- src/codegen/map_builtin.c src/codegen/filter_builtin.c src/codegen/reduce_builtin.c src/codegen/keys_values.c \
19- src/codegen/string_alloc.c src/codegen/case_builtins.c src/codegen/trim_builtin.c \
20- src/codegen/substring_builtin.c src/codegen/indexof_builtin.c \
21- src/codegen/join_builtin.c src/codegen/split_builtin.c src/codegen/replace_builtin.c \
22- src/codegen/file_path.c src/codegen/read_file_builtin.c src/codegen/write_file_builtins.c \
23- src/codegen/input_builtin.c src/codegen/argv_builtin.c src/codegen/argv_builtin_windows.c \
24- src/codegen/expr.c src/codegen/expr_call.c src/codegen/expr_bool.c src/codegen/print_int.c \
25- src/codegen/closures.c src/codegen/lambda.c src/codegen/win_call.c src/codegen/win_file_call.c \
26- src/codegen/platform_console.c src/codegen/platform_file.c \
27- src/elf/elf_writer.c src/elf/elf_dynamic.c src/elf/elf_dynamic_call.c src/elf/elf_so_writer.c \
28- src/pe/pe_writer.c src/pe/pe_dynamic.c src/pe/pe_dll_writer.c \
29- src/diagnostics/diagnostics.c
30-KILN_OBJ = $(KILN_SRC:.c=.o)
31-KILN_DEP = $(KILN_SRC:.c=.d)
88+define compile_rule
89+$(call obj_of,$(1)): $(1)
90+ @mkdir -p $$(dir $$@) $$(dir $(call dep_of,$(1)))
91+ $$(CC) $$(CFLAGS) -MMD -MP -MF $(call dep_of,$(1)) -MT $$@ -c $$< -o $$@
92+endef
93+$(foreach s,$(KILN_SRC),$(eval $(call compile_rule,$(s))))
3294
3395 BIN = ../bin/kiln
3496

kiln/README.mdmodified

+24−13
@@ -19,7 +19,7 @@ standalone, freestanding ELF64 executable - no libc, raw syscalls only.
1919
2020 ```bash
2121 cd kiln && make # builds ../bin/kiln
22-../bin/kiln tests/hello.ash -o /tmp/hello
22+../bin/kiln tests/cases/basics/hello.ash -o /tmp/hello
2323 /tmp/hello # prints 7 (1 + 2 * 3)
2424 ```
2525
@@ -40,16 +40,27 @@ cd kiln && make # builds ../bin/kiln
4040
4141 ```
4242 kiln/
43- Makefile builds ../bin/kiln
44- src/
45- lexer/ tokenizer (own copy, same shape as ashvm's)
46- parser/ token state + statement grammar
47- codegen/
48- emit.c/.h raw x86-64 instruction encoding primitives
49- expr.c/.h expression -> real arithmetic instructions
50- print_int.c/.h int-to-decimal-ASCII + write(2) + exit(2)
51- elf/
52- elf_writer.c/.h minimal "tiny ELF" executable writer
53- main.c argv parsing, drives the pipeline
54- tests/ *.ash programs exercised by hand for now
43+ Makefile builds ../bin/kiln
44+ src/ each subsystem: C/ (sources), H/ (headers), D/ (deps), O/ (objects), mirrored
45+ app/ main.c argv parsing, drives the pipeline; target.c/.h
46+ lexer/ tokenizer (own copy, same shape as ashvm's)
47+ parser/C/ H/ D/ O/
48+ core/ parser entry, shared parser state
49+ statements/ control flow, for loops, try/catch, loop stack
50+ declarations/ variables, functions, constants
51+ imports/ import resolution
52+ codegen/C/ H/ D/ O/ (same feature folders in each tree)
53+ emit/ raw x86-64 encoding, byte buffers, memory layout, value tags
54+ expressions/ expression -> arithmetic instructions, calls, booleans
55+ functions/ closures and lambdas
56+ runtime/ heap, runtime errors, int printing
57+ collections/ arrays, maps, keys/values
58+ strings/ string values, allocation, string builtins
59+ builtins/ builtin dispatch, math, map/filter/reduce, str/num
60+ io/ file, stdin and argv builtins
61+ platform/ console/file and Windows-call wrappers
62+ elf/ ELF executable and shared-object writers
63+ pe/ PE executable and DLL writers
64+ diagnostics/ error reporting
65+ tests/ cases/<feature>/*.ash programs (+ scripts/run_regression.sh)
5566 ```
\ No newline at end of file

kiln/src/app/C/main.cmodified

+10−10
@@ -1,15 +1,15 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "parser/parser.h"
5-#include "codegen/emit.h"
6-#include "elf/elf_writer.h"
7-#include "elf/elf_dynamic.h"
8-#include "elf/elf_so_writer.h"
9-#include "pe/pe_writer.h"
10-#include "pe/pe_dll_writer.h"
11-#include "diagnostics/diagnostics.h"
12-#include "target.h"
4+#include "parser/H/core/parser.h"
5+#include "codegen/H/emit/emit.h"
6+#include "elf/H/elf_writer.h"
7+#include "elf/H/elf_dynamic.h"
8+#include "elf/H/elf_so_writer.h"
9+#include "pe/H/pe_writer.h"
10+#include "pe/H/pe_dll_writer.h"
11+#include "diagnostics/H/diagnostics.h"
12+#include "app/H/target.h"
1313
1414 static char *read_file(const char *path) {
1515 FILE *file = fopen(path, "rb");
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
5252 // mode from compiling a program.
5353 if (argc >= 4 && argc <= 5 && strcmp(argv[1], "--emit-runtime") == 0 && strcmp(argv[2], "-o") == 0) {
5454 if (argc == 5) kiln_set_target(parse_target(argv[4], argv[0]));
55- // The runtime's own globals-address computation (codegen/layout.c)
55+ // The runtime's own globals-address computation (codegen/C/emit/layout.c)
5656 // needs to resolve as if for a --link=shared executable, since
5757 // that's whose globals this code reads/writes at runtime --
5858 // elf_write_shared_runtime/pe_write_shared_runtime additionally

kiln/src/app/C/target.cmodified

+1−1
@@ -1,4 +1,4 @@
1-#include "target.h"
1+#include "app/H/target.h"
22
33 static KilnTarget current_target = KILN_TARGET_LINUX;
44

kiln/src/app/D/main.dadded

+21−0
@@ -0,0 +1,21 @@
1+src/app/O/main.o: src/app/C/main.c src/parser/H/core/parser.h \
2+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h src/elf/H/elf_writer.h \
3+ src/codegen/H/emit/runtime_layout.h src/elf/H/elf_dynamic.h \
4+ src/codegen/H/emit/runtime_import_enum.h \
5+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_so_writer.h \
6+ src/pe/H/pe_writer.h src/pe/H/pe_imports.def src/pe/H/pe_dll_writer.h \
7+ src/diagnostics/H/diagnostics.h src/app/H/target.h
8+src/parser/H/core/parser.h:
9+src/lexer/H/lexer.h:
10+src/codegen/H/emit/emit.h:
11+src/elf/H/elf_writer.h:
12+src/codegen/H/emit/runtime_layout.h:
13+src/elf/H/elf_dynamic.h:
14+src/codegen/H/emit/runtime_import_enum.h:
15+src/codegen/H/emit/runtime_exports.def:
16+src/elf/H/elf_so_writer.h:
17+src/pe/H/pe_writer.h:
18+src/pe/H/pe_imports.def:
19+src/pe/H/pe_dll_writer.h:
20+src/diagnostics/H/diagnostics.h:
21+src/app/H/target.h:

kiln/src/app/D/target.dadded

+2−0
@@ -0,0 +1,2 @@
1+src/app/O/target.o: src/app/C/target.c src/app/H/target.h
2+src/app/H/target.h:

kiln/src/app/H/target.hmodified

+2−2
@@ -31,15 +31,15 @@ KilnLinkMode kiln_get_link_mode(void);
3131
3232 // Separate from KilnLinkMode on purpose: link mode answers "should THIS
3333 // routine's own call sites (heap_emit_alloc etc.) reach their callee via
34-// a local call or a GOT call" -- but codegen/layout.c's globals-address
34+// a local call or a GOT call" -- but codegen/C/emit/layout.c's globals-address
3535 // selection needs to answer a DIFFERENT question, "which executable
3636 // layout owns the globals this code will read at runtime", and that
3737 // answer is the shared-mode layout in BOTH cases: when compiling a
3838 // normal --link=shared executable AND when compiling the runtime that
3939 // goes into libkilnrt.so (its heap_alloc etc. always run on behalf of
4040 // some shared-mode executable's globals, never its own). Conflating
4141 // these into one flag was a real bug caught by testing (see
42-// elf/elf_so_writer.c's comment) -- kiln_set_link_mode(STATIC) to get
42+// elf/C/elf_so_writer.c's comment) -- kiln_set_link_mode(STATIC) to get
4343 // local intra-.so calls also silently broke the globals address.
4444 void kiln_set_compiling_so(int flag);
4545 int kiln_is_compiling_so(void);

kiln/src/app/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/C/builtins/builtins.cmodified

+13−13
@@ -1,17 +1,17 @@
11 #include <string.h>
2-#include "codegen/builtins.h"
3-#include "codegen/expr.h"
4-#include "codegen/arrays.h"
5-#include "codegen/maps.h"
6-#include "codegen/math_builtins.h"
7-#include "codegen/convert_builtins.h"
8-#include "codegen/higher_order.h"
9-#include "codegen/keys_values.h"
10-#include "codegen/string_builtins.h"
11-#include "codegen/file_builtins.h"
12-#include "codegen/input_builtin.h"
13-#include "codegen/argv_builtin.h"
14-#include "parser/parser.h"
2+#include "codegen/H/builtins/builtins.h"
3+#include "codegen/H/expressions/expr.h"
4+#include "codegen/H/collections/arrays.h"
5+#include "codegen/H/collections/maps.h"
6+#include "codegen/H/builtins/math_builtins.h"
7+#include "codegen/H/builtins/convert_builtins.h"
8+#include "codegen/H/builtins/higher_order.h"
9+#include "codegen/H/collections/keys_values.h"
10+#include "codegen/H/strings/string_builtins.h"
11+#include "codegen/H/io/file_builtins.h"
12+#include "codegen/H/io/input_builtin.h"
13+#include "codegen/H/io/argv_builtin.h"
14+#include "parser/H/core/parser.h"
1515
1616 int codegen_try_builtin_call(const char *name, int len) {
1717 if (len == 4 && strncmp(name, "argv", 4) == 0) {

kiln/src/codegen/C/builtins/filter_builtin.cmodified

+9−9
@@ -1,12 +1,12 @@
1-#include "codegen/higher_order.h"
2-#include "codegen/expr.h"
3-#include "codegen/closures.h"
4-#include "codegen/emit.h"
5-#include "codegen/emit_sse.h"
6-#include "codegen/value.h"
7-#include "codegen/heap.h"
8-#include "parser/parser.h"
9-#include "parser/vars.h"
1+#include "codegen/H/builtins/higher_order.h"
2+#include "codegen/H/expressions/expr.h"
3+#include "codegen/H/functions/closures.h"
4+#include "codegen/H/emit/emit.h"
5+#include "codegen/H/emit/emit_sse.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/runtime/heap.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/declarations/vars.h"
1010
1111 // Scratch layout: [0]=fn_tag [8]=fn_payload [16]=data_ptr [24]=count
1212 // [32]=out_data_ptr [40]=i [48]=out_count

kiln/src/codegen/C/builtins/map_builtin.cmodified

+8−8
@@ -1,11 +1,11 @@
1-#include "codegen/higher_order.h"
2-#include "codegen/expr.h"
3-#include "codegen/closures.h"
4-#include "codegen/emit.h"
5-#include "codegen/value.h"
6-#include "codegen/heap.h"
7-#include "parser/parser.h"
8-#include "parser/vars.h"
1+#include "codegen/H/builtins/higher_order.h"
2+#include "codegen/H/expressions/expr.h"
3+#include "codegen/H/functions/closures.h"
4+#include "codegen/H/emit/emit.h"
5+#include "codegen/H/emit/value.h"
6+#include "codegen/H/runtime/heap.h"
7+#include "parser/H/core/parser.h"
8+#include "parser/H/declarations/vars.h"
99
1010 // Scratch layout (see vars.h's higher_order_scratch_offset -- everything
1111 // needed after codegen_call_closure_value must live here, never in a

kiln/src/codegen/C/builtins/math_builtins.cmodified

+5−5
@@ -1,8 +1,8 @@
1-#include "codegen/math_builtins.h"
2-#include "codegen/emit.h"
3-#include "codegen/emit_sse.h"
4-#include "codegen/value.h"
5-#include "parser/parser.h"
1+#include "codegen/H/builtins/math_builtins.h"
2+#include "codegen/H/emit/emit.h"
3+#include "codegen/H/emit/emit_sse.h"
4+#include "codegen/H/emit/value.h"
5+#include "parser/H/core/parser.h"
66
77 void codegen_builtin_sqrt(void) {
88 emit_pop_reg(code, REG_RAX); // payload

kiln/src/codegen/C/builtins/num_builtin.cmodified

+5−5
@@ -1,9 +1,9 @@
11 #include <string.h>
2-#include "codegen/convert_builtins.h"
3-#include "codegen/emit.h"
4-#include "codegen/emit_sse.h"
5-#include "codegen/value.h"
6-#include "parser/parser.h"
2+#include "codegen/H/builtins/convert_builtins.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/emit/emit_sse.h"
5+#include "codegen/H/emit/value.h"
6+#include "parser/H/core/parser.h"
77
88 static void load_double_const(XReg dst, double v) {
99 uint64_t bits;

kiln/src/codegen/C/builtins/reduce_builtin.cmodified

+6−6
@@ -1,9 +1,9 @@
1-#include "codegen/higher_order.h"
2-#include "codegen/expr.h"
3-#include "codegen/closures.h"
4-#include "codegen/emit.h"
5-#include "parser/parser.h"
6-#include "parser/vars.h"
1+#include "codegen/H/builtins/higher_order.h"
2+#include "codegen/H/expressions/expr.h"
3+#include "codegen/H/functions/closures.h"
4+#include "codegen/H/emit/emit.h"
5+#include "parser/H/core/parser.h"
6+#include "parser/H/declarations/vars.h"
77
88 // Scratch layout: [0]=acc_tag [8]=acc_payload [16]=fn_tag [24]=fn_payload
99 // [32]=data_ptr [40]=count [48]=i

kiln/src/codegen/C/builtins/str_builtin.cmodified

+7−7
@@ -1,11 +1,11 @@
11 #include <string.h>
2-#include "codegen/convert_builtins.h"
3-#include "codegen/emit.h"
4-#include "codegen/emit_sse.h"
5-#include "codegen/value.h"
6-#include "codegen/heap.h"
7-#include "codegen/bytes.h"
8-#include "parser/parser.h"
2+#include "codegen/H/builtins/convert_builtins.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/emit/emit_sse.h"
5+#include "codegen/H/emit/value.h"
6+#include "codegen/H/runtime/heap.h"
7+#include "codegen/H/emit/bytes.h"
8+#include "parser/H/core/parser.h"
99
1010 static void load_double_const(XReg dst, double v) {
1111 uint64_t bits;

kiln/src/codegen/C/collections/arrays.cmodified

+9−9
@@ -1,12 +1,12 @@
1-#include "codegen/arrays.h"
2-#include "codegen/expr.h"
3-#include "codegen/emit_internal.h"
4-#include "codegen/emit_sse.h"
5-#include "codegen/value.h"
6-#include "codegen/heap.h"
7-#include "codegen/bytes.h"
8-#include "codegen/errors.h"
9-#include "parser/parser.h"
1+#include "codegen/H/collections/arrays.h"
2+#include "codegen/H/expressions/expr.h"
3+#include "codegen/H/emit/emit_internal.h"
4+#include "codegen/H/emit/emit_sse.h"
5+#include "codegen/H/emit/value.h"
6+#include "codegen/H/runtime/heap.h"
7+#include "codegen/H/emit/bytes.h"
8+#include "codegen/H/runtime/errors.h"
9+#include "parser/H/core/parser.h"
1010
1111 void codegen_array_literal(void) {
1212 advance_token(); // consume '['

kiln/src/codegen/C/collections/keys_values.cmodified

+7−7
@@ -1,14 +1,14 @@
1-#include "codegen/keys_values.h"
2-#include "codegen/emit.h"
3-#include "codegen/value.h"
4-#include "codegen/heap.h"
5-#include "parser/parser.h"
6-#include "parser/vars.h"
1+#include "codegen/H/collections/keys_values.h"
2+#include "codegen/H/emit/emit.h"
3+#include "codegen/H/emit/value.h"
4+#include "codegen/H/runtime/heap.h"
5+#include "parser/H/core/parser.h"
6+#include "parser/H/declarations/vars.h"
77
88 // This implementation's map (unlike ashvm's capacity-sized hash table
99 // with scattered "used" flags) keeps every live entry packed into
1010 // [0, count) -- delete() swaps the last entry into a removed slot rather
11-// than leaving a hole (see codegen/maps_mutate.c) -- so both builtins
11+// than leaving a hole (see codegen/C/collections/maps_mutate.c) -- so both builtins
1212 // below can just iterate 0..count directly, no "used" check needed.
1313 //
1414 // Scratch layout: [0]=count [8]=entries_ptr [16]=out_block [24]=i

kiln/src/codegen/C/collections/maps.cmodified

+9−9
@@ -1,12 +1,12 @@
1-#include "codegen/maps.h"
2-#include "codegen/maps_internal.h"
3-#include "codegen/expr.h"
4-#include "codegen/strings.h"
5-#include "codegen/emit_internal.h"
6-#include "codegen/value.h"
7-#include "codegen/heap.h"
8-#include "codegen/errors.h"
9-#include "parser/parser.h"
1+#include "codegen/H/collections/maps.h"
2+#include "codegen/H/collections/maps_internal.h"
3+#include "codegen/H/expressions/expr.h"
4+#include "codegen/H/strings/strings.h"
5+#include "codegen/H/emit/emit_internal.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/runtime/heap.h"
8+#include "codegen/H/runtime/errors.h"
9+#include "parser/H/core/parser.h"
1010
1111 void codegen_map_literal(void) {
1212 advance_token(); // consume '{'

kiln/src/codegen/C/collections/maps_mutate.cmodified

+8−8
@@ -1,10 +1,10 @@
1-#include "codegen/maps.h"
2-#include "codegen/maps_internal.h"
3-#include "codegen/emit_internal.h"
4-#include "codegen/value.h"
5-#include "codegen/heap.h"
6-#include "codegen/bytes.h"
7-#include "parser/parser.h"
1+#include "codegen/H/collections/maps.h"
2+#include "codegen/H/collections/maps_internal.h"
3+#include "codegen/H/emit/emit_internal.h"
4+#include "codegen/H/emit/value.h"
5+#include "codegen/H/runtime/heap.h"
6+#include "codegen/H/emit/bytes.h"
7+#include "parser/H/core/parser.h"
88
99 static void push_number_local(double v) {
1010 uint64_t bits;
@@ -17,7 +17,7 @@ static void push_number_local(double v) {
1717
1818 // Scratch layout (base recomputed via `mov reg,rsp` after any call that
1919 // might have clobbered whichever register held it -- same technique
20-// codegen/arrays.c's codegen_builtin_push uses): [0]=val_tag
20+// codegen/C/collections/arrays.c's codegen_builtin_push uses): [0]=val_tag
2121 // [8]=val_payload [16]=key_payload [24]=map_object [32]=new_capacity
2222 // (grow path only) [40]=new_entries_block (grow path only)
2323 void codegen_map_index_store(void) {

kiln/src/codegen/C/emit/bytes.cmodified

+5−5
@@ -1,11 +1,11 @@
1-#include "codegen/bytes.h"
2-#include "codegen/win_call.h"
3-#include "elf/elf_dynamic_call.h"
4-#include "target.h"
1+#include "codegen/H/emit/bytes.h"
2+#include "codegen/H/platform/win_call.h"
3+#include "elf/H/elf_dynamic_call.h"
4+#include "app/H/target.h"
55
66 // Plan B, phase B1: emitted once (jumped over), called via emit_call_back
77 // from all 18 call sites instead of each re-emitting this loop inline --
8-// same pattern as codegen/heap.c's alloc routine. Phase B3/B4: skipped
8+// same pattern as codegen/C/runtime/heap.c's alloc routine. Phase B3/B4: skipped
99 // entirely under --link=shared (this routine lives in libkilnrt.so/.dll
1010 // instead, emitted by the separate "compile the runtime" driver via
1111 // bytes_emit_copy_routine_only), and bytes_emit_copy becomes a call

kiln/src/codegen/C/emit/emit.cmodified

+1−1
@@ -1,6 +1,6 @@
11 #include <stdlib.h>
22 #include <string.h>
3-#include "codegen/emit_internal.h"
3+#include "codegen/H/emit/emit_internal.h"
44
55 void code_init(CodeBuf *buf) {
66 buf->code = NULL;

kiln/src/codegen/C/emit/emit_mem.cmodified

+1−1
@@ -1,5 +1,5 @@
11 #include <string.h>
2-#include "codegen/emit_internal.h"
2+#include "codegen/H/emit/emit_internal.h"
33
44 void emit_store_mem_disp32(CodeBuf *buf, Reg base, int32_t disp, Reg src) {
55 emit_byte(buf, REX_W);

kiln/src/codegen/C/emit/emit_sse.cmodified

+2−2
@@ -1,5 +1,5 @@
1-#include "codegen/emit_sse.h"
2-#include "codegen/emit_internal.h"
1+#include "codegen/H/emit/emit_sse.h"
2+#include "codegen/H/emit/emit_internal.h"
33
44 // ModRM for two xmm operands (or GP<->xmm), register-direct -- same
55 // mod=11 shape modrm_reg() builds, xmm register numbers 0-7 encode

kiln/src/codegen/C/emit/layout.cmodified

+6−6
@@ -1,9 +1,9 @@
1-#include "codegen/layout.h"
2-#include "target.h"
3-#include "elf/elf_writer.h"
4-#include "elf/elf_dynamic.h"
5-#include "pe/pe_writer.h"
6-#include "pe/pe_dll_writer.h"
1+#include "codegen/H/emit/layout.h"
2+#include "app/H/target.h"
3+#include "elf/H/elf_writer.h"
4+#include "elf/H/elf_dynamic.h"
5+#include "pe/H/pe_writer.h"
6+#include "pe/H/pe_dll_writer.h"
77
88 static int is_linux_shared(void) {
99 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 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "codegen/expr.h"
5-#include "codegen/expr_internal.h"
6-#include "codegen/emit.h"
7-#include "codegen/emit_sse.h"
8-#include "codegen/value.h"
9-#include "codegen/strings.h"
10-#include "codegen/arrays.h"
11-#include "codegen/maps.h"
12-#include "codegen/builtins.h"
13-#include "codegen/closures.h"
14-#include "parser/parser.h"
15-#include "parser/vars.h"
16-#include "parser/functions.h"
17-#include "parser/constants.h"
4+#include "codegen/H/expressions/expr.h"
5+#include "codegen/H/expressions/expr_internal.h"
6+#include "codegen/H/emit/emit.h"
7+#include "codegen/H/emit/emit_sse.h"
8+#include "codegen/H/emit/value.h"
9+#include "codegen/H/strings/strings.h"
10+#include "codegen/H/collections/arrays.h"
11+#include "codegen/H/collections/maps.h"
12+#include "codegen/H/builtins/builtins.h"
13+#include "codegen/H/functions/closures.h"
14+#include "parser/H/core/parser.h"
15+#include "parser/H/declarations/vars.h"
16+#include "parser/H/declarations/functions.h"
17+#include "parser/H/declarations/constants.h"
1818
1919 // Precedence climbing: expression -> logical_or -> logical_and ->
2020 // comparison -> additive -> term -> unary -> postfix -> primary
@@ -23,7 +23,7 @@
2323 // one (tag, payload) pair onto the real CPU stack -- tag first (deeper),
2424 // payload second (on top), so popping retrieves payload then tag.
2525 //
26-// Milestone 5: a value can now be a number OR a string (codegen/value.h),
26+// Milestone 5: a value can now be a number OR a string (codegen/H/emit/value.h),
2727 // so both halves travel generically via GP registers (raw bit-copying
2828 // doesn't care what the bits mean). XMM registers only ever hold the
2929 // payload transiently, at the point of actually doing floating-point
@@ -131,7 +131,7 @@ static void primary(void) {
131131 }
132132 // Not a variable -- fall back to a bare named-function reference
133133 // used as a value (not immediately called), wrapped as a
134- // zero-capture closure (see codegen/closures.c).
134+ // zero-capture closure (see codegen/C/functions/closures.c).
135135 KilnFunction *fn = resolve_function_in_context(id.start, id.length);
136136 if (fn != NULL) {
137137 codegen_named_function_value(fn);

kiln/src/codegen/C/expressions/expr_bool.cmodified

+8−8
@@ -1,11 +1,11 @@
11 #include <string.h>
2-#include "codegen/expr.h"
3-#include "codegen/expr_internal.h"
4-#include "codegen/emit.h"
5-#include "codegen/emit_sse.h"
6-#include "codegen/value.h"
7-#include "codegen/strings.h"
8-#include "parser/parser.h"
2+#include "codegen/H/expressions/expr.h"
3+#include "codegen/H/expressions/expr_internal.h"
4+#include "codegen/H/emit/emit.h"
5+#include "codegen/H/emit/emit_sse.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/strings/strings.h"
8+#include "parser/H/core/parser.h"
99
1010 // Precedence climbing continued from expr.c: comparison -> logical_and ->
1111 // logical_or -> expression. See expr.c's header comment for the full
@@ -29,7 +29,7 @@ static void push_number_literal(double v) {
2929
3030 // Turns "condition true/false" (as of the last ucomisd) into a clean
3131 // pushed 0.0/1.0, via the same jcc-and-patch technique
32-// codegen/print_int.c already uses for its digit loop -- just applied to
32+// codegen/C/runtime/print_int.c already uses for its digit loop -- just applied to
3333 // a general boolean result instead of a hardcoded loop exit. `cc_if_true`
3434 // must be one of ucomisd's unsigned-style condition codes (COND_B/BE/A/AE
3535 // or COND_E/NE), never the signed integer ones.

kiln/src/codegen/C/expressions/expr_call.cmodified

+7−7
@@ -1,11 +1,11 @@
11 #include <stdio.h>
2-#include "codegen/expr.h"
3-#include "codegen/emit.h"
4-#include "codegen/builtins.h"
5-#include "codegen/closures.h"
6-#include "parser/parser.h"
7-#include "parser/functions.h"
8-#include "parser/vars.h"
2+#include "codegen/H/expressions/expr.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/builtins/builtins.h"
5+#include "codegen/H/functions/closures.h"
6+#include "parser/H/core/parser.h"
7+#include "parser/H/declarations/functions.h"
8+#include "parser/H/declarations/vars.h"
99
1010 // Call codegen -- its own file since it's used from two places
1111 // (expr.c's primary(), for calls used as expressions, and parser.c's

kiln/src/codegen/C/functions/closures.cmodified

+9−9
@@ -1,12 +1,12 @@
1-#include "codegen/closures.h"
2-#include "codegen/closures_internal.h"
3-#include "codegen/emit.h"
4-#include "codegen/expr.h"
5-#include "codegen/value.h"
6-#include "codegen/heap.h"
7-#include "codegen/layout.h"
8-#include "parser/parser.h"
9-#include "parser/vars.h"
1+#include "codegen/H/functions/closures.h"
2+#include "codegen/H/functions/closures_internal.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/expressions/expr.h"
5+#include "codegen/H/emit/value.h"
6+#include "codegen/H/runtime/heap.h"
7+#include "codegen/H/emit/layout.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/declarations/vars.h"
1010
1111 // Closure-object creation and the two ways a TAG_FUNCTION value gets
1212 // built (a lambda literal's runtime header, and a zero-capture wrapper

kiln/src/codegen/C/functions/lambda.cmodified

+12−12
@@ -1,16 +1,16 @@
11 #include <string.h>
2-#include "codegen/closures.h"
3-#include "codegen/closures_internal.h"
4-#include "codegen/emit.h"
5-#include "codegen/value.h"
6-#include "codegen/expr.h"
7-#include "codegen/layout.h"
8-#include "parser/parser.h"
9-#include "parser/parser_internal.h"
10-#include "parser/vars.h"
11-#include "parser/functions.h"
12-#include "parser/for_loop.h"
13-#include "parser/loop_stack.h"
2+#include "codegen/H/functions/closures.h"
3+#include "codegen/H/functions/closures_internal.h"
4+#include "codegen/H/emit/emit.h"
5+#include "codegen/H/emit/value.h"
6+#include "codegen/H/expressions/expr.h"
7+#include "codegen/H/emit/layout.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/core/parser_internal.h"
10+#include "parser/H/declarations/vars.h"
11+#include "parser/H/declarations/functions.h"
12+#include "parser/H/statements/for_loop.h"
13+#include "parser/H/statements/loop_stack.h"
1414
1515 // `fn (params) { body }` as an expression. The closure-object creation
1616 // 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 @@
11 #include <stdint.h>
2-#include "codegen/argv_builtin.h"
3-#include "codegen/argv_builtin_internal.h"
4-#include "codegen/string_alloc.h"
5-#include "codegen/bytes.h"
6-#include "codegen/heap.h"
7-#include "codegen/value.h"
8-#include "elf/elf_writer.h"
9-#include "parser/parser.h"
10-#include "parser/vars.h"
11-#include "target.h"
2+#include "codegen/H/io/argv_builtin.h"
3+#include "codegen/H/io/argv_builtin_internal.h"
4+#include "codegen/H/strings/string_alloc.h"
5+#include "codegen/H/emit/bytes.h"
6+#include "codegen/H/runtime/heap.h"
7+#include "codegen/H/emit/value.h"
8+#include "elf/H/elf_writer.h"
9+#include "parser/H/core/parser.h"
10+#include "parser/H/declarations/vars.h"
11+#include "app/H/target.h"
1212
1313 static void codegen_builtin_argv_linux(void);
1414

kiln/src/codegen/C/io/argv_builtin_windows.cmodified

+8−8
@@ -1,12 +1,12 @@
11 #include <stdint.h>
2-#include "codegen/argv_builtin_internal.h"
3-#include "codegen/string_alloc.h"
4-#include "codegen/bytes.h"
5-#include "codegen/heap.h"
6-#include "codegen/value.h"
7-#include "codegen/win_call.h"
8-#include "parser/parser.h"
9-#include "parser/vars.h"
2+#include "codegen/H/io/argv_builtin_internal.h"
3+#include "codegen/H/strings/string_alloc.h"
4+#include "codegen/H/emit/bytes.h"
5+#include "codegen/H/runtime/heap.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/platform/win_call.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/declarations/vars.h"
1010
1111 // GetCommandLineA() returns the whole command line as one string (e.g.
1212 // `prog.exe arg1 arg2`), not a pre-split argv array -- so unlike the

kiln/src/codegen/C/io/file_path.cmodified

+4−4
@@ -1,8 +1,8 @@
11 #include <stdint.h>
2-#include "codegen/file_path.h"
3-#include "codegen/bytes.h"
4-#include "codegen/heap.h"
5-#include "parser/vars.h"
2+#include "codegen/H/io/file_path.h"
3+#include "codegen/H/emit/bytes.h"
4+#include "codegen/H/runtime/heap.h"
5+#include "parser/H/declarations/vars.h"
66
77 void filepath_emit_nullterm(CodeBuf *code) {
88 int32_t base = higher_order_scratch_offset();

kiln/src/codegen/C/io/input_builtin.cmodified

+8−8
@@ -1,12 +1,12 @@
11 #include <stdint.h>
2-#include "codegen/input_builtin.h"
3-#include "codegen/string_alloc.h"
4-#include "codegen/bytes.h"
5-#include "codegen/heap.h"
6-#include "codegen/value.h"
7-#include "codegen/platform_console.h"
8-#include "parser/parser.h"
9-#include "parser/vars.h"
2+#include "codegen/H/io/input_builtin.h"
3+#include "codegen/H/strings/string_alloc.h"
4+#include "codegen/H/emit/bytes.h"
5+#include "codegen/H/runtime/heap.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/platform/platform_console.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/declarations/vars.h"
1010
1111 // Reads one line from stdin (matching ashvm's fgets(buf,1024,stdin) +
1212 // trailing-newline-strip): a fixed 1024-byte cap, same as ashvm's own

kiln/src/codegen/C/io/read_file_builtin.cmodified

+8−8
@@ -1,12 +1,12 @@
11 #include <stdint.h>
2-#include "codegen/file_builtins.h"
3-#include "codegen/file_path.h"
4-#include "codegen/string_alloc.h"
5-#include "codegen/errors.h"
6-#include "codegen/value.h"
7-#include "codegen/platform_file.h"
8-#include "parser/parser.h"
9-#include "parser/vars.h"
2+#include "codegen/H/io/file_builtins.h"
3+#include "codegen/H/io/file_path.h"
4+#include "codegen/H/strings/string_alloc.h"
5+#include "codegen/H/runtime/errors.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/platform/platform_file.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/declarations/vars.h"
1010
1111 // A single read() call is assumed to fill the whole file in one go (matches
1212 // ashvm's own single fread call, not a retry loop) -- reasonable for

kiln/src/codegen/C/io/write_file_builtins.cmodified

+8−8
@@ -1,12 +1,12 @@
11 #include <stdint.h>
2-#include "codegen/file_builtins.h"
3-#include "codegen/file_path.h"
4-#include "codegen/expr.h"
5-#include "codegen/emit_sse.h"
6-#include "codegen/value.h"
7-#include "codegen/platform_file.h"
8-#include "parser/parser.h"
9-#include "parser/vars.h"
2+#include "codegen/H/io/file_builtins.h"
3+#include "codegen/H/io/file_path.h"
4+#include "codegen/H/expressions/expr.h"
5+#include "codegen/H/emit/emit_sse.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/platform/platform_file.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/declarations/vars.h"
1010
1111 static void push_number(double v) {
1212 emit_mov_reg_imm64(code, REG_RBX, TAG_NUMBER);

kiln/src/codegen/C/platform/platform_console.cmodified

+5−5
@@ -1,8 +1,8 @@
1-#include "codegen/platform_console.h"
2-#include "codegen/win_call.h"
3-#include "codegen/win_file_call.h"
4-#include "parser/vars.h"
5-#include "target.h"
1+#include "codegen/H/platform/platform_console.h"
2+#include "codegen/H/platform/win_call.h"
3+#include "codegen/H/platform/win_file_call.h"
4+#include "parser/H/declarations/vars.h"
5+#include "app/H/target.h"
66
77 #define STD_INPUT_HANDLE ((uint64_t)(int64_t)-10)
88 #define STD_OUTPUT_HANDLE ((uint64_t)(int64_t)-11)

kiln/src/codegen/C/platform/platform_file.cmodified

+4−4
@@ -1,7 +1,7 @@
1-#include "codegen/platform_file.h"
2-#include "codegen/win_call.h"
3-#include "codegen/win_file_call.h"
4-#include "target.h"
1+#include "codegen/H/platform/platform_file.h"
2+#include "codegen/H/platform/win_call.h"
3+#include "codegen/H/platform/win_file_call.h"
4+#include "app/H/target.h"
55
66 #define GENERIC_READ 0x80000000u
77 #define GENERIC_WRITE 0x40000000u

kiln/src/codegen/C/platform/win_call.cmodified

+6−6
@@ -1,7 +1,7 @@
1-#include "codegen/win_call.h"
2-#include "codegen/emit_internal.h"
3-#include "codegen/layout.h"
4-#include "parser/vars.h"
1+#include "codegen/H/platform/win_call.h"
2+#include "codegen/H/emit/emit_internal.h"
3+#include "codegen/H/emit/layout.h"
4+#include "parser/H/declarations/vars.h"
55
66 // AND RSP, imm8 (sign-extended) -- opcode 0x83 /4. Nothing else in kiln
77 // needs a register-immediate AND, so this stays local instead of joining
@@ -94,8 +94,8 @@ void win_call_end(CodeBuf *code) {
9494 // Windows API, needs the full shadow-space dance above), libkilnrt.dll's
9595 // exports are kiln's OWN code using kiln's OWN simple per-routine
9696 // register conventions (RAX/RBX/RDI/RDX depending on which routine, see
97-// codegen/heap.c etc.) -- exactly like the Linux GOT call
98-// (elf/elf_dynamic_call.c's emit_call_abs32), no register is safe to
97+// codegen/C/runtime/heap.c etc.) -- exactly like the Linux GOT call
98+// (elf/C/elf_dynamic_call.c's emit_call_abs32), no register is safe to
9999 // clobber loading the IAT address first. Can't reuse emit_call_abs32's
100100 // technique directly, though: kiln's PE image base (0x140000000) is
101101 // already past the 32-bit absolute-displacement addressing mode's

kiln/src/codegen/C/platform/win_file_call.cmodified

+3−3
@@ -1,6 +1,6 @@
1-#include "codegen/win_file_call.h"
2-#include "codegen/win_call.h"
3-#include "parser/vars.h"
1+#include "codegen/H/platform/win_file_call.h"
2+#include "codegen/H/platform/win_call.h"
3+#include "parser/H/declarations/vars.h"
44
55 // &ignored_out needs to be a real writable address (Windows doesn't
66 // accept NULL there for synchronous handles), so it points at a

kiln/src/codegen/C/runtime/errors.cmodified

+11−11
@@ -1,13 +1,13 @@
11 #include <string.h>
2-#include "codegen/errors.h"
3-#include "codegen/emit_internal.h"
4-#include "codegen/value.h"
5-#include "codegen/layout.h"
6-#include "codegen/runtime_layout.h"
7-#include "codegen/platform_console.h"
8-#include "codegen/win_call.h"
9-#include "elf/elf_dynamic_call.h"
10-#include "target.h"
2+#include "codegen/H/runtime/errors.h"
3+#include "codegen/H/emit/emit_internal.h"
4+#include "codegen/H/emit/value.h"
5+#include "codegen/H/emit/layout.h"
6+#include "codegen/H/emit/runtime_layout.h"
7+#include "codegen/H/platform/platform_console.h"
8+#include "codegen/H/platform/win_call.h"
9+#include "elf/H/elf_dynamic_call.h"
10+#include "app/H/target.h"
1111
1212 static int raise_routine_offset = -1;
1313
@@ -16,7 +16,7 @@ static int is_shared(void) {
1616 }
1717
1818 // Embeds `msg` as a proper length-prefixed string (jumped over, never
19-// executed as instructions) -- the SAME layout codegen/strings.c's
19+// executed as instructions) -- the SAME layout codegen/C/strings/strings.c's
2020 // literals use ([payload-8]=length, no trailing newline in the data
2121 // itself), since milestone 9 makes a caught error a real, usable
2222 // TAG_STRING value (print/concat/equality all assume this layout). This
@@ -131,7 +131,7 @@ void errors_emit_die(CodeBuf *code, const char *msg) {
131131 // The ONE case that must never be "catchable" (exceeding
132132 // MAX_KILN_TRY_DEPTH itself -- silently continuing there would mean
133133 // pushing a handler past the fixed table, corrupting the adjacent code
134-// segment). Only ever called from one site (parser/try_catch.c), so
134+// segment). Only ever called from one site (parser/C/statements/try_catch.c), so
135135 // there's no deduplication payoff in routing it through the shared
136136 // runtime at all -- it just emits its own small inline write+exit
137137 // sequence directly, in every link mode, decoupled from wherever RAISE

kiln/src/codegen/C/runtime/heap.cmodified

+6−6
@@ -1,8 +1,8 @@
1-#include "codegen/heap.h"
2-#include "codegen/layout.h"
3-#include "codegen/win_call.h"
4-#include "elf/elf_dynamic_call.h"
5-#include "target.h"
1+#include "codegen/H/runtime/heap.h"
2+#include "codegen/H/emit/layout.h"
3+#include "codegen/H/platform/win_call.h"
4+#include "elf/H/elf_dynamic_call.h"
5+#include "app/H/target.h"
66
77 #define HEAP_SIZE (16 * 1024 * 1024)
88 #define MEM_COMMIT_RESERVE 0x3000u // MEM_COMMIT(0x1000) | MEM_RESERVE(0x2000)
@@ -30,7 +30,7 @@ static void emit_alloc_routine(CodeBuf *code) {
3030 }
3131
3232 // Called by the dedicated "compile the runtime" driver (see
33-// elf/elf_so_writer.c) to emit this routine into libkilnrt.so's OWN code
33+// elf/C/elf_so_writer.c) to emit this routine into libkilnrt.so's OWN code
3434 // buffer, completely separate from any executable's compile_program.
3535 void heap_emit_alloc_routine_only(CodeBuf *code) {
3636 emit_alloc_routine(code);

kiln/src/codegen/C/runtime/print_int.cmodified

+13−13
@@ -1,17 +1,17 @@
11 #include <string.h>
2-#include "codegen/print_int.h"
3-#include "codegen/emit_internal.h"
4-#include "codegen/emit_sse.h"
5-#include "codegen/value.h"
6-#include "codegen/layout.h"
7-#include "codegen/win_call.h"
8-#include "codegen/platform_console.h"
9-#include "elf/elf_dynamic_call.h"
10-#include "target.h"
2+#include "codegen/H/runtime/print_int.h"
3+#include "codegen/H/emit/emit_internal.h"
4+#include "codegen/H/emit/emit_sse.h"
5+#include "codegen/H/emit/value.h"
6+#include "codegen/H/emit/layout.h"
7+#include "codegen/H/platform/win_call.h"
8+#include "codegen/H/platform/platform_console.h"
9+#include "elf/H/elf_dynamic_call.h"
10+#include "app/H/target.h"
1111
1212 // Loads a compile-time-known double literal into an xmm register, via a
1313 // GP register holding its raw IEEE-754 bit pattern -- same technique
14-// codegen/expr.c uses for user-written number literals (there's no "mov
14+// codegen/C/expressions/expr.c uses for user-written number literals (there's no "mov
1515 // xmm, imm64" instruction).
1616 static void load_double_const(CodeBuf *code, XReg dst, double v) {
1717 uint64_t bits;
@@ -48,7 +48,7 @@ static void load_double_const(CodeBuf *code, XReg dst, double v) {
4848 // RBX=tag (NOT by popping them itself): a real CALL pushes a return
4949 // address on top of whatever the caller already pushed, so a `pop` here
5050 // would grab the return address instead of the caller's value -- same
51-// register-based-argument reasoning codegen/heap.c's alloc routine
51+// register-based-argument reasoning codegen/C/runtime/heap.c's alloc routine
5252 // already uses, not something print specifically needed before this
5353 // became a real subroutine. Each of its three paths (string/nil/number)
5454 // 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) {
8888 // Position-independent path: needed only for libkilnrt.so, whose
8989 // load address ld.so chooses at runtime. libkilnrt.dll (Windows)
9090 // is fixed-base like everything else kiln emits (see
91- // pe/pe_dll_writer.h), so kiln_code_base() already resolves
91+ // pe/H/pe_dll_writer.h), so kiln_code_base() already resolves
9292 // correctly there without RIP-relative addressing -- it now
93- // knows about DLL compilation specifically (see codegen/layout.c).
93+ // knows about DLL compilation specifically (see codegen/C/emit/layout.c).
9494 if (kiln_is_compiling_so() && kiln_get_target() == KILN_TARGET_LINUX) {
9595 emit_lea_rip_back(code, REG_RSI, data_offset);
9696 } else {

kiln/src/codegen/C/strings/case_builtins.cmodified

+6−6
@@ -1,14 +1,14 @@
11 #include <stdint.h>
2-#include "codegen/string_builtins.h"
3-#include "codegen/string_alloc.h"
4-#include "codegen/emit.h"
5-#include "codegen/value.h"
6-#include "parser/parser.h"
2+#include "codegen/H/strings/string_builtins.h"
3+#include "codegen/H/strings/string_alloc.h"
4+#include "codegen/H/emit/emit.h"
5+#include "codegen/H/emit/value.h"
6+#include "parser/H/core/parser.h"
77
88 // Shared shape for upper()/lower(): allocate a same-length copy, then a
99 // byte-by-byte transform loop advancing two raw pointers (source cursor
1010 // in RSI, dest cursor in RDI) rather than indexing -- same technique
11-// codegen/closures.c's capture-copy loop uses, avoiding any need for a
11+// codegen/C/functions/closures.c's capture-copy loop uses, avoiding any need for a
1212 // scaled-index addressing mode this project's emitter doesn't support.
1313 static void case_transform(char lo, char hi, int8_t delta) {
1414 emit_pop_reg(code, REG_RAX); // src payload

kiln/src/codegen/C/strings/indexof_builtin.cmodified

+7−7
@@ -1,10 +1,10 @@
1-#include "codegen/string_builtins.h"
2-#include "codegen/expr.h"
3-#include "codegen/emit.h"
4-#include "codegen/emit_sse.h"
5-#include "codegen/value.h"
6-#include "parser/parser.h"
7-#include "parser/vars.h"
1+#include "codegen/H/strings/string_builtins.h"
2+#include "codegen/H/expressions/expr.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/emit/emit_sse.h"
5+#include "codegen/H/emit/value.h"
6+#include "parser/H/core/parser.h"
7+#include "parser/H/declarations/vars.h"
88
99 static void push_number(double v) {
1010 emit_mov_reg_imm64(code, REG_RBX, TAG_NUMBER);

kiln/src/codegen/C/strings/join_builtin.cmodified

+8−8
@@ -1,11 +1,11 @@
1-#include "codegen/string_builtins.h"
2-#include "codegen/string_alloc.h"
3-#include "codegen/expr.h"
4-#include "codegen/bytes.h"
5-#include "codegen/emit.h"
6-#include "codegen/value.h"
7-#include "parser/parser.h"
8-#include "parser/vars.h"
1+#include "codegen/H/strings/string_builtins.h"
2+#include "codegen/H/strings/string_alloc.h"
3+#include "codegen/H/expressions/expr.h"
4+#include "codegen/H/emit/bytes.h"
5+#include "codegen/H/emit/emit.h"
6+#include "codegen/H/emit/value.h"
7+#include "parser/H/core/parser.h"
8+#include "parser/H/declarations/vars.h"
99
1010 // Two-pass: pass 1 sums each element's length (+ delim length between
1111 // consecutive elements) to get the exact output size; pass 2 allocates

kiln/src/codegen/C/strings/replace_builtin.cmodified

+8−8
@@ -1,12 +1,12 @@
11 #include <stdint.h>
2-#include "codegen/string_builtins.h"
3-#include "codegen/string_alloc.h"
4-#include "codegen/expr.h"
5-#include "codegen/bytes.h"
6-#include "codegen/emit.h"
7-#include "codegen/value.h"
8-#include "parser/parser.h"
9-#include "parser/vars.h"
2+#include "codegen/H/strings/string_builtins.h"
3+#include "codegen/H/strings/string_alloc.h"
4+#include "codegen/H/expressions/expr.h"
5+#include "codegen/H/emit/bytes.h"
6+#include "codegen/H/emit/emit.h"
7+#include "codegen/H/emit/value.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/declarations/vars.h"
1010
1111 // Scratch layout: [0]=s_ptr [8]=s_len [16]=search_ptr [24]=search_len
1212 // [32]=cur [40]=total_len/occurrences [48]=out_block [56]=cursor

kiln/src/codegen/C/strings/split_builtin.cmodified

+9−9
@@ -1,13 +1,13 @@
11 #include <stdint.h>
2-#include "codegen/string_builtins.h"
3-#include "codegen/string_alloc.h"
4-#include "codegen/expr.h"
5-#include "codegen/bytes.h"
6-#include "codegen/emit.h"
7-#include "codegen/value.h"
8-#include "codegen/heap.h"
9-#include "parser/parser.h"
10-#include "parser/vars.h"
2+#include "codegen/H/strings/string_builtins.h"
3+#include "codegen/H/strings/string_alloc.h"
4+#include "codegen/H/expressions/expr.h"
5+#include "codegen/H/emit/bytes.h"
6+#include "codegen/H/emit/emit.h"
7+#include "codegen/H/emit/value.h"
8+#include "codegen/H/runtime/heap.h"
9+#include "parser/H/core/parser.h"
10+#include "parser/H/declarations/vars.h"
1111
1212 // Scratch layout: [0]=s_ptr [8]=s_len [16]=delim_ptr [24]=delim_len
1313 // [32]=cur [40]=count [48]=out_data_ptr [56]=out_index

kiln/src/codegen/C/strings/string_alloc.cmodified

+7−7
@@ -1,12 +1,12 @@
1-#include "codegen/string_alloc.h"
2-#include "codegen/heap.h"
3-#include "codegen/win_call.h"
4-#include "elf/elf_dynamic_call.h"
5-#include "target.h"
1+#include "codegen/H/strings/string_alloc.h"
2+#include "codegen/H/runtime/heap.h"
3+#include "codegen/H/platform/win_call.h"
4+#include "elf/H/elf_dynamic_call.h"
5+#include "app/H/target.h"
66
77 // Plan B, phase B1: emitted once (jumped over), called via emit_call_back
8-// from all 13 call sites -- same pattern as codegen/heap.c's alloc
9-// routine and codegen/bytes.c's copy routine (which this one itself
8+// from all 13 call sites -- same pattern as codegen/C/runtime/heap.c's alloc
9+// routine and codegen/C/emit/bytes.c's copy routine (which this one itself
1010 // calls, via heap_emit_alloc -- routines calling other routines nest
1111 // exactly like any other CALL/RET, no special handling needed). Note this
1212 // stays a LOCAL call even when compiling libkilnrt.so/.dll: the "compile

kiln/src/codegen/C/strings/strings.cmodified

+11−11
@@ -1,13 +1,13 @@
1-#include "codegen/strings.h"
2-#include "codegen/emit_internal.h"
3-#include "codegen/emit_sse.h"
4-#include "codegen/value.h"
5-#include "codegen/heap.h"
6-#include "codegen/bytes.h"
7-#include "codegen/string_alloc.h"
8-#include "codegen/errors.h"
9-#include "codegen/layout.h"
10-#include "parser/parser.h"
1+#include "codegen/H/strings/strings.h"
2+#include "codegen/H/emit/emit_internal.h"
3+#include "codegen/H/emit/emit_sse.h"
4+#include "codegen/H/emit/value.h"
5+#include "codegen/H/runtime/heap.h"
6+#include "codegen/H/emit/bytes.h"
7+#include "codegen/H/strings/string_alloc.h"
8+#include "codegen/H/runtime/errors.h"
9+#include "codegen/H/emit/layout.h"
10+#include "parser/H/core/parser.h"
1111
1212 static void push_number_literal(double v) {
1313 uint64_t bits;
@@ -60,7 +60,7 @@ void codegen_string_literal(void) {
6060
6161 // Scratch layout (a stable base pointer copied from RSP into RSI, since
6262 // [rsp+disp] itself needs a SIB byte this project's encoders don't
63-// support -- same technique codegen/print_int.c uses):
63+// support -- same technique codegen/C/runtime/print_int.c uses):
6464 // [0]=a_payload [8]=b_payload [16]=length_a [24]=length_b [32]=new_block
6565 void codegen_string_concat(void) {
6666 emit_sub_reg_imm8(code, REG_RSP, 40);

kiln/src/codegen/C/strings/substring_builtin.cmodified

+8−8
@@ -1,11 +1,11 @@
1-#include "codegen/string_builtins.h"
2-#include "codegen/string_alloc.h"
3-#include "codegen/expr.h"
4-#include "codegen/bytes.h"
5-#include "codegen/emit.h"
6-#include "codegen/emit_sse.h"
7-#include "codegen/value.h"
8-#include "parser/parser.h"
1+#include "codegen/H/strings/string_builtins.h"
2+#include "codegen/H/strings/string_alloc.h"
3+#include "codegen/H/expressions/expr.h"
4+#include "codegen/H/emit/bytes.h"
5+#include "codegen/H/emit/emit.h"
6+#include "codegen/H/emit/emit_sse.h"
7+#include "codegen/H/emit/value.h"
8+#include "parser/H/core/parser.h"
99
1010 // substring(str, start, end): clamps start>=0, end<=len, start>end->start=end
1111 // (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 @@
1-#include "codegen/string_builtins.h"
2-#include "codegen/string_alloc.h"
3-#include "codegen/bytes.h"
4-#include "codegen/emit.h"
5-#include "codegen/value.h"
6-#include "parser/parser.h"
1+#include "codegen/H/strings/string_builtins.h"
2+#include "codegen/H/strings/string_alloc.h"
3+#include "codegen/H/emit/bytes.h"
4+#include "codegen/H/emit/emit.h"
5+#include "codegen/H/emit/value.h"
6+#include "parser/H/core/parser.h"
77
88 // Advances RSI forward past leading whitespace, then RDI backward past
99 // trailing whitespace (RDI starts as the exclusive end pointer), each via

kiln/src/codegen/D/builtins/builtins.dadded

+25−0
@@ -0,0 +1,25 @@
1+src/codegen/O/builtins/builtins.o: src/codegen/C/builtins/builtins.c \
2+ src/codegen/H/builtins/builtins.h src/codegen/H/expressions/expr.h \
3+ src/lexer/H/lexer.h src/codegen/H/collections/arrays.h \
4+ src/codegen/H/collections/maps.h src/codegen/H/builtins/math_builtins.h \
5+ src/codegen/H/builtins/convert_builtins.h \
6+ src/codegen/H/builtins/higher_order.h \
7+ src/codegen/H/collections/keys_values.h \
8+ src/codegen/H/strings/string_builtins.h src/codegen/H/io/file_builtins.h \
9+ src/codegen/H/io/input_builtin.h src/codegen/H/io/argv_builtin.h \
10+ src/parser/H/core/parser.h src/codegen/H/emit/emit.h
11+src/codegen/H/builtins/builtins.h:
12+src/codegen/H/expressions/expr.h:
13+src/lexer/H/lexer.h:
14+src/codegen/H/collections/arrays.h:
15+src/codegen/H/collections/maps.h:
16+src/codegen/H/builtins/math_builtins.h:
17+src/codegen/H/builtins/convert_builtins.h:
18+src/codegen/H/builtins/higher_order.h:
19+src/codegen/H/collections/keys_values.h:
20+src/codegen/H/strings/string_builtins.h:
21+src/codegen/H/io/file_builtins.h:
22+src/codegen/H/io/input_builtin.h:
23+src/codegen/H/io/argv_builtin.h:
24+src/parser/H/core/parser.h:
25+src/codegen/H/emit/emit.h:

kiln/src/codegen/D/builtins/filter_builtin.dadded

+19−0
@@ -0,0 +1,19 @@
1+src/codegen/O/builtins/filter_builtin.o: \
2+ src/codegen/C/builtins/filter_builtin.c \
3+ src/codegen/H/builtins/higher_order.h src/codegen/H/expressions/expr.h \
4+ src/lexer/H/lexer.h src/codegen/H/functions/closures.h \
5+ src/parser/H/declarations/functions.h src/codegen/H/emit/emit.h \
6+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
7+ src/codegen/H/runtime/heap.h src/parser/H/core/parser.h \
8+ src/parser/H/declarations/vars.h
9+src/codegen/H/builtins/higher_order.h:
10+src/codegen/H/expressions/expr.h:
11+src/lexer/H/lexer.h:
12+src/codegen/H/functions/closures.h:
13+src/parser/H/declarations/functions.h:
14+src/codegen/H/emit/emit.h:
15+src/codegen/H/emit/emit_sse.h:
16+src/codegen/H/emit/value.h:
17+src/codegen/H/runtime/heap.h:
18+src/parser/H/core/parser.h:
19+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/builtins/map_builtin.dadded

+17−0
@@ -0,0 +1,17 @@
1+src/codegen/O/builtins/map_builtin.o: \
2+ src/codegen/C/builtins/map_builtin.c \
3+ src/codegen/H/builtins/higher_order.h src/codegen/H/expressions/expr.h \
4+ src/lexer/H/lexer.h src/codegen/H/functions/closures.h \
5+ src/parser/H/declarations/functions.h src/codegen/H/emit/emit.h \
6+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \
7+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h
8+src/codegen/H/builtins/higher_order.h:
9+src/codegen/H/expressions/expr.h:
10+src/lexer/H/lexer.h:
11+src/codegen/H/functions/closures.h:
12+src/parser/H/declarations/functions.h:
13+src/codegen/H/emit/emit.h:
14+src/codegen/H/emit/value.h:
15+src/codegen/H/runtime/heap.h:
16+src/parser/H/core/parser.h:
17+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/builtins/math_builtins.dadded

+11−0
@@ -0,0 +1,11 @@
1+src/codegen/O/builtins/math_builtins.o: \
2+ src/codegen/C/builtins/math_builtins.c \
3+ src/codegen/H/builtins/math_builtins.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
5+ src/parser/H/core/parser.h src/lexer/H/lexer.h
6+src/codegen/H/builtins/math_builtins.h:
7+src/codegen/H/emit/emit.h:
8+src/codegen/H/emit/emit_sse.h:
9+src/codegen/H/emit/value.h:
10+src/parser/H/core/parser.h:
11+src/lexer/H/lexer.h:

kiln/src/codegen/D/builtins/num_builtin.dadded

+11−0
@@ -0,0 +1,11 @@
1+src/codegen/O/builtins/num_builtin.o: \
2+ src/codegen/C/builtins/num_builtin.c \
3+ src/codegen/H/builtins/convert_builtins.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
5+ src/parser/H/core/parser.h src/lexer/H/lexer.h
6+src/codegen/H/builtins/convert_builtins.h:
7+src/codegen/H/emit/emit.h:
8+src/codegen/H/emit/emit_sse.h:
9+src/codegen/H/emit/value.h:
10+src/parser/H/core/parser.h:
11+src/lexer/H/lexer.h:

kiln/src/codegen/D/builtins/reduce_builtin.dadded

+14−0
@@ -0,0 +1,14 @@
1+src/codegen/O/builtins/reduce_builtin.o: \
2+ src/codegen/C/builtins/reduce_builtin.c \
3+ src/codegen/H/builtins/higher_order.h src/codegen/H/expressions/expr.h \
4+ src/lexer/H/lexer.h src/codegen/H/functions/closures.h \
5+ src/parser/H/declarations/functions.h src/codegen/H/emit/emit.h \
6+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h
7+src/codegen/H/builtins/higher_order.h:
8+src/codegen/H/expressions/expr.h:
9+src/lexer/H/lexer.h:
10+src/codegen/H/functions/closures.h:
11+src/parser/H/declarations/functions.h:
12+src/codegen/H/emit/emit.h:
13+src/parser/H/core/parser.h:
14+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/builtins/str_builtin.dadded

+14−0
@@ -0,0 +1,14 @@
1+src/codegen/O/builtins/str_builtin.o: \
2+ src/codegen/C/builtins/str_builtin.c \
3+ src/codegen/H/builtins/convert_builtins.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
5+ src/codegen/H/runtime/heap.h src/codegen/H/emit/bytes.h \
6+ src/parser/H/core/parser.h src/lexer/H/lexer.h
7+src/codegen/H/builtins/convert_builtins.h:
8+src/codegen/H/emit/emit.h:
9+src/codegen/H/emit/emit_sse.h:
10+src/codegen/H/emit/value.h:
11+src/codegen/H/runtime/heap.h:
12+src/codegen/H/emit/bytes.h:
13+src/parser/H/core/parser.h:
14+src/lexer/H/lexer.h:

kiln/src/codegen/D/collections/arrays.dadded

+18−0
@@ -0,0 +1,18 @@
1+src/codegen/O/collections/arrays.o: src/codegen/C/collections/arrays.c \
2+ src/codegen/H/collections/arrays.h src/codegen/H/expressions/expr.h \
3+ src/lexer/H/lexer.h src/codegen/H/emit/emit_internal.h \
4+ src/codegen/H/emit/emit.h src/codegen/H/emit/emit_sse.h \
5+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \
6+ src/codegen/H/emit/bytes.h src/codegen/H/runtime/errors.h \
7+ src/parser/H/core/parser.h
8+src/codegen/H/collections/arrays.h:
9+src/codegen/H/expressions/expr.h:
10+src/lexer/H/lexer.h:
11+src/codegen/H/emit/emit_internal.h:
12+src/codegen/H/emit/emit.h:
13+src/codegen/H/emit/emit_sse.h:
14+src/codegen/H/emit/value.h:
15+src/codegen/H/runtime/heap.h:
16+src/codegen/H/emit/bytes.h:
17+src/codegen/H/runtime/errors.h:
18+src/parser/H/core/parser.h:

kiln/src/codegen/D/collections/keys_values.dadded

+13−0
@@ -0,0 +1,13 @@
1+src/codegen/O/collections/keys_values.o: \
2+ src/codegen/C/collections/keys_values.c \
3+ src/codegen/H/collections/keys_values.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \
5+ src/parser/H/core/parser.h src/lexer/H/lexer.h \
6+ src/parser/H/declarations/vars.h
7+src/codegen/H/collections/keys_values.h:
8+src/codegen/H/emit/emit.h:
9+src/codegen/H/emit/value.h:
10+src/codegen/H/runtime/heap.h:
11+src/parser/H/core/parser.h:
12+src/lexer/H/lexer.h:
13+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/collections/maps.dadded

+19−0
@@ -0,0 +1,19 @@
1+src/codegen/O/collections/maps.o: src/codegen/C/collections/maps.c \
2+ src/codegen/H/collections/maps.h \
3+ src/codegen/H/collections/maps_internal.h \
4+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
5+ src/codegen/H/strings/strings.h src/codegen/H/emit/emit_internal.h \
6+ src/codegen/H/emit/emit.h src/codegen/H/emit/value.h \
7+ src/codegen/H/runtime/heap.h src/codegen/H/runtime/errors.h \
8+ src/parser/H/core/parser.h
9+src/codegen/H/collections/maps.h:
10+src/codegen/H/collections/maps_internal.h:
11+src/codegen/H/expressions/expr.h:
12+src/lexer/H/lexer.h:
13+src/codegen/H/strings/strings.h:
14+src/codegen/H/emit/emit_internal.h:
15+src/codegen/H/emit/emit.h:
16+src/codegen/H/emit/value.h:
17+src/codegen/H/runtime/heap.h:
18+src/codegen/H/runtime/errors.h:
19+src/parser/H/core/parser.h:

kiln/src/codegen/D/collections/maps_mutate.dadded

+16−0
@@ -0,0 +1,16 @@
1+src/codegen/O/collections/maps_mutate.o: \
2+ src/codegen/C/collections/maps_mutate.c src/codegen/H/collections/maps.h \
3+ src/codegen/H/collections/maps_internal.h \
4+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \
6+ src/codegen/H/emit/bytes.h src/parser/H/core/parser.h \
7+ src/lexer/H/lexer.h
8+src/codegen/H/collections/maps.h:
9+src/codegen/H/collections/maps_internal.h:
10+src/codegen/H/emit/emit_internal.h:
11+src/codegen/H/emit/emit.h:
12+src/codegen/H/emit/value.h:
13+src/codegen/H/runtime/heap.h:
14+src/codegen/H/emit/bytes.h:
15+src/parser/H/core/parser.h:
16+src/lexer/H/lexer.h:

kiln/src/codegen/D/emit/bytes.dadded

+20−0
@@ -0,0 +1,20 @@
1+src/codegen/O/emit/bytes.o: src/codegen/C/emit/bytes.c \
2+ src/codegen/H/emit/bytes.h src/codegen/H/emit/emit.h \
3+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \
4+ src/codegen/H/emit/runtime_layout.h \
5+ src/codegen/H/emit/runtime_import_enum.h \
6+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
7+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \
8+ src/elf/H/elf_writer.h src/app/H/target.h
9+src/codegen/H/emit/bytes.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/platform/win_call.h:
12+src/pe/H/pe_writer.h:
13+src/codegen/H/emit/runtime_layout.h:
14+src/codegen/H/emit/runtime_import_enum.h:
15+src/codegen/H/emit/runtime_exports.def:
16+src/pe/H/pe_imports.def:
17+src/elf/H/elf_dynamic_call.h:
18+src/elf/H/elf_dynamic.h:
19+src/elf/H/elf_writer.h:
20+src/app/H/target.h:

kiln/src/codegen/D/emit/emit.dadded

+4−0
@@ -0,0 +1,4 @@
1+src/codegen/O/emit/emit.o: src/codegen/C/emit/emit.c \
2+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit.h
3+src/codegen/H/emit/emit_internal.h:
4+src/codegen/H/emit/emit.h:

kiln/src/codegen/D/emit/emit_mem.dadded

+4−0
@@ -0,0 +1,4 @@
1+src/codegen/O/emit/emit_mem.o: src/codegen/C/emit/emit_mem.c \
2+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit.h
3+src/codegen/H/emit/emit_internal.h:
4+src/codegen/H/emit/emit.h:

kiln/src/codegen/D/emit/emit_sse.dadded

+6−0
@@ -0,0 +1,6 @@
1+src/codegen/O/emit/emit_sse.o: src/codegen/C/emit/emit_sse.c \
2+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/emit.h \
3+ src/codegen/H/emit/emit_internal.h
4+src/codegen/H/emit/emit_sse.h:
5+src/codegen/H/emit/emit.h:
6+src/codegen/H/emit/emit_internal.h:

kiln/src/codegen/D/emit/layout.dadded

+17−0
@@ -0,0 +1,17 @@
1+src/codegen/O/emit/layout.o: src/codegen/C/emit/layout.c \
2+ src/codegen/H/emit/layout.h src/app/H/target.h src/elf/H/elf_writer.h \
3+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \
4+ src/elf/H/elf_dynamic.h src/codegen/H/emit/runtime_import_enum.h \
5+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_writer.h \
6+ src/pe/H/pe_imports.def src/pe/H/pe_dll_writer.h
7+src/codegen/H/emit/layout.h:
8+src/app/H/target.h:
9+src/elf/H/elf_writer.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/emit/runtime_layout.h:
12+src/elf/H/elf_dynamic.h:
13+src/codegen/H/emit/runtime_import_enum.h:
14+src/codegen/H/emit/runtime_exports.def:
15+src/pe/H/pe_writer.h:
16+src/pe/H/pe_imports.def:
17+src/pe/H/pe_dll_writer.h:

kiln/src/codegen/D/expressions/expr.dadded

+24−0
@@ -0,0 +1,24 @@
1+src/codegen/O/expressions/expr.o: src/codegen/C/expressions/expr.c \
2+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
3+ src/codegen/H/expressions/expr_internal.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
5+ src/codegen/H/strings/strings.h src/codegen/H/collections/arrays.h \
6+ src/codegen/H/collections/maps.h src/codegen/H/builtins/builtins.h \
7+ src/codegen/H/functions/closures.h src/parser/H/declarations/functions.h \
8+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h \
9+ src/parser/H/declarations/constants.h
10+src/codegen/H/expressions/expr.h:
11+src/lexer/H/lexer.h:
12+src/codegen/H/expressions/expr_internal.h:
13+src/codegen/H/emit/emit.h:
14+src/codegen/H/emit/emit_sse.h:
15+src/codegen/H/emit/value.h:
16+src/codegen/H/strings/strings.h:
17+src/codegen/H/collections/arrays.h:
18+src/codegen/H/collections/maps.h:
19+src/codegen/H/builtins/builtins.h:
20+src/codegen/H/functions/closures.h:
21+src/parser/H/declarations/functions.h:
22+src/parser/H/core/parser.h:
23+src/parser/H/declarations/vars.h:
24+src/parser/H/declarations/constants.h:

kiln/src/codegen/D/expressions/expr_bool.dadded

+14−0
@@ -0,0 +1,14 @@
1+src/codegen/O/expressions/expr_bool.o: \
2+ src/codegen/C/expressions/expr_bool.c src/codegen/H/expressions/expr.h \
3+ src/lexer/H/lexer.h src/codegen/H/expressions/expr_internal.h \
4+ src/codegen/H/emit/emit.h src/codegen/H/emit/emit_sse.h \
5+ src/codegen/H/emit/value.h src/codegen/H/strings/strings.h \
6+ src/parser/H/core/parser.h
7+src/codegen/H/expressions/expr.h:
8+src/lexer/H/lexer.h:
9+src/codegen/H/expressions/expr_internal.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/emit/emit_sse.h:
12+src/codegen/H/emit/value.h:
13+src/codegen/H/strings/strings.h:
14+src/parser/H/core/parser.h:

kiln/src/codegen/D/expressions/expr_call.dadded

+14−0
@@ -0,0 +1,14 @@
1+src/codegen/O/expressions/expr_call.o: \
2+ src/codegen/C/expressions/expr_call.c src/codegen/H/expressions/expr.h \
3+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/builtins/builtins.h src/codegen/H/functions/closures.h \
5+ src/parser/H/declarations/functions.h src/parser/H/core/parser.h \
6+ src/parser/H/declarations/vars.h
7+src/codegen/H/expressions/expr.h:
8+src/lexer/H/lexer.h:
9+src/codegen/H/emit/emit.h:
10+src/codegen/H/builtins/builtins.h:
11+src/codegen/H/functions/closures.h:
12+src/parser/H/declarations/functions.h:
13+src/parser/H/core/parser.h:
14+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/functions/closures.dadded

+18−0
@@ -0,0 +1,18 @@
1+src/codegen/O/functions/closures.o: src/codegen/C/functions/closures.c \
2+ src/codegen/H/functions/closures.h src/parser/H/declarations/functions.h \
3+ src/codegen/H/functions/closures_internal.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
5+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \
6+ src/codegen/H/emit/layout.h src/parser/H/core/parser.h \
7+ src/parser/H/declarations/vars.h
8+src/codegen/H/functions/closures.h:
9+src/parser/H/declarations/functions.h:
10+src/codegen/H/functions/closures_internal.h:
11+src/codegen/H/emit/emit.h:
12+src/codegen/H/expressions/expr.h:
13+src/lexer/H/lexer.h:
14+src/codegen/H/emit/value.h:
15+src/codegen/H/runtime/heap.h:
16+src/codegen/H/emit/layout.h:
17+src/parser/H/core/parser.h:
18+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/functions/lambda.dadded

+21−0
@@ -0,0 +1,21 @@
1+src/codegen/O/functions/lambda.o: src/codegen/C/functions/lambda.c \
2+ src/codegen/H/functions/closures.h src/parser/H/declarations/functions.h \
3+ src/codegen/H/functions/closures_internal.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/emit/value.h src/codegen/H/expressions/expr.h \
5+ src/lexer/H/lexer.h src/codegen/H/emit/layout.h \
6+ src/parser/H/core/parser.h src/parser/H/core/parser_internal.h \
7+ src/parser/H/declarations/vars.h src/parser/H/statements/for_loop.h \
8+ src/parser/H/statements/loop_stack.h
9+src/codegen/H/functions/closures.h:
10+src/parser/H/declarations/functions.h:
11+src/codegen/H/functions/closures_internal.h:
12+src/codegen/H/emit/emit.h:
13+src/codegen/H/emit/value.h:
14+src/codegen/H/expressions/expr.h:
15+src/lexer/H/lexer.h:
16+src/codegen/H/emit/layout.h:
17+src/parser/H/core/parser.h:
18+src/parser/H/core/parser_internal.h:
19+src/parser/H/declarations/vars.h:
20+src/parser/H/statements/for_loop.h:
21+src/parser/H/statements/loop_stack.h:

kiln/src/codegen/D/io/argv_builtin.dadded

+20−0
@@ -0,0 +1,20 @@
1+src/codegen/O/io/argv_builtin.o: src/codegen/C/io/argv_builtin.c \
2+ src/codegen/H/io/argv_builtin.h src/codegen/H/io/argv_builtin_internal.h \
3+ src/codegen/H/emit/emit.h src/codegen/H/strings/string_alloc.h \
4+ src/codegen/H/emit/bytes.h src/codegen/H/runtime/heap.h \
5+ src/codegen/H/emit/value.h src/elf/H/elf_writer.h \
6+ src/codegen/H/emit/runtime_layout.h src/parser/H/core/parser.h \
7+ src/lexer/H/lexer.h src/parser/H/declarations/vars.h src/app/H/target.h
8+src/codegen/H/io/argv_builtin.h:
9+src/codegen/H/io/argv_builtin_internal.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/strings/string_alloc.h:
12+src/codegen/H/emit/bytes.h:
13+src/codegen/H/runtime/heap.h:
14+src/codegen/H/emit/value.h:
15+src/elf/H/elf_writer.h:
16+src/codegen/H/emit/runtime_layout.h:
17+src/parser/H/core/parser.h:
18+src/lexer/H/lexer.h:
19+src/parser/H/declarations/vars.h:
20+src/app/H/target.h:

kiln/src/codegen/D/io/argv_builtin_windows.dadded

+26−0
@@ -0,0 +1,26 @@
1+src/codegen/O/io/argv_builtin_windows.o: \
2+ src/codegen/C/io/argv_builtin_windows.c \
3+ src/codegen/H/io/argv_builtin_internal.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/bytes.h \
5+ src/codegen/H/runtime/heap.h src/codegen/H/emit/value.h \
6+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \
7+ src/codegen/H/emit/runtime_layout.h \
8+ src/codegen/H/emit/runtime_import_enum.h \
9+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
10+ src/parser/H/core/parser.h src/lexer/H/lexer.h \
11+ src/parser/H/declarations/vars.h
12+src/codegen/H/io/argv_builtin_internal.h:
13+src/codegen/H/emit/emit.h:
14+src/codegen/H/strings/string_alloc.h:
15+src/codegen/H/emit/bytes.h:
16+src/codegen/H/runtime/heap.h:
17+src/codegen/H/emit/value.h:
18+src/codegen/H/platform/win_call.h:
19+src/pe/H/pe_writer.h:
20+src/codegen/H/emit/runtime_layout.h:
21+src/codegen/H/emit/runtime_import_enum.h:
22+src/codegen/H/emit/runtime_exports.def:
23+src/pe/H/pe_imports.def:
24+src/parser/H/core/parser.h:
25+src/lexer/H/lexer.h:
26+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/io/file_path.dadded

+9−0
@@ -0,0 +1,9 @@
1+src/codegen/O/io/file_path.o: src/codegen/C/io/file_path.c \
2+ src/codegen/H/io/file_path.h src/codegen/H/emit/emit.h \
3+ src/codegen/H/emit/bytes.h src/codegen/H/runtime/heap.h \
4+ src/parser/H/declarations/vars.h
5+src/codegen/H/io/file_path.h:
6+src/codegen/H/emit/emit.h:
7+src/codegen/H/emit/bytes.h:
8+src/codegen/H/runtime/heap.h:
9+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/io/input_builtin.dadded

+16−0
@@ -0,0 +1,16 @@
1+src/codegen/O/io/input_builtin.o: src/codegen/C/io/input_builtin.c \
2+ src/codegen/H/io/input_builtin.h src/codegen/H/strings/string_alloc.h \
3+ src/codegen/H/emit/emit.h src/codegen/H/emit/bytes.h \
4+ src/codegen/H/runtime/heap.h src/codegen/H/emit/value.h \
5+ src/codegen/H/platform/platform_console.h src/parser/H/core/parser.h \
6+ src/lexer/H/lexer.h src/parser/H/declarations/vars.h
7+src/codegen/H/io/input_builtin.h:
8+src/codegen/H/strings/string_alloc.h:
9+src/codegen/H/emit/emit.h:
10+src/codegen/H/emit/bytes.h:
11+src/codegen/H/runtime/heap.h:
12+src/codegen/H/emit/value.h:
13+src/codegen/H/platform/platform_console.h:
14+src/parser/H/core/parser.h:
15+src/lexer/H/lexer.h:
16+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/io/read_file_builtin.dadded

+17−0
@@ -0,0 +1,17 @@
1+src/codegen/O/io/read_file_builtin.o: \
2+ src/codegen/C/io/read_file_builtin.c src/codegen/H/io/file_builtins.h \
3+ src/codegen/H/io/file_path.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/runtime/errors.h \
5+ src/codegen/H/emit/value.h src/codegen/H/platform/platform_file.h \
6+ src/parser/H/core/parser.h src/lexer/H/lexer.h \
7+ src/parser/H/declarations/vars.h
8+src/codegen/H/io/file_builtins.h:
9+src/codegen/H/io/file_path.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/strings/string_alloc.h:
12+src/codegen/H/runtime/errors.h:
13+src/codegen/H/emit/value.h:
14+src/codegen/H/platform/platform_file.h:
15+src/parser/H/core/parser.h:
16+src/lexer/H/lexer.h:
17+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/io/write_file_builtins.dadded

+17−0
@@ -0,0 +1,17 @@
1+src/codegen/O/io/write_file_builtins.o: \
2+ src/codegen/C/io/write_file_builtins.c src/codegen/H/io/file_builtins.h \
3+ src/codegen/H/io/file_path.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
5+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
6+ src/codegen/H/platform/platform_file.h src/parser/H/core/parser.h \
7+ src/parser/H/declarations/vars.h
8+src/codegen/H/io/file_builtins.h:
9+src/codegen/H/io/file_path.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/expressions/expr.h:
12+src/lexer/H/lexer.h:
13+src/codegen/H/emit/emit_sse.h:
14+src/codegen/H/emit/value.h:
15+src/codegen/H/platform/platform_file.h:
16+src/parser/H/core/parser.h:
17+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/platform/platform_console.dadded

+20−0
@@ -0,0 +1,20 @@
1+src/codegen/O/platform/platform_console.o: \
2+ src/codegen/C/platform/platform_console.c \
3+ src/codegen/H/platform/platform_console.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \
5+ src/codegen/H/emit/runtime_layout.h \
6+ src/codegen/H/emit/runtime_import_enum.h \
7+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
8+ src/codegen/H/platform/win_file_call.h src/parser/H/declarations/vars.h \
9+ src/app/H/target.h
10+src/codegen/H/platform/platform_console.h:
11+src/codegen/H/emit/emit.h:
12+src/codegen/H/platform/win_call.h:
13+src/pe/H/pe_writer.h:
14+src/codegen/H/emit/runtime_layout.h:
15+src/codegen/H/emit/runtime_import_enum.h:
16+src/codegen/H/emit/runtime_exports.def:
17+src/pe/H/pe_imports.def:
18+src/codegen/H/platform/win_file_call.h:
19+src/parser/H/declarations/vars.h:
20+src/app/H/target.h:

kiln/src/codegen/D/platform/platform_file.dadded

+18−0
@@ -0,0 +1,18 @@
1+src/codegen/O/platform/platform_file.o: \
2+ src/codegen/C/platform/platform_file.c \
3+ src/codegen/H/platform/platform_file.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \
5+ src/codegen/H/emit/runtime_layout.h \
6+ src/codegen/H/emit/runtime_import_enum.h \
7+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
8+ src/codegen/H/platform/win_file_call.h src/app/H/target.h
9+src/codegen/H/platform/platform_file.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/platform/win_call.h:
12+src/pe/H/pe_writer.h:
13+src/codegen/H/emit/runtime_layout.h:
14+src/codegen/H/emit/runtime_import_enum.h:
15+src/codegen/H/emit/runtime_exports.def:
16+src/pe/H/pe_imports.def:
17+src/codegen/H/platform/win_file_call.h:
18+src/app/H/target.h:

kiln/src/codegen/D/platform/win_call.dadded

+17−0
@@ -0,0 +1,17 @@
1+src/codegen/O/platform/win_call.o: src/codegen/C/platform/win_call.c \
2+ src/codegen/H/platform/win_call.h src/codegen/H/emit/emit.h \
3+ src/pe/H/pe_writer.h src/codegen/H/emit/runtime_layout.h \
4+ src/codegen/H/emit/runtime_import_enum.h \
5+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
6+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/layout.h \
7+ src/parser/H/declarations/vars.h
8+src/codegen/H/platform/win_call.h:
9+src/codegen/H/emit/emit.h:
10+src/pe/H/pe_writer.h:
11+src/codegen/H/emit/runtime_layout.h:
12+src/codegen/H/emit/runtime_import_enum.h:
13+src/codegen/H/emit/runtime_exports.def:
14+src/pe/H/pe_imports.def:
15+src/codegen/H/emit/emit_internal.h:
16+src/codegen/H/emit/layout.h:
17+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/platform/win_file_call.dadded

+16−0
@@ -0,0 +1,16 @@
1+src/codegen/O/platform/win_file_call.o: \
2+ src/codegen/C/platform/win_file_call.c \
3+ src/codegen/H/platform/win_file_call.h src/pe/H/pe_writer.h \
4+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \
5+ src/codegen/H/emit/runtime_import_enum.h \
6+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
7+ src/codegen/H/platform/win_call.h src/parser/H/declarations/vars.h
8+src/codegen/H/platform/win_file_call.h:
9+src/pe/H/pe_writer.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/emit/runtime_layout.h:
12+src/codegen/H/emit/runtime_import_enum.h:
13+src/codegen/H/emit/runtime_exports.def:
14+src/pe/H/pe_imports.def:
15+src/codegen/H/platform/win_call.h:
16+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/runtime/errors.dadded

+26−0
@@ -0,0 +1,26 @@
1+src/codegen/O/runtime/errors.o: src/codegen/C/runtime/errors.c \
2+ src/codegen/H/runtime/errors.h src/codegen/H/emit/emit.h \
3+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/value.h \
4+ src/codegen/H/emit/layout.h src/codegen/H/emit/runtime_layout.h \
5+ src/codegen/H/platform/platform_console.h \
6+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \
7+ src/codegen/H/emit/runtime_import_enum.h \
8+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
9+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \
10+ src/elf/H/elf_writer.h src/app/H/target.h
11+src/codegen/H/runtime/errors.h:
12+src/codegen/H/emit/emit.h:
13+src/codegen/H/emit/emit_internal.h:
14+src/codegen/H/emit/value.h:
15+src/codegen/H/emit/layout.h:
16+src/codegen/H/emit/runtime_layout.h:
17+src/codegen/H/platform/platform_console.h:
18+src/codegen/H/platform/win_call.h:
19+src/pe/H/pe_writer.h:
20+src/codegen/H/emit/runtime_import_enum.h:
21+src/codegen/H/emit/runtime_exports.def:
22+src/pe/H/pe_imports.def:
23+src/elf/H/elf_dynamic_call.h:
24+src/elf/H/elf_dynamic.h:
25+src/elf/H/elf_writer.h:
26+src/app/H/target.h:

kiln/src/codegen/D/runtime/heap.dadded

+21−0
@@ -0,0 +1,21 @@
1+src/codegen/O/runtime/heap.o: src/codegen/C/runtime/heap.c \
2+ src/codegen/H/runtime/heap.h src/codegen/H/emit/emit.h \
3+ src/codegen/H/emit/layout.h src/codegen/H/platform/win_call.h \
4+ src/pe/H/pe_writer.h src/codegen/H/emit/runtime_layout.h \
5+ src/codegen/H/emit/runtime_import_enum.h \
6+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
7+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \
8+ src/elf/H/elf_writer.h src/app/H/target.h
9+src/codegen/H/runtime/heap.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/emit/layout.h:
12+src/codegen/H/platform/win_call.h:
13+src/pe/H/pe_writer.h:
14+src/codegen/H/emit/runtime_layout.h:
15+src/codegen/H/emit/runtime_import_enum.h:
16+src/codegen/H/emit/runtime_exports.def:
17+src/pe/H/pe_imports.def:
18+src/elf/H/elf_dynamic_call.h:
19+src/elf/H/elf_dynamic.h:
20+src/elf/H/elf_writer.h:
21+src/app/H/target.h:

kiln/src/codegen/D/runtime/print_int.dadded

+27−0
@@ -0,0 +1,27 @@
1+src/codegen/O/runtime/print_int.o: src/codegen/C/runtime/print_int.c \
2+ src/codegen/H/runtime/print_int.h src/codegen/H/emit/emit.h \
3+ src/codegen/H/emit/emit_internal.h src/codegen/H/emit/emit_sse.h \
4+ src/codegen/H/emit/value.h src/codegen/H/emit/layout.h \
5+ src/codegen/H/platform/win_call.h src/pe/H/pe_writer.h \
6+ src/codegen/H/emit/runtime_layout.h \
7+ src/codegen/H/emit/runtime_import_enum.h \
8+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
9+ src/codegen/H/platform/platform_console.h src/elf/H/elf_dynamic_call.h \
10+ src/elf/H/elf_dynamic.h src/elf/H/elf_writer.h src/app/H/target.h
11+src/codegen/H/runtime/print_int.h:
12+src/codegen/H/emit/emit.h:
13+src/codegen/H/emit/emit_internal.h:
14+src/codegen/H/emit/emit_sse.h:
15+src/codegen/H/emit/value.h:
16+src/codegen/H/emit/layout.h:
17+src/codegen/H/platform/win_call.h:
18+src/pe/H/pe_writer.h:
19+src/codegen/H/emit/runtime_layout.h:
20+src/codegen/H/emit/runtime_import_enum.h:
21+src/codegen/H/emit/runtime_exports.def:
22+src/pe/H/pe_imports.def:
23+src/codegen/H/platform/platform_console.h:
24+src/elf/H/elf_dynamic_call.h:
25+src/elf/H/elf_dynamic.h:
26+src/elf/H/elf_writer.h:
27+src/app/H/target.h:

kiln/src/codegen/D/strings/case_builtins.dadded

+12−0
@@ -0,0 +1,12 @@
1+src/codegen/O/strings/case_builtins.o: \
2+ src/codegen/C/strings/case_builtins.c \
3+ src/codegen/H/strings/string_builtins.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/emit/value.h src/parser/H/core/parser.h \
6+ src/lexer/H/lexer.h
7+src/codegen/H/strings/string_builtins.h:
8+src/codegen/H/strings/string_alloc.h:
9+src/codegen/H/emit/emit.h:
10+src/codegen/H/emit/value.h:
11+src/parser/H/core/parser.h:
12+src/lexer/H/lexer.h:

kiln/src/codegen/D/strings/indexof_builtin.dadded

+14−0
@@ -0,0 +1,14 @@
1+src/codegen/O/strings/indexof_builtin.o: \
2+ src/codegen/C/strings/indexof_builtin.c \
3+ src/codegen/H/strings/string_builtins.h src/codegen/H/expressions/expr.h \
4+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
6+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h
7+src/codegen/H/strings/string_builtins.h:
8+src/codegen/H/expressions/expr.h:
9+src/lexer/H/lexer.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/emit/emit_sse.h:
12+src/codegen/H/emit/value.h:
13+src/parser/H/core/parser.h:
14+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/strings/join_builtin.dadded

+16−0
@@ -0,0 +1,16 @@
1+src/codegen/O/strings/join_builtin.o: \
2+ src/codegen/C/strings/join_builtin.c \
3+ src/codegen/H/strings/string_builtins.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
6+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \
7+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h
8+src/codegen/H/strings/string_builtins.h:
9+src/codegen/H/strings/string_alloc.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/expressions/expr.h:
12+src/lexer/H/lexer.h:
13+src/codegen/H/emit/bytes.h:
14+src/codegen/H/emit/value.h:
15+src/parser/H/core/parser.h:
16+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/strings/replace_builtin.dadded

+16−0
@@ -0,0 +1,16 @@
1+src/codegen/O/strings/replace_builtin.o: \
2+ src/codegen/C/strings/replace_builtin.c \
3+ src/codegen/H/strings/string_builtins.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
6+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \
7+ src/parser/H/core/parser.h src/parser/H/declarations/vars.h
8+src/codegen/H/strings/string_builtins.h:
9+src/codegen/H/strings/string_alloc.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/expressions/expr.h:
12+src/lexer/H/lexer.h:
13+src/codegen/H/emit/bytes.h:
14+src/codegen/H/emit/value.h:
15+src/parser/H/core/parser.h:
16+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/strings/split_builtin.dadded

+18−0
@@ -0,0 +1,18 @@
1+src/codegen/O/strings/split_builtin.o: \
2+ src/codegen/C/strings/split_builtin.c \
3+ src/codegen/H/strings/string_builtins.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
6+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \
7+ src/codegen/H/runtime/heap.h src/parser/H/core/parser.h \
8+ src/parser/H/declarations/vars.h
9+src/codegen/H/strings/string_builtins.h:
10+src/codegen/H/strings/string_alloc.h:
11+src/codegen/H/emit/emit.h:
12+src/codegen/H/expressions/expr.h:
13+src/lexer/H/lexer.h:
14+src/codegen/H/emit/bytes.h:
15+src/codegen/H/emit/value.h:
16+src/codegen/H/runtime/heap.h:
17+src/parser/H/core/parser.h:
18+src/parser/H/declarations/vars.h:

kiln/src/codegen/D/strings/string_alloc.dadded

+22−0
@@ -0,0 +1,22 @@
1+src/codegen/O/strings/string_alloc.o: \
2+ src/codegen/C/strings/string_alloc.c \
3+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \
4+ src/codegen/H/runtime/heap.h src/codegen/H/platform/win_call.h \
5+ src/pe/H/pe_writer.h src/codegen/H/emit/runtime_layout.h \
6+ src/codegen/H/emit/runtime_import_enum.h \
7+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
8+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \
9+ src/elf/H/elf_writer.h src/app/H/target.h
10+src/codegen/H/strings/string_alloc.h:
11+src/codegen/H/emit/emit.h:
12+src/codegen/H/runtime/heap.h:
13+src/codegen/H/platform/win_call.h:
14+src/pe/H/pe_writer.h:
15+src/codegen/H/emit/runtime_layout.h:
16+src/codegen/H/emit/runtime_import_enum.h:
17+src/codegen/H/emit/runtime_exports.def:
18+src/pe/H/pe_imports.def:
19+src/elf/H/elf_dynamic_call.h:
20+src/elf/H/elf_dynamic.h:
21+src/elf/H/elf_writer.h:
22+src/app/H/target.h:

kiln/src/codegen/D/strings/strings.dadded

+19−0
@@ -0,0 +1,19 @@
1+src/codegen/O/strings/strings.o: src/codegen/C/strings/strings.c \
2+ src/codegen/H/strings/strings.h src/codegen/H/emit/emit_internal.h \
3+ src/codegen/H/emit/emit.h src/codegen/H/emit/emit_sse.h \
4+ src/codegen/H/emit/value.h src/codegen/H/runtime/heap.h \
5+ src/codegen/H/emit/bytes.h src/codegen/H/strings/string_alloc.h \
6+ src/codegen/H/runtime/errors.h src/codegen/H/emit/layout.h \
7+ src/parser/H/core/parser.h src/lexer/H/lexer.h
8+src/codegen/H/strings/strings.h:
9+src/codegen/H/emit/emit_internal.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/emit/emit_sse.h:
12+src/codegen/H/emit/value.h:
13+src/codegen/H/runtime/heap.h:
14+src/codegen/H/emit/bytes.h:
15+src/codegen/H/strings/string_alloc.h:
16+src/codegen/H/runtime/errors.h:
17+src/codegen/H/emit/layout.h:
18+src/parser/H/core/parser.h:
19+src/lexer/H/lexer.h:

kiln/src/codegen/D/strings/substring_builtin.dadded

+16−0
@@ -0,0 +1,16 @@
1+src/codegen/O/strings/substring_builtin.o: \
2+ src/codegen/C/strings/substring_builtin.c \
3+ src/codegen/H/strings/string_builtins.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/expressions/expr.h src/lexer/H/lexer.h \
6+ src/codegen/H/emit/bytes.h src/codegen/H/emit/emit_sse.h \
7+ src/codegen/H/emit/value.h src/parser/H/core/parser.h
8+src/codegen/H/strings/string_builtins.h:
9+src/codegen/H/strings/string_alloc.h:
10+src/codegen/H/emit/emit.h:
11+src/codegen/H/expressions/expr.h:
12+src/lexer/H/lexer.h:
13+src/codegen/H/emit/bytes.h:
14+src/codegen/H/emit/emit_sse.h:
15+src/codegen/H/emit/value.h:
16+src/parser/H/core/parser.h:

kiln/src/codegen/D/strings/trim_builtin.dadded

+13−0
@@ -0,0 +1,13 @@
1+src/codegen/O/strings/trim_builtin.o: \
2+ src/codegen/C/strings/trim_builtin.c \
3+ src/codegen/H/strings/string_builtins.h \
4+ src/codegen/H/strings/string_alloc.h src/codegen/H/emit/emit.h \
5+ src/codegen/H/emit/bytes.h src/codegen/H/emit/value.h \
6+ src/parser/H/core/parser.h src/lexer/H/lexer.h
7+src/codegen/H/strings/string_builtins.h:
8+src/codegen/H/strings/string_alloc.h:
9+src/codegen/H/emit/emit.h:
10+src/codegen/H/emit/bytes.h:
11+src/codegen/H/emit/value.h:
12+src/parser/H/core/parser.h:
13+src/lexer/H/lexer.h:

kiln/src/codegen/H/builtins/convert_builtins.hmodified

+2−2
@@ -1,12 +1,12 @@
11 #ifndef KILN_CONVERT_BUILTINS_H
22 #define KILN_CONVERT_BUILTINS_H
33
4-// Assumes its one argument already pushed -- codegen/builtins.c's dispatch
4+// Assumes its one argument already pushed -- codegen/C/builtins/builtins.c's dispatch
55 // calls these after parsing str(x)/num(x)'s argument.
66
77 // str(number): formats into a heap-allocated, length-prefixed string
88 // (same layout as any other TAG_STRING value) -- the exact same digit
9-// algorithm codegen/print_int.c uses (sign, integer part backward, up to
9+// algorithm codegen/C/runtime/print_int.c uses (sign, integer part backward, up to
1010 // 6 fraction digits with round-half-up and trailing-zero trim), just
1111 // targeting a heap block instead of a direct stdout write. Kept as its
1212 // own self-contained copy rather than sharing code with print_int.c's

kiln/src/codegen/H/builtins/math_builtins.hmodified

+1−1
@@ -1,7 +1,7 @@
11 #ifndef KILN_MATH_BUILTINS_H
22 #define KILN_MATH_BUILTINS_H
33
4-// Each assumes its one NUMBER argument already pushed -- codegen/builtins.c's
4+// Each assumes its one NUMBER argument already pushed -- codegen/C/builtins/builtins.c's
55 // dispatch calls these after parsing sqrt(x)/abs(x)/floor(x)'s argument.
66 void codegen_builtin_sqrt(void);
77 void codegen_builtin_abs(void);

kiln/src/codegen/H/collections/arrays.hmodified

+2−2
@@ -2,7 +2,7 @@
22 #define KILN_ARRAYS_H
33
44 // primary()'s '[' handling: parses `[e0, e1, ...]`, allocates a heap
5-// block sized for exactly that many elements (see codegen/value.h for
5+// block sized for exactly that many elements (see codegen/H/emit/value.h for
66 // the layout), and pushes (tag=TAG_ARRAY, payload=<block address>).
77 void codegen_array_literal(void);
88
@@ -17,7 +17,7 @@ void codegen_array_index_read(void);
1717 void codegen_array_index_store(void);
1818
1919 // Both assume their arguments already pushed left-to-right (matching
20-// the normal call-argument convention) -- codegen/builtins.c's dispatch
20+// the normal call-argument convention) -- codegen/C/builtins/builtins.c's dispatch
2121 // calls these after parsing push(arr, val) / len(arr)'s arguments.
2222
2323 // push(array, value): appends, growing (a fresh, bigger heap block plus

kiln/src/codegen/H/collections/keys_values.hmodified

+1−1
@@ -1,7 +1,7 @@
11 #ifndef KILN_KEYS_VALUES_H
22 #define KILN_KEYS_VALUES_H
33
4-// Both assume their one MAP argument already pushed -- codegen/builtins.c's
4+// Both assume their one MAP argument already pushed -- codegen/C/builtins/builtins.c's
55 // dispatch calls these after parsing keys(m)/values(m)'s argument.
66 void codegen_builtin_keys(void);
77 void codegen_builtin_values(void);

kiln/src/codegen/H/collections/maps.hmodified

+1−1
@@ -16,7 +16,7 @@ void codegen_map_index_read(void);
1616 // exists, otherwise appends a new entry (growing if needed).
1717 void codegen_map_index_store(void);
1818
19-// Builtins, dispatched from codegen/builtins.c -- each assumes its
19+// Builtins, dispatched from codegen/C/builtins/builtins.c -- each assumes its
2020 // arguments already pushed left to right, matching the normal
2121 // call-argument convention. keys()/values() (each needs to build a new
2222 // ARRAY sized only-known-at-runtime, real extra complexity for

kiln/src/codegen/H/emit/bytes.hmodified

+3−3
@@ -1,6 +1,6 @@
11 #ifndef KILN_BYTES_H
22 #define KILN_BYTES_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Emitted once, at program start (see parser.c's compile_program) --
66 // must run before any call to bytes_emit_copy below.
@@ -13,8 +13,8 @@ int bytes_copy_routine_offset(void);
1313
1414 // RDI=dest, RBX=src, RDX=count (input) -- clobbers RAX,RBX,RCX,RDX,RDI.
1515 // Deliberately doesn't touch RSI, so callers can keep a stable scratch
16-// pointer there across multiple calls. Shared between codegen/strings.c
17-// (concatenation) and codegen/arrays.c (growth). Plan B, phase B1: a real
16+// pointer there across multiple calls. Shared between codegen/C/strings/strings.c
17+// (concatenation) and codegen/C/collections/arrays.c (growth). Plan B, phase B1: a real
1818 // CALL to one shared copy (emitted by bytes_emit_startup) rather than
1919 // re-emitting this loop inline at each of its ~18 call sites.
2020 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);
7777 // Byte (8-bit) memory stores through a register-indirect address [reg] --
7878 // `reg` must not be RSP/RBP (both need a SIB/disp encoding this module
7979 // deliberately doesn't support; callers route byte-buffer pointers through
80-// RCX instead, see codegen/print_int.c).
80+// RCX instead, see codegen/C/runtime/print_int.c).
8181 void emit_store_byte_imm(CodeBuf *buf, Reg base, uint8_t imm);
8282 void emit_store_byte_reg(CodeBuf *buf, Reg base, Reg src); // src must be RAX/RCX/RDX/RBX (low byte AL/CL/DL/BL)
8383 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 @@
11 #ifndef KILN_EMIT_INTERNAL_H
22 #define KILN_EMIT_INTERNAL_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Shared byte-buffer primitives and ModRM builders, used by both emit.c
66 // (register arithmetic) and emit_mem.c (memory/stack/jump instructions).

kiln/src/codegen/H/emit/emit_sse.hmodified

+2−2
@@ -1,6 +1,6 @@
11 #ifndef KILN_EMIT_SSE_H
22 #define KILN_EMIT_SSE_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Scalar double-precision (SSE2) primitives -- milestone 4 replaces
66 // kiln's integer-only numbers with real doubles throughout, matching
@@ -12,7 +12,7 @@
1212 typedef enum { XMM0 = 0, XMM1 = 1, XMM2 = 2, XMM3 = 3 } XReg;
1313
1414 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)
15-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
15+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
1616 void emit_movsd_xmm_xmm(CodeBuf *buf, XReg dst, XReg src);
1717 void emit_movsd_load_disp32(CodeBuf *buf, XReg dst, Reg base, int32_t disp);
1818 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 @@
55 // Every place in codegen that needs "the absolute address of code offset
66 // N" or "the absolute address of a globals-region field" used to hardcode
77 // KILN_LOAD_BASE+KILN_CODE_START_OFFSET / KILN_TRY_DEPTH_ADDR / etc.
8-// directly from elf/elf_writer.h. Now that kiln can target two different
8+// directly from elf/H/elf_writer.h. Now that kiln can target two different
99 // executable formats with two different fixed base addresses (see
10-// elf/elf_writer.h vs pe/pe_writer.h), those hardcodes would each need
10+// elf/H/elf_writer.h vs pe/H/pe_writer.h), those hardcodes would each need
1111 // their own target check -- so instead every call site goes through one
1212 // of these, and the target check lives here exactly once.
1313 uint64_t kiln_code_base(void); // add a code offset to get an absolute address

kiln/src/codegen/H/emit/runtime_exports.defmodified

+1−1
@@ -3,7 +3,7 @@
33 // between the .so writer (which needs to export these by name) and the
44 // executable's codegen (which needs a GOT slot per import) -- same
55 // "adding one means adding one line here, nowhere else" reasoning as
6-// pe/pe_imports.def.
6+// pe/H/pe_imports.def.
77 //
88 // RUNTIME_EXPORT(enum_suffix, "exported symbol name")
99 RUNTIME_EXPORT(HEAP_ALLOC, "kiln_heap_alloc")

kiln/src/codegen/H/emit/runtime_import_enum.hmodified

+3−3
@@ -1,14 +1,14 @@
11 #ifndef KILN_RUNTIME_IMPORT_ENUM_H
22 #define KILN_RUNTIME_IMPORT_ENUM_H
33
4-// The RuntimeImport enum itself, factored out of elf/elf_dynamic.h so
5-// pe/pe_dll_writer.h can share it too (Windows --link=shared imports the
4+// The RuntimeImport enum itself, factored out of elf/H/elf_dynamic.h so
5+// pe/H/pe_dll_writer.h can share it too (Windows --link=shared imports the
66 // exact same 5 functions from libkilnrt.dll that Linux imports from
77 // libkilnrt.so) without two conflicting `typedef enum RuntimeImport`
88 // definitions in the same translation unit.
99 typedef enum {
1010 #define RUNTIME_EXPORT(name, str) RUNTIME_IMPORT_##name,
11-#include "codegen/runtime_exports.def"
11+#include "codegen/H/emit/runtime_exports.def"
1212 #undef RUNTIME_EXPORT
1313 RUNTIME_IMPORT_COUNT_
1414 } RuntimeImport;

kiln/src/codegen/H/emit/runtime_layout.hmodified

+2−2
@@ -2,9 +2,9 @@
22 #define KILN_RUNTIME_LAYOUT_H
33
44 // OS-agnostic sizes for kiln's own hand-rolled try/catch handler stack
5-// (see codegen/errors.c's raise routine, parser/try_catch.c) -- the byte
5+// (see codegen/C/runtime/errors.c's raise routine, parser/C/statements/try_catch.c) -- the byte
66 // layout is a kiln-internal invention, not tied to ELF or PE, so both
7-// elf/elf_writer.h and pe/pe_writer.h include this rather than each
7+// elf/H/elf_writer.h and pe/H/pe_writer.h include this rather than each
88 // re-declaring the same numbers.
99 #define MAX_KILN_TRY_DEPTH 16
1010 #define KILN_TRY_HANDLER_SIZE 32

kiln/src/codegen/H/emit/value.hmodified

+8−8
@@ -4,7 +4,7 @@
44 // Milestone 5: an ash value is no longer always a bare double -- it can
55 // also be a string. Every value is now a (tag, payload) pair, 16 bytes
66 // total, moved around generically via GP registers (raw bit-copying
7-// doesn't care what the bits mean -- see codegen/expr.c's header
7+// doesn't care what the bits mean -- see codegen/C/expressions/expr.c's header
88 // comment). XMM registers only ever hold the payload transiently, at the
99 // point of actually doing floating-point arithmetic on a NUMBER-tagged
1010 // value.
@@ -13,8 +13,8 @@
1313 // non-PIE executable, so absolute addresses are stable and known at
1414 // compile time) pointing at a length-prefixed byte block: 8 bytes of
1515 // length, followed by that many raw bytes. String literals are embedded
16-// directly in the code buffer (see codegen/strings.c); concatenation
17-// results are heap-allocated (see codegen/heap.c) since their size is
16+// directly in the code buffer (see codegen/C/strings/strings.c); concatenation
17+// results are heap-allocated (see codegen/C/runtime/heap.c) since their size is
1818 // only known at runtime.
1919 #define TAG_NUMBER 0
2020 #define TAG_STRING 1
@@ -26,9 +26,9 @@
2626 // coincides with +0.0's bit pattern. That's what lets nil ride the
2727 // EXISTING truthy-test and numeric-comparison codegen (both just
2828 // ucomisd the payload against 0.0) without needing its own special case
29-// anywhere except print (see codegen/print_int.c's dispatch) and the
29+// anywhere except print (see codegen/C/runtime/print_int.c's dispatch) and the
3030 // tag-equality short-circuit in comparisons (already tag-aware since
31-// M5's `==`/`!=`, see codegen/expr_bool.c -- nil==nil compares equal
31+// M5's `==`/`!=`, see codegen/C/expressions/expr_bool.c -- nil==nil compares equal
3232 // tags then falls into the numeric path, 0.0==0.0; nil compared against
3333 // any other tag is caught by the tags-differ branch before ever
3434 // touching the payload). `true`/`false` are NOT a separate tag --
@@ -40,7 +40,7 @@
4040 #define TAG_NIL 5
4141
4242 // An array's payload is the address of a small, fixed-size, STABLE
43-// "array object" (see codegen/strings.h's comment on why absolute
43+// "array object" (see codegen/H/strings/strings.h's comment on why absolute
4444 // addresses are safe: kiln is always a fixed, non-PIE executable):
4545 // [0] capacity (int64, how many elements the data block has room for)
4646 // [8] count (int64, how many are actually in use)
@@ -75,13 +75,13 @@
7575 // arrays/maps) heap block:
7676 // [0] absolute code address (already resolved to KILN_LOAD_BASE +
7777 // KILN_CODE_START_OFFSET + code_offset at compile time -- kiln is
78-// a fixed non-PIE executable, see elf/elf_writer.h, so this is
78+// a fixed non-PIE executable, see elf/H/elf_writer.h, so this is
7979 // known and stable)
8080 // [8] capture_count (int64)
8181 // [16+16*i] capture i's tag [16+16*i+8] capture i's payload
8282 // A plain named function used as a value (not immediately called) gets
8383 // capture_count=0 -- the same shape as any closure with zero captures, so
84-// codegen/closures.c's indirect-call codegen never special-cases "0
84+// codegen/C/functions/closures.c's indirect-call codegen never special-cases "0
8585 // captures", it just runs a 0-iteration loop.
8686 //
8787 // Scope limit (documented, not silently pretended away -- same spirit as

kiln/src/codegen/H/expressions/expr.hmodified

+3−3
@@ -1,9 +1,9 @@
11 #ifndef KILN_CODEGEN_EXPR_H
22 #define KILN_CODEGEN_EXPR_H
3-#include "lexer/lexer.h"
3+#include "lexer/H/lexer.h"
44
55 // Parses one expression and emits real x86-64 code for it via the
6-// shared `code` buffer (see parser/parser.h) -- consumes tokens
6+// shared `code` buffer (see parser/H/core/parser.h) -- consumes tokens
77 // directly, no AST. Leaves the computed value's (tag, payload) pushed on
88 // the (simulated, real CPU) stack.
99 void codegen_expression(void);
@@ -21,7 +21,7 @@ void codegen_call(Token id);
2121 // than a contiguous span of the source text, so there's no single Token
2222 // to hand codegen_call. Already-fully-qualified name -- resolved via
2323 // resolve_function (not resolve_function_in_context), since the caller
24-// (codegen/expr.c's primary()) has already done the namespace lookup by
24+// (codegen/C/expressions/expr.c's primary()) has already done the namespace lookup by
2525 // building the combined name.
2626 void codegen_call_named(const char *name, int len);
2727

kiln/src/codegen/H/expressions/expr_internal.hmodified

+1−1
@@ -3,7 +3,7 @@
33
44 // Cross-file link between expr.c (arithmetic: primary -> unary -> term ->
55 // additive) and expr_bool.c (comparison -> logical_and -> logical_or ->
6-// codegen_expression), not part of the public API (codegen/expr.h).
6+// codegen_expression), not part of the public API (codegen/H/expressions/expr.h).
77 void additive(void);
88
99 #endif

kiln/src/codegen/H/functions/closures.hmodified

+3−3
@@ -1,10 +1,10 @@
11 #ifndef KILN_CLOSURES_H
22 #define KILN_CLOSURES_H
3-#include "parser/functions.h"
3+#include "parser/H/declarations/functions.h"
44
55 // `fn (params) { body }` as an EXPRESSION -- current sits on the 'fn'
66 // token. Captures (by value, snapshotted at creation time -- see the
7-// scope-limit note in codegen/value.h) every variable currently visible
7+// scope-limit note in codegen/H/emit/value.h) every variable currently visible
88 // in the enclosing scope, then pushes a TAG_FUNCTION value.
99 void codegen_lambda_expr(void);
1010
@@ -16,7 +16,7 @@ void codegen_named_function_value(KilnFunction *fn);
1616
1717 // `id` already resolved to variable `slot` holding a TAG_FUNCTION value;
1818 // current sits on the first argument or ')' (the '(' already consumed,
19-// same convention as codegen/expr_call.c's codegen_call). Parses args,
19+// same convention as codegen/C/expressions/expr_call.c's codegen_call). Parses args,
2020 // calls indirectly through the closure object, and pushes the (tag,
2121 // payload) result.
2222 void codegen_indirect_call(int slot);

kiln/src/codegen/H/io/argv_builtin.hmodified

+1−1
@@ -1,7 +1,7 @@
11 #ifndef KILN_ARGV_BUILTIN_H
22 #define KILN_ARGV_BUILTIN_H
33
4-// argv(): no arguments -- codegen/builtins.c's dispatch just expects the
4+// argv(): no arguments -- codegen/C/builtins/builtins.c's dispatch just expects the
55 // closing ')' before calling this. Pushes an array of strings, one per
66 // process argument (argv[0] is the executable's own path, same
77 // convention as C's main(argc, argv)).

kiln/src/codegen/H/io/argv_builtin_internal.hmodified

+2−2
@@ -1,13 +1,13 @@
11 #ifndef KILN_ARGV_BUILTIN_INTERNAL_H
22 #define KILN_ARGV_BUILTIN_INTERNAL_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Windows has no kernel-provided argv array to read (see
66 // argv_builtin.c's header comment) -- GetCommandLineA() returns the raw
77 // command-line string instead, so the Windows path needs its own tokenizer
88 // rather than sharing codegen with the Linux path. Split into its own
99 // file to keep argv_builtin.c under ~200 lines; not part of the public
10-// codegen/argv_builtin.h surface, only argv_builtin.c calls this.
10+// codegen/H/io/argv_builtin.h surface, only argv_builtin.c calls this.
1111 void codegen_builtin_argv_windows(void);
1212
1313 #endif

kiln/src/codegen/H/io/file_path.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef KILN_FILE_PATH_H
22 #define KILN_FILE_PATH_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Kiln strings are length-prefixed, not null-terminated -- but the raw
66 // `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 @@
11 #ifndef KILN_INPUT_BUILTIN_H
22 #define KILN_INPUT_BUILTIN_H
33
4-// input(): no arguments -- codegen/builtins.c's dispatch just expects the
4+// input(): no arguments -- codegen/C/builtins/builtins.c's dispatch just expects the
55 // closing ')' before calling this.
66 void codegen_builtin_input(void);
77

kiln/src/codegen/H/platform/platform_console.hmodified

+3−3
@@ -1,9 +1,9 @@
11 #ifndef KILN_PLATFORM_CONSOLE_H
22 #define KILN_PLATFORM_CONSOLE_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Console I/O, dispatching on kiln_get_target() internally so call sites
6-// (codegen/print_int.c, codegen/errors.c, codegen/input_builtin.c) don't
6+// (codegen/C/runtime/print_int.c, codegen/C/runtime/errors.c, codegen/C/io/input_builtin.c) don't
77 // need their own target branch. Linux writes/reads a fixed fd (1/2/0)
88 // directly via raw syscall; Windows has no such fixed handle -- it has to
99 // call GetStdHandle first, so each of these costs one extra call there.
@@ -18,7 +18,7 @@ void platform_emit_write_stderr(CodeBuf *code);
1818 void platform_emit_read_stdin_byte(CodeBuf *code);
1919
2020 // Split out of platform_emit_read_stdin_byte for callers that read many
21-// bytes in a loop (codegen/input_builtin.c): looking the handle up once
21+// bytes in a loop (codegen/C/io/input_builtin.c): looking the handle up once
2222 // outside the loop instead of once per byte cuts a multi-byte line's
2323 // worth of GetStdHandle round-trips down to one, which matters on
2424 // 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 @@
11 #ifndef KILN_PLATFORM_FILE_H
22 #define KILN_PLATFORM_FILE_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Real file I/O, dispatching on kiln_get_target() internally so call
6-// sites (codegen/read_file_builtin.c, codegen/write_file_builtins.c)
6+// sites (codegen/C/io/read_file_builtin.c, codegen/C/io/write_file_builtins.c)
77 // don't need their own target branch. The fd/HANDLE kiln gets back is
88 // used the same way on both targets: a signed value, negative means
99 // "open failed" (Linux's -1 and Windows' INVALID_HANDLE_VALUE, which is

kiln/src/codegen/H/platform/win_call.hmodified

+3−3
@@ -1,12 +1,12 @@
11 #ifndef KILN_WIN_CALL_H
22 #define KILN_WIN_CALL_H
3-#include "codegen/emit.h"
4-#include "pe/pe_writer.h"
3+#include "codegen/H/emit/emit.h"
4+#include "pe/H/pe_writer.h"
55
66 // Windows x64 calling convention -- the caller-side sequence for calling
77 // an imported kernel32.dll function. New territory for this codebase:
88 // unlike kiln's own internal `fn` convention (stack-push based, see
9-// parser/parser_control.c), this has to match a REAL external ABI, with
9+// parser/C/statements/parser_control.c), this has to match a REAL external ABI, with
1010 // rules kiln has never had to satisfy before:
1111 // - first four integer/pointer args in RCX, RDX, R8, R9
1212 // - a mandatory 32-byte "shadow space" the CALLEE is allowed to spill

kiln/src/codegen/H/platform/win_file_call.hmodified

+3−3
@@ -1,11 +1,11 @@
11 #ifndef KILN_WIN_FILE_CALL_H
22 #define KILN_WIN_FILE_CALL_H
3-#include "pe/pe_writer.h"
3+#include "pe/H/pe_writer.h"
44
55 // Shared shape between ReadFile and WriteFile's argument lists (both are
66 // (handle, buffer, length, &ignored_out, NULL)) -- used by both
7-// codegen/platform_console.c (stdin/stdout/stderr) and
8-// codegen/platform_file.c (real files), so it lives here instead of
7+// codegen/C/platform/platform_console.c (stdin/stdout/stderr) and
8+// codegen/C/platform/platform_file.c (real files), so it lives here instead of
99 // being duplicated in each.
1010 //
1111 // In: RAX=handle, RSI=buf, RDI=len. `which` must be PE_IMPORT_READ_FILE

kiln/src/codegen/H/runtime/errors.hmodified

+5−5
@@ -1,11 +1,11 @@
11 #ifndef KILN_ERRORS_H
22 #define KILN_ERRORS_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
5-// Runtime (not compile-time -- see parser/parser.h's parse_error for
5+// Runtime (not compile-time -- see parser/H/core/parser.h's parse_error for
66 // that) errors: array out of bounds, missing map key, and so on.
77 // Emitted once, at the very start of the generated program (right after
8-// codegen/heap.c's heap_emit_startup): a single reusable "raise" routine
8+// codegen/C/runtime/heap.c's heap_emit_startup): a single reusable "raise" routine
99 // that every runtime error jumps to (never called -- there's nothing to
1010 // return to, control either resumes at a catch block or the process
1111 // exits).
@@ -17,9 +17,9 @@ void errors_emit_raise_routine_only(CodeBuf *code);
1717 int errors_raise_routine_offset(void);
1818
1919 // Embeds `msg` (compile-time-known, jumped over so it's never executed
20-// as instructions -- same technique codegen/strings.c uses for string
20+// as instructions -- same technique codegen/C/strings/strings.c uses for string
2121 // literals) and raises it: if a `try` is currently active (see
22-// parser/try_catch.c), unwinds to its `catch` block with `msg` bound as
22+// parser/C/statements/try_catch.c), unwinds to its `catch` block with `msg` bound as
2323 // a TAG_STRING value; otherwise writes it to stderr and exits with
2424 // status 1, same as before milestone 9.
2525 void errors_emit_die(CodeBuf *code, const char *msg);

kiln/src/codegen/H/runtime/heap.hmodified

+2−2
@@ -1,6 +1,6 @@
11 #ifndef KILN_HEAP_H
22 #define KILN_HEAP_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // A bump allocator, no free (matches ashvm's own lack of GC -- neither
66 // engine reclaims memory during a run, only at process exit). Backed by
@@ -13,7 +13,7 @@
1313
1414 // Emitted once, at the very start of the generated program (before the
1515 // top-level statement loop): grabs a 16MB arena and records its start as
16-// the heap bump pointer at KILN_GLOBALS_ADDR (see elf/elf_writer.h).
16+// the heap bump pointer at KILN_GLOBALS_ADDR (see elf/H/elf_writer.h).
1717 void heap_emit_startup(CodeBuf *code);
1818
1919 // Plan B: emits ONLY the alloc routine's body (no arena grab) -- used by

kiln/src/codegen/H/runtime/print_int.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef KILN_CODEGEN_PRINT_INT_H
22 #define KILN_CODEGEN_PRINT_INT_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Emitted once, at program start (see parser.c's compile_program) --
66 // must run before any call to codegen_print_top below.

kiln/src/codegen/H/strings/string_alloc.hmodified

+3−3
@@ -1,6 +1,6 @@
11 #ifndef KILN_STRING_ALLOC_H
22 #define KILN_STRING_ALLOC_H
3-#include "codegen/emit.h"
3+#include "codegen/H/emit/emit.h"
44
55 // Emitted once, at program start (see parser.c's compile_program) --
66 // must run after heap_emit_startup (this calls heap_emit_alloc) and
@@ -15,8 +15,8 @@ int string_alloc_prefixed_routine_offset(void);
1515 // Allocates a heap block for a new TAG_STRING value's content: input
1616 // RDX=content length, output RAX=block address with the length prefix
1717 // already written at [RAX+0] (the payload is RAX+8, same layout
18-// codegen/strings.c's literals use). Clobbers RSI, RDI (via
19-// codegen/heap.c's heap_emit_alloc) -- RDX itself survives untouched.
18+// codegen/C/strings/strings.c's literals use). Clobbers RSI, RDI (via
19+// codegen/C/runtime/heap.c's heap_emit_alloc) -- RDX itself survives untouched.
2020 // Shared by every milestone-10 string builtin that produces a new string
2121 // (upper/lower/trim/substring/join/replace) so the "+8 for the length
2222 // prefix" arithmetic exists in exactly one place. Plan B, phase B1: a

kiln/src/codegen/H/strings/string_builtins.hmodified

+2−2
@@ -2,14 +2,14 @@
22 #define KILN_STRING_BUILTINS_H
33
44 // upper/lower/trim assume their one STRING argument already pushed --
5-// codegen/builtins.c's dispatch calls these after parsing the argument.
5+// codegen/C/builtins/builtins.c's dispatch calls these after parsing the argument.
66 void codegen_builtin_upper(void);
77 void codegen_builtin_lower(void);
88 void codegen_builtin_trim(void);
99
1010 // substring/indexOf/split/join/replace self-parse their (multiple)
1111 // arguments starting right after the already-consumed '(', same
12-// convention as codegen/higher_order.h's map/filter/reduce.
12+// convention as codegen/H/builtins/higher_order.h's map/filter/reduce.
1313 void codegen_builtin_substring(void);
1414 void codegen_builtin_indexof(void);
1515 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);
2020 // saved BEFORE calling -- these clobber RAX,RBX,RCX,RDX,RSI,RDI freely).
2121
2222 // Pushes (tag=STRING, payload=<new heap address>) -- the concatenation.
23-// Needs a real heap allocation (see codegen/heap.h) since the combined
23+// Needs a real heap allocation (see codegen/H/runtime/heap.h) since the combined
2424 // size is only known at runtime.
2525 void codegen_string_concat(void);
2626

kiln/src/codegen/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/builtins/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/collections/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/emit/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/expressions/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/functions/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/io/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/platform/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/runtime/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/codegen/O/strings/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/diagnostics/C/diagnostics.cmodified

+1−1
@@ -2,7 +2,7 @@
22 #include <stdio.h>
33 #include <string.h>
44 #include <unistd.h>
5-#include "diagnostics/diagnostics.h"
5+#include "diagnostics/H/diagnostics.h"
66
77 static const char *g_source = NULL;
88 static const char *g_filename = "source";

kiln/src/diagnostics/D/diagnostics.dadded

+3−0
@@ -0,0 +1,3 @@
1+src/diagnostics/O/diagnostics.o: src/diagnostics/C/diagnostics.c \
2+ src/diagnostics/H/diagnostics.h
3+src/diagnostics/H/diagnostics.h:

kiln/src/diagnostics/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/elf/C/elf_dynamic.cmodified

+2−2
@@ -2,7 +2,7 @@
22 #include <stdlib.h>
33 #include <string.h>
44 #include <sys/stat.h>
5-#include "elf/elf_dynamic.h"
5+#include "elf/H/elf_dynamic.h"
66
77 // Hand-written dynamically-linked ELF64 executable: PT_INTERP so the
88 // kernel hands off to the REAL system dynamic linker, PT_DYNAMIC with
@@ -18,7 +18,7 @@
1818
1919 static const char *const runtime_names[] = {
2020 #define RUNTIME_EXPORT(name, str) str,
21-#include "codegen/runtime_exports.def"
21+#include "codegen/H/emit/runtime_exports.def"
2222 #undef RUNTIME_EXPORT
2323 };
2424

kiln/src/elf/C/elf_dynamic_call.cmodified

+1−1
@@ -1,4 +1,4 @@
1-#include "elf/elf_dynamic_call.h"
1+#include "elf/H/elf_dynamic_call.h"
22
33 void elf_dynamic_call(CodeBuf *code, RuntimeImport which) {
44 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 @@
22 #include <stdlib.h>
33 #include <string.h>
44 #include <sys/stat.h>
5-#include "elf/elf_so_writer.h"
6-#include "elf/elf_dynamic.h"
7-#include "codegen/heap.h"
8-#include "codegen/bytes.h"
9-#include "codegen/string_alloc.h"
10-#include "codegen/print_int.h"
11-#include "codegen/errors.h"
12-#include "target.h"
5+#include "elf/H/elf_so_writer.h"
6+#include "elf/H/elf_dynamic.h"
7+#include "codegen/H/runtime/heap.h"
8+#include "codegen/H/emit/bytes.h"
9+#include "codegen/H/strings/string_alloc.h"
10+#include "codegen/H/runtime/print_int.h"
11+#include "codegen/H/runtime/errors.h"
12+#include "app/H/target.h"
1313
1414 static const char *const export_names[] = {
1515 #define RUNTIME_EXPORT(name, str) str,
16-#include "codegen/runtime_exports.def"
16+#include "codegen/H/emit/runtime_exports.def"
1717 #undef RUNTIME_EXPORT
1818 };
1919
@@ -44,7 +44,7 @@ static uint32_t elf_hash(const char *name) {
4444 int elf_write_shared_runtime(const char *path) {
4545 // ---- compile the runtime itself, position-independent, into its own
4646 // fresh CodeBuf. Link mode STAYS shared (main.c sets it before
47- // calling this) so codegen/layout.c resolves globals addresses using
47+ // calling this) so codegen/C/emit/layout.c resolves globals addresses using
4848 // the shared-mode executable layout -- but kiln_set_compiling_so(1)
4949 // makes each routine's OWN call sites (e.g. string_alloc_prefixed
5050 // calling heap_emit_alloc) resolve as ordinary same-buffer relative

kiln/src/elf/C/elf_writer.cmodified

+2−2
@@ -2,7 +2,7 @@
22 #include <stdlib.h>
33 #include <string.h>
44 #include <sys/stat.h>
5-#include "elf/elf_writer.h"
5+#include "elf/H/elf_writer.h"
66
77 static void put8(CodeBuf *f, uint8_t v) {
88 if (f->count >= f->capacity) {
@@ -48,7 +48,7 @@ int elf_write_executable(const char *path, const CodeBuf *machine_code) {
4848 put32(&file, 1); // p_type = PT_LOAD
4949 // p_flags = PF_R | PF_W | PF_X. Milestone 1-4 only needed R|X (code
5050 // never wrote into its own segment); milestone 5's heap bump pointer
51- // (see elf_writer.h / codegen/heap.c) is a global living inside this
51+ // (see elf_writer.h / codegen/C/runtime/heap.c) is a global living inside this
5252 // same segment, so it needs to be writable too. A real compiler would
5353 // split .text (R|X) from .data (R|W) into separate segments -- kiln
5454 // 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 @@
1+src/elf/O/elf_dynamic.o: src/elf/C/elf_dynamic.c src/elf/H/elf_dynamic.h \
2+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_import_enum.h \
3+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_writer.h \
4+ src/codegen/H/emit/runtime_layout.h
5+src/elf/H/elf_dynamic.h:
6+src/codegen/H/emit/emit.h:
7+src/codegen/H/emit/runtime_import_enum.h:
8+src/codegen/H/emit/runtime_exports.def:
9+src/elf/H/elf_writer.h:
10+src/codegen/H/emit/runtime_layout.h:

kiln/src/elf/D/elf_dynamic_call.dadded

+12−0
@@ -0,0 +1,12 @@
1+src/elf/O/elf_dynamic_call.o: src/elf/C/elf_dynamic_call.c \
2+ src/elf/H/elf_dynamic_call.h src/elf/H/elf_dynamic.h \
3+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_import_enum.h \
4+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_writer.h \
5+ src/codegen/H/emit/runtime_layout.h
6+src/elf/H/elf_dynamic_call.h:
7+src/elf/H/elf_dynamic.h:
8+src/codegen/H/emit/emit.h:
9+src/codegen/H/emit/runtime_import_enum.h:
10+src/codegen/H/emit/runtime_exports.def:
11+src/elf/H/elf_writer.h:
12+src/codegen/H/emit/runtime_layout.h:

kiln/src/elf/D/elf_so_writer.dadded

+21−0
@@ -0,0 +1,21 @@
1+src/elf/O/elf_so_writer.o: src/elf/C/elf_so_writer.c \
2+ src/elf/H/elf_so_writer.h src/elf/H/elf_dynamic.h \
3+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_import_enum.h \
4+ src/codegen/H/emit/runtime_exports.def src/elf/H/elf_writer.h \
5+ src/codegen/H/emit/runtime_layout.h src/codegen/H/runtime/heap.h \
6+ src/codegen/H/emit/bytes.h src/codegen/H/strings/string_alloc.h \
7+ src/codegen/H/runtime/print_int.h src/codegen/H/runtime/errors.h \
8+ src/app/H/target.h
9+src/elf/H/elf_so_writer.h:
10+src/elf/H/elf_dynamic.h:
11+src/codegen/H/emit/emit.h:
12+src/codegen/H/emit/runtime_import_enum.h:
13+src/codegen/H/emit/runtime_exports.def:
14+src/elf/H/elf_writer.h:
15+src/codegen/H/emit/runtime_layout.h:
16+src/codegen/H/runtime/heap.h:
17+src/codegen/H/emit/bytes.h:
18+src/codegen/H/strings/string_alloc.h:
19+src/codegen/H/runtime/print_int.h:
20+src/codegen/H/runtime/errors.h:
21+src/app/H/target.h:

kiln/src/elf/D/elf_writer.dadded

+5−0
@@ -0,0 +1,5 @@
1+src/elf/O/elf_writer.o: src/elf/C/elf_writer.c src/elf/H/elf_writer.h \
2+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h
3+src/elf/H/elf_writer.h:
4+src/codegen/H/emit/emit.h:
5+src/codegen/H/emit/runtime_layout.h:

kiln/src/elf/H/elf_dynamic.hmodified

+3−3
@@ -1,8 +1,8 @@
11 #ifndef KILN_ELF_DYNAMIC_H
22 #define KILN_ELF_DYNAMIC_H
3-#include "codegen/emit.h"
4-#include "codegen/runtime_import_enum.h"
5-#include "elf/elf_writer.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/emit/runtime_import_enum.h"
5+#include "elf/H/elf_writer.h"
66
77 // Layout for a --link=shared kiln executable: real dynamic linking, the
88 // kernel hands off to the system's actual /lib64/ld-linux-x86-64.so.2 (a

kiln/src/elf/H/elf_dynamic_call.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef KILN_ELF_DYNAMIC_CALL_H
22 #define KILN_ELF_DYNAMIC_CALL_H
3-#include "elf/elf_dynamic.h"
3+#include "elf/H/elf_dynamic.h"
44
55 // Calls `which` through its GOT slot (filled in by ld.so before this
66 // program's own code ever runs) -- a single `call [addr]` touching no

kiln/src/elf/H/elf_so_writer.hmodified

+2−2
@@ -4,8 +4,8 @@
44 // Compiles the runtime (heap/bytes/string_alloc/print/errors-raise) into
55 // a fresh, position-independent CodeBuf and writes it as a real ET_DYN
66 // ELF64 shared object at `path` -- one exported symbol per
7-// codegen/runtime_exports.def entry, loadable by the system's real
8-// dynamic linker (validated structure, see elf/elf_dynamic.h's header
7+// codegen/H/emit/runtime_exports.def entry, loadable by the system's real
8+// dynamic linker (validated structure, see elf/H/elf_dynamic.h's header
99 // comment). Returns 0 on success.
1010 int elf_write_shared_runtime(const char *path);
1111

kiln/src/elf/H/elf_writer.hmodified

+6−6
@@ -1,9 +1,9 @@
11 #ifndef KILN_ELF_WRITER_H
22 #define KILN_ELF_WRITER_H
3-#include "codegen/emit.h"
4-#include "codegen/runtime_layout.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/emit/runtime_layout.h"
55
6-// Layout constants shared with codegen/heap.c: kiln generates a fixed,
6+// Layout constants shared with codegen/C/runtime/heap.c: kiln generates a fixed,
77 // non-PIE executable (always loaded at KILN_LOAD_BASE), so absolute
88 // addresses are known at compile time. Milestone 5 needs one such fixed
99 // address for the heap bump pointer (a "global" -- there's no per-call
@@ -15,8 +15,8 @@
1515 #define KILN_PHDR_SIZE 56
1616
1717 // Milestone 9: the globals region also holds kiln's own hand-rolled
18-// setjmp/longjmp equivalent for try/catch (see codegen/errors.c's raise
19-// routine and parser/try_catch.c) -- a fixed-depth stack of "handler"
18+// setjmp/longjmp equivalent for try/catch (see codegen/C/runtime/errors.c's raise
19+// routine and parser/C/statements/try_catch.c) -- a fixed-depth stack of "handler"
2020 // records, since this is a freestanding binary with no libc setjmp to
2121 // call. Each handler is {saved_rsp, saved_rbp, target_addr,
2222 // error_slot_rbp_offset}, 4 x int64. Bounded the same way every other
@@ -31,7 +31,7 @@
3131 // saves that original RSP here -- a fixed absolute address, reachable
3232 // from any frame later on, since a called function's own RBP is no
3333 // longer the original one by the time argv() might be called from
34-// inside it (see codegen/argv_builtin.c).
34+// inside it (see codegen/C/io/argv_builtin.c).
3535 #define KILN_ARGV_SIZE 8
3636
3737 #define KILN_GLOBALS_SIZE (8 + KILN_TRY_DEPTH_SIZE + KILN_TRY_HANDLERS_SIZE + KILN_ARGV_SIZE) // heap_ptr, try_depth, handler stack, argv

kiln/src/elf/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/lexer/C/lexer.cmodified

+3−3
@@ -1,7 +1,7 @@
11 #include <string.h>
22 #include <ctype.h>
3-#include "lexer/lexer.h"
4-#include "lexer/lexer_import.h"
3+#include "lexer/H/lexer.h"
4+#include "lexer/H/lexer_import.h"
55
66 // lex_* (not the bare start/current/line these had as file-static
77 // before) -- shared with lexer_import.c now, and a plain `current` would
@@ -89,7 +89,7 @@ Token error_token(const char *message) {
8989 // lexer just has to not stop early and hand back a truncated token.
9090 // Underscore digit separators (1_000_000) are the one thing strtod
9191 // itself doesn't understand -- primary() strips those out of the token
92-// text before calling strtod, see codegen/expr.c.
92+// text before calling strtod, see codegen/C/expressions/expr.c.
9393 static Token number(void) {
9494 if (lex_start[0] == '0' && (peek() == 'x' || peek() == 'X')) {
9595 advance(); // consume 'x'/'X'

kiln/src/lexer/C/lexer_import.cmodified

+1−1
@@ -1,4 +1,4 @@
1-#include "lexer/lexer_import.h"
1+#include "lexer/H/lexer_import.h"
22
33 LexerState lexer_save_state(void) {
44 LexerState state;

kiln/src/lexer/D/lexer.dadded

+4−0
@@ -0,0 +1,4 @@
1+src/lexer/O/lexer.o: src/lexer/C/lexer.c src/lexer/H/lexer.h \
2+ src/lexer/H/lexer_import.h
3+src/lexer/H/lexer.h:
4+src/lexer/H/lexer_import.h:

kiln/src/lexer/D/lexer_import.dadded

+4−0
@@ -0,0 +1,4 @@
1+src/lexer/O/lexer_import.o: src/lexer/C/lexer_import.c \
2+ src/lexer/H/lexer_import.h src/lexer/H/lexer.h
3+src/lexer/H/lexer_import.h:
4+src/lexer/H/lexer.h:

kiln/src/lexer/H/lexer_import.hmodified

+1−1
@@ -1,6 +1,6 @@
11 #ifndef KILN_LEXER_IMPORT_H
22 #define KILN_LEXER_IMPORT_H
3-#include "lexer/lexer.h"
3+#include "lexer/H/lexer.h"
44
55 // Cross-file link between lexer.c (the tokenizer's cursor state and its
66 // low-level scan primitives) and lexer_import.c (state save/restore plus

kiln/src/lexer/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/parser/C/core/parser.cmodified

+25−25
@@ -1,26 +1,26 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "parser/parser.h"
5-#include "parser/parser_internal.h"
6-#include "parser/vars.h"
7-#include "parser/loop_stack.h"
8-#include "parser/functions.h"
9-#include "parser/imports.h"
10-#include "parser/constants.h"
11-#include "codegen/expr.h"
12-#include "codegen/emit_sse.h"
13-#include "codegen/value.h"
14-#include "codegen/heap.h"
15-#include "codegen/bytes.h"
16-#include "codegen/string_alloc.h"
17-#include "codegen/arrays.h"
18-#include "codegen/maps.h"
19-#include "codegen/errors.h"
20-#include "codegen/print_int.h"
21-#include "diagnostics/diagnostics.h"
22-#include "elf/elf_writer.h"
23-#include "target.h"
4+#include "parser/H/core/parser.h"
5+#include "parser/H/core/parser_internal.h"
6+#include "parser/H/declarations/vars.h"
7+#include "parser/H/statements/loop_stack.h"
8+#include "parser/H/declarations/functions.h"
9+#include "parser/H/imports/imports.h"
10+#include "parser/H/declarations/constants.h"
11+#include "codegen/H/expressions/expr.h"
12+#include "codegen/H/emit/emit_sse.h"
13+#include "codegen/H/emit/value.h"
14+#include "codegen/H/runtime/heap.h"
15+#include "codegen/H/emit/bytes.h"
16+#include "codegen/H/strings/string_alloc.h"
17+#include "codegen/H/collections/arrays.h"
18+#include "codegen/H/collections/maps.h"
19+#include "codegen/H/runtime/errors.h"
20+#include "codegen/H/runtime/print_int.h"
21+#include "diagnostics/H/diagnostics.h"
22+#include "elf/H/elf_writer.h"
23+#include "app/H/target.h"
2424
2525 Token current;
2626 Token previous;
@@ -264,7 +264,7 @@ static void assignment_statement(void) {
264264 }
265265
266266 // return [expr] ; -- bare `return;` returns 0, matching ashc/ashvm.
267-// Return value comes back as RBX=tag, RAX=payload (see codegen/expr.c's
267+// Return value comes back as RBX=tag, RAX=payload (see codegen/C/expressions/expr.c's
268268 // call-site handling).
269269 static void return_statement(void) {
270270 advance_token();
@@ -285,7 +285,7 @@ static void return_statement(void) {
285285
286286 // throw expr ; -- expr must be a STRING (matches try/catch's own
287287 // convention: every caught error, built-in or user-thrown, is a plain
288-// string). Reuses codegen/errors.c's raise routine directly -- the exact
288+// string). Reuses codegen/C/runtime/errors.c's raise routine directly -- the exact
289289 // same catch/unwind mechanism M9's built-in errors (array bounds, missing
290290 // map key) already go through, just with a runtime message instead of a
291291 // compile-time-constant one.
@@ -302,7 +302,7 @@ static void throw_statement(void) {
302302
303303 // break ; -- jumps past the innermost loop; the jump is recorded, not
304304 // resolved here, since the innermost loop's own codegen (parser_control.c's
305-// while_statement / parser/for_loop.c's for_statement) hasn't emitted the
305+// while_statement / parser/C/statements/for_loop.c's for_statement) hasn't emitted the
306306 // "after the loop" landing point yet.
307307 static void break_statement(void) {
308308 advance_token();
@@ -372,7 +372,7 @@ void compile_program(const char *source, const char *source_path, CodeBuf *out)
372372 // the whole program where that original RSP is still available
373373 // (nothing has touched it yet), so it's saved to a fixed globals
374374 // address here, before anything else, for argv() to read later from
375- // any frame (see codegen/argv_builtin.c and elf/elf_writer.h's
375+ // any frame (see codegen/C/io/argv_builtin.c and elf/H/elf_writer.h's
376376 // KILN_ARGV_ADDR comment). Windows has no equivalent need: argv()
377377 // there calls GetCommandLineA() directly, callable at any point, so
378378 // there's nothing to snapshot this early.
@@ -387,7 +387,7 @@ void compile_program(const char *source, const char *source_path, CodeBuf *out)
387387 // frame (see parser_control.c's fn_statement/parser.c's
388388 // return_statement) without disturbing this one -- the callee always
389389 // restores RBP before returning. Milestone 5: each slot is now 16
390- // bytes (tag + payload, see codegen/value.h), not 8.
390+ // bytes (tag + payload, see codegen/H/emit/value.h), not 8.
391391 emit_mov_reg_reg(code, REG_RBP, REG_RSP);
392392 emit_sub_reg_imm32(code, REG_RSP, KILN_FRAME_RESERVE);
393393

kiln/src/parser/C/declarations/constants.cmodified

+5−5
@@ -1,10 +1,10 @@
11 #include <string.h>
22 #include <stdint.h>
3-#include "parser/constants.h"
4-#include "parser/parser.h"
5-#include "codegen/emit.h"
6-#include "codegen/value.h"
7-#include "codegen/strings.h"
3+#include "parser/H/declarations/constants.h"
4+#include "parser/H/core/parser.h"
5+#include "codegen/H/emit/emit.h"
6+#include "codegen/H/emit/value.h"
7+#include "codegen/H/strings/strings.h"
88
99 static KilnConstant constants[MAX_KILN_CONSTS];
1010 static int constant_count = 0;

kiln/src/parser/C/declarations/functions.cmodified

+2−2
@@ -1,7 +1,7 @@
11 #include <string.h>
22 #include <stdio.h>
3-#include "parser/functions.h"
4-#include "parser/parser.h"
3+#include "parser/H/declarations/functions.h"
4+#include "parser/H/core/parser.h"
55
66 static KilnFunction functions[MAX_KILN_FUNCS];
77 static int function_count = 0;

kiln/src/parser/C/declarations/vars.cmodified

+3−3
@@ -1,13 +1,13 @@
11 #include <string.h>
2-#include "parser/vars.h"
3-#include "parser/parser.h"
2+#include "parser/H/declarations/vars.h"
3+#include "parser/H/core/parser.h"
44
55 static char var_names[MAX_KILN_VARS][64];
66 static int var_count = 0;
77 static int scope_start = 0;
88
99 // Scans newest-first (most-recently-declared wins), standard shadowing
10-// semantics -- required for try/catch: parser/try_catch.c reserves each
10+// semantics -- required for try/catch: parser/C/statements/try_catch.c reserves each
1111 // catch variable's slot with a synthetic placeholder name and renames it
1212 // to the real name only after the fact (the slot's rbp-offset has to be
1313 // known before the try body compiles, before the real name is even

kiln/src/parser/C/imports/import_paths.cmodified

+1−1
@@ -2,7 +2,7 @@
22 #include <string.h>
33 #include <stdio.h>
44 #include <stdlib.h>
5-#include "parser/import_paths.h"
5+#include "parser/H/imports/import_paths.h"
66
77 void import_path_dirname(const char *path, char *out, int out_size) {
88 const char *slash = strrchr(path, '/');

kiln/src/parser/C/imports/imports.cmodified

+7−7
@@ -3,13 +3,13 @@
33 #include <stdio.h>
44 #include <stdlib.h>
55 #include <limits.h>
6-#include "parser/imports.h"
7-#include "parser/import_paths.h"
8-#include "parser/parser.h"
9-#include "parser/parser_internal.h"
10-#include "parser/functions.h"
11-#include "lexer/lexer.h"
12-#include "diagnostics/diagnostics.h"
6+#include "parser/H/imports/imports.h"
7+#include "parser/H/imports/import_paths.h"
8+#include "parser/H/core/parser.h"
9+#include "parser/H/core/parser_internal.h"
10+#include "parser/H/declarations/functions.h"
11+#include "lexer/H/lexer.h"
12+#include "diagnostics/H/diagnostics.h"
1313
1414 #define MAX_KILN_IMPORTS 16
1515 #define MAX_KILN_IMPORT_DEPTH 8

kiln/src/parser/C/statements/for_loop.cmodified

+7−7
@@ -1,10 +1,10 @@
1-#include "parser/for_loop.h"
2-#include "parser/parser.h"
3-#include "parser/parser_internal.h"
4-#include "parser/vars.h"
5-#include "parser/loop_stack.h"
6-#include "codegen/expr.h"
7-#include "codegen/emit.h"
1+#include "parser/H/statements/for_loop.h"
2+#include "parser/H/core/parser.h"
3+#include "parser/H/core/parser_internal.h"
4+#include "parser/H/declarations/vars.h"
5+#include "parser/H/statements/loop_stack.h"
6+#include "codegen/H/expressions/expr.h"
7+#include "codegen/H/emit/emit.h"
88
99 static int for_nesting_depth = 0;
1010

kiln/src/parser/C/statements/loop_stack.cmodified

+2−2
@@ -1,5 +1,5 @@
1-#include "parser/loop_stack.h"
2-#include "parser/parser.h"
1+#include "parser/H/statements/loop_stack.h"
2+#include "parser/H/core/parser.h"
33
44 #define MAX_LOOP_NESTING 16
55 #define MAX_LOOP_JUMPS 64

kiln/src/parser/C/statements/parser_control.cmodified

+9−9
@@ -1,13 +1,13 @@
11 #include <string.h>
2-#include "parser/parser.h"
3-#include "parser/parser_internal.h"
4-#include "parser/vars.h"
5-#include "parser/functions.h"
6-#include "parser/for_loop.h"
7-#include "parser/loop_stack.h"
8-#include "codegen/expr.h"
9-#include "codegen/emit_sse.h"
10-#include "codegen/value.h"
2+#include "parser/H/core/parser.h"
3+#include "parser/H/core/parser_internal.h"
4+#include "parser/H/declarations/vars.h"
5+#include "parser/H/declarations/functions.h"
6+#include "parser/H/statements/for_loop.h"
7+#include "parser/H/statements/loop_stack.h"
8+#include "codegen/H/expressions/expr.h"
9+#include "codegen/H/emit/emit_sse.h"
10+#include "codegen/H/emit/value.h"
1111
1212 // Truthiness test for if/while conditions: pop the value (tag discarded,
1313 // assumed NUMBER -- matches ashvm's own truthy(), which requires a

kiln/src/parser/C/statements/try_catch.cmodified

+9−9
@@ -1,18 +1,18 @@
1-#include "parser/parser.h"
2-#include "parser/parser_internal.h"
3-#include "parser/vars.h"
4-#include "codegen/emit.h"
5-#include "codegen/errors.h"
6-#include "codegen/layout.h"
7-#include "codegen/runtime_layout.h"
1+#include "parser/H/core/parser.h"
2+#include "parser/H/core/parser_internal.h"
3+#include "parser/H/declarations/vars.h"
4+#include "codegen/H/emit/emit.h"
5+#include "codegen/H/runtime/errors.h"
6+#include "codegen/H/emit/layout.h"
7+#include "codegen/H/emit/runtime_layout.h"
88
99 // try { A } catch (e) { B }
1010 //
1111 // A handler stack living in the fixed globals region (see
12-// elf/elf_writer.h) holds, per active try, the (rsp, rbp) to restore and
12+// elf/H/elf_writer.h) holds, per active try, the (rsp, rbp) to restore and
1313 // the (target address, error-variable rbp-offset) to resume at -- kiln's
1414 // own setjmp/longjmp equivalent, hand-rolled since this is a freestanding
15-// binary with no libc to call into (see codegen/errors.c's raise routine
15+// binary with no libc to call into (see codegen/C/runtime/errors.c's raise routine
1616 // for the runtime half of this).
1717 //
1818 // The catch variable's slot has to be reserved BEFORE compiling A: its

kiln/src/parser/D/core/parser.dadded

+36−0
@@ -0,0 +1,36 @@
1+src/parser/O/core/parser.o: src/parser/C/core/parser.c \
2+ src/parser/H/core/parser.h src/lexer/H/lexer.h src/codegen/H/emit/emit.h \
3+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \
4+ src/parser/H/statements/loop_stack.h \
5+ src/parser/H/declarations/functions.h src/parser/H/imports/imports.h \
6+ src/parser/H/declarations/constants.h src/codegen/H/expressions/expr.h \
7+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h \
8+ src/codegen/H/runtime/heap.h src/codegen/H/emit/bytes.h \
9+ src/codegen/H/strings/string_alloc.h src/codegen/H/collections/arrays.h \
10+ src/codegen/H/collections/maps.h src/codegen/H/runtime/errors.h \
11+ src/codegen/H/runtime/print_int.h src/diagnostics/H/diagnostics.h \
12+ src/elf/H/elf_writer.h src/codegen/H/emit/runtime_layout.h \
13+ src/app/H/target.h
14+src/parser/H/core/parser.h:
15+src/lexer/H/lexer.h:
16+src/codegen/H/emit/emit.h:
17+src/parser/H/core/parser_internal.h:
18+src/parser/H/declarations/vars.h:
19+src/parser/H/statements/loop_stack.h:
20+src/parser/H/declarations/functions.h:
21+src/parser/H/imports/imports.h:
22+src/parser/H/declarations/constants.h:
23+src/codegen/H/expressions/expr.h:
24+src/codegen/H/emit/emit_sse.h:
25+src/codegen/H/emit/value.h:
26+src/codegen/H/runtime/heap.h:
27+src/codegen/H/emit/bytes.h:
28+src/codegen/H/strings/string_alloc.h:
29+src/codegen/H/collections/arrays.h:
30+src/codegen/H/collections/maps.h:
31+src/codegen/H/runtime/errors.h:
32+src/codegen/H/runtime/print_int.h:
33+src/diagnostics/H/diagnostics.h:
34+src/elf/H/elf_writer.h:
35+src/codegen/H/emit/runtime_layout.h:
36+src/app/H/target.h:

kiln/src/parser/D/declarations/constants.dadded

+11−0
@@ -0,0 +1,11 @@
1+src/parser/O/declarations/constants.o: \
2+ src/parser/C/declarations/constants.c \
3+ src/parser/H/declarations/constants.h src/parser/H/core/parser.h \
4+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h src/codegen/H/emit/value.h \
5+ src/codegen/H/strings/strings.h
6+src/parser/H/declarations/constants.h:
7+src/parser/H/core/parser.h:
8+src/lexer/H/lexer.h:
9+src/codegen/H/emit/emit.h:
10+src/codegen/H/emit/value.h:
11+src/codegen/H/strings/strings.h:

kiln/src/parser/D/declarations/functions.dadded

+8−0
@@ -0,0 +1,8 @@
1+src/parser/O/declarations/functions.o: \
2+ src/parser/C/declarations/functions.c \
3+ src/parser/H/declarations/functions.h src/parser/H/core/parser.h \
4+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h
5+src/parser/H/declarations/functions.h:
6+src/parser/H/core/parser.h:
7+src/lexer/H/lexer.h:
8+src/codegen/H/emit/emit.h:

kiln/src/parser/D/declarations/vars.dadded

+7−0
@@ -0,0 +1,7 @@
1+src/parser/O/declarations/vars.o: src/parser/C/declarations/vars.c \
2+ src/parser/H/declarations/vars.h src/parser/H/core/parser.h \
3+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h
4+src/parser/H/declarations/vars.h:
5+src/parser/H/core/parser.h:
6+src/lexer/H/lexer.h:
7+src/codegen/H/emit/emit.h:

kiln/src/parser/D/imports/import_paths.dadded

+3−0
@@ -0,0 +1,3 @@
1+src/parser/O/imports/import_paths.o: src/parser/C/imports/import_paths.c \
2+ src/parser/H/imports/import_paths.h
3+src/parser/H/imports/import_paths.h:

kiln/src/parser/D/imports/imports.dadded

+13−0
@@ -0,0 +1,13 @@
1+src/parser/O/imports/imports.o: src/parser/C/imports/imports.c \
2+ src/parser/H/imports/imports.h src/parser/H/imports/import_paths.h \
3+ src/parser/H/core/parser.h src/lexer/H/lexer.h src/codegen/H/emit/emit.h \
4+ src/parser/H/core/parser_internal.h \
5+ src/parser/H/declarations/functions.h src/diagnostics/H/diagnostics.h
6+src/parser/H/imports/imports.h:
7+src/parser/H/imports/import_paths.h:
8+src/parser/H/core/parser.h:
9+src/lexer/H/lexer.h:
10+src/codegen/H/emit/emit.h:
11+src/parser/H/core/parser_internal.h:
12+src/parser/H/declarations/functions.h:
13+src/diagnostics/H/diagnostics.h:

kiln/src/parser/D/statements/for_loop.dadded

+13−0
@@ -0,0 +1,13 @@
1+src/parser/O/statements/for_loop.o: src/parser/C/statements/for_loop.c \
2+ src/parser/H/statements/for_loop.h src/parser/H/core/parser.h \
3+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \
4+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \
5+ src/parser/H/statements/loop_stack.h src/codegen/H/expressions/expr.h
6+src/parser/H/statements/for_loop.h:
7+src/parser/H/core/parser.h:
8+src/lexer/H/lexer.h:
9+src/codegen/H/emit/emit.h:
10+src/parser/H/core/parser_internal.h:
11+src/parser/H/declarations/vars.h:
12+src/parser/H/statements/loop_stack.h:
13+src/codegen/H/expressions/expr.h:

kiln/src/parser/D/statements/loop_stack.dadded

+8−0
@@ -0,0 +1,8 @@
1+src/parser/O/statements/loop_stack.o: \
2+ src/parser/C/statements/loop_stack.c \
3+ src/parser/H/statements/loop_stack.h src/parser/H/core/parser.h \
4+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h
5+src/parser/H/statements/loop_stack.h:
6+src/parser/H/core/parser.h:
7+src/lexer/H/lexer.h:
8+src/codegen/H/emit/emit.h:

kiln/src/parser/D/statements/parser_control.dadded

+18−0
@@ -0,0 +1,18 @@
1+src/parser/O/statements/parser_control.o: \
2+ src/parser/C/statements/parser_control.c src/parser/H/core/parser.h \
3+ src/lexer/H/lexer.h src/codegen/H/emit/emit.h \
4+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \
5+ src/parser/H/declarations/functions.h src/parser/H/statements/for_loop.h \
6+ src/parser/H/statements/loop_stack.h src/codegen/H/expressions/expr.h \
7+ src/codegen/H/emit/emit_sse.h src/codegen/H/emit/value.h
8+src/parser/H/core/parser.h:
9+src/lexer/H/lexer.h:
10+src/codegen/H/emit/emit.h:
11+src/parser/H/core/parser_internal.h:
12+src/parser/H/declarations/vars.h:
13+src/parser/H/declarations/functions.h:
14+src/parser/H/statements/for_loop.h:
15+src/parser/H/statements/loop_stack.h:
16+src/codegen/H/expressions/expr.h:
17+src/codegen/H/emit/emit_sse.h:
18+src/codegen/H/emit/value.h:

kiln/src/parser/D/statements/try_catch.dadded

+13−0
@@ -0,0 +1,13 @@
1+src/parser/O/statements/try_catch.o: src/parser/C/statements/try_catch.c \
2+ src/parser/H/core/parser.h src/lexer/H/lexer.h src/codegen/H/emit/emit.h \
3+ src/parser/H/core/parser_internal.h src/parser/H/declarations/vars.h \
4+ src/codegen/H/runtime/errors.h src/codegen/H/emit/layout.h \
5+ src/codegen/H/emit/runtime_layout.h
6+src/parser/H/core/parser.h:
7+src/lexer/H/lexer.h:
8+src/codegen/H/emit/emit.h:
9+src/parser/H/core/parser_internal.h:
10+src/parser/H/declarations/vars.h:
11+src/codegen/H/runtime/errors.h:
12+src/codegen/H/emit/layout.h:
13+src/codegen/H/emit/runtime_layout.h:

kiln/src/parser/H/core/parser.hmodified

+3−3
@@ -1,9 +1,9 @@
11 #ifndef KILN_PARSER_H
22 #define KILN_PARSER_H
3-#include "lexer/lexer.h"
4-#include "codegen/emit.h"
3+#include "lexer/H/lexer.h"
4+#include "codegen/H/emit/emit.h"
55
6-// Shared parser state, read by codegen/expr.c as well as parser.c --
6+// Shared parser state, read by codegen/C/expressions/expr.c as well as parser.c --
77 // mirrors ashvm/src/compiler/state.h's split (state lives in a small
88 // header, expression codegen and statement parsing both consume it).
99 extern Token current;

kiln/src/parser/H/declarations/functions.hmodified

+3−3
@@ -7,7 +7,7 @@
77 // ashvm's compiler has (see emit_call_back's comment) -- so by the time a
88 // call site compiles, the callee's code_offset is always already known.
99 //
10-// Imports (see parser/imports.c) don't change this table's shape at all
10+// Imports (see parser/C/imports/imports.c) don't change this table's shape at all
1111 // -- an imported function is declared under a namespaced string (e.g.
1212 // "math.add") in the exact same flat array. 64 (up from 32) gives real
1313 // programs room to import a handful of libraries without hitting the cap
@@ -31,9 +31,9 @@ KilnFunction *resolve_function(const char *name, int len);
3131 // doesn't fit in the 64-byte name field.
3232 KilnFunction *declare_function(const char *name, int len);
3333
34-// --- Import namespace context (parser/imports.c sets/restores this around
34+// --- Import namespace context (parser/C/imports/imports.c sets/restores this around
3535 // each recursively-parsed imported file; parser_control.c's fn_statement
36-// and codegen/expr.c + expr_call.c's call-site resolution consult it) ---
36+// and codegen/C/expressions/expr.c + expr_call.c's call-site resolution consult it) ---
3737
3838 // Sets the namespace prefix every subsequent declare_function_in_context/
3939 // 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);
1616 int declare_var(const char *name, int len);
1717
1818 // Milestone 9: overwrites an already-declared slot's name in place (same
19-// slot index, new name) -- parser/try_catch.c needs a catch variable's
19+// slot index, new name) -- parser/C/statements/try_catch.c needs a catch variable's
2020 // slot reserved BEFORE its real name (`catch (e)`) is parsed, since the
2121 // slot's rbp-relative offset must be embedded into the handler struct at
2222 // try-entry, ahead of the try block's body.
2323 void rename_var(int slot, const char *name, int len);
2424
2525 // Milestone 5: each variable now holds a (tag, payload) pair (16 bytes,
26-// see codegen/value.h), not a bare 8-byte double -- so each slot takes
26+// see codegen/H/emit/value.h), not a bare 8-byte double -- so each slot takes
2727 // 16 bytes: tag at [rbp - 16*(i+1)], payload right after it at
2828 // [rbp - 16*(i+1) + 8], below the frame pointer set up by parser.c's
2929 // prologue (`mov rbp, rsp; sub rsp, MAX_KILN_VARS*16`). Shared here so
@@ -67,7 +67,7 @@ void vars_scope_end(VarBlockScope saved);
6767 int resolve_var_in_current_scope(const char *name, int len);
6868
6969 // Milestone 8: one extra RBP-relative slot beyond the normal variable
70-// table, reserved for codegen/closures.c's indirect-call codegen to stash
70+// table, reserved for codegen/C/functions/closures.c's indirect-call codegen to stash
7171 // a runtime-only capture_count across the `call` instruction (GP
7272 // registers are all freely clobbered by the callee; RBP is the one thing
7373 // provably restored to the caller's own value by the time any call
@@ -97,7 +97,7 @@ int32_t higher_order_scratch_offset(void);
9797 // at COMPILE TIME (nested `for` statements are literally nested calls in
9898 // this single-pass compiler), so each nesting level just gets its own
9999 // fixed offset rather than a runtime-tracked stack. Bounded the same way
100-// every other table here is; parser/for_loop.c resets its nesting
100+// every other table here is; parser/C/statements/for_loop.c resets its nesting
101101 // counter to 0 when entering a function or lambda body (mirroring
102102 // vars_save/vars_clear/vars_restore), since that body gets its own RBP
103103 // at runtime and can safely reuse the same offsets independently of how
@@ -107,7 +107,7 @@ int32_t higher_order_scratch_offset(void);
107107 #define KILN_FOR_STACK_SIZE (MAX_KILN_FOR_DEPTH * KILN_FOR_LEVEL_SIZE)
108108 int32_t for_level_offset(int depth);
109109
110-// Plan A, phase A3: one 8-byte RBP-relative slot for codegen/win_call.c to
110+// Plan A, phase A3: one 8-byte RBP-relative slot for codegen/C/platform/win_call.c to
111111 // stash the original RSP across a Windows API call (dynamic 16-byte align
112112 // + shadow space reservation clobbers RSP by an amount only known at
113113 // runtime, so it can't be undone with a fixed `add rsp, N` -- see

kiln/src/parser/H/statements/for_loop.hmodified

+1−1
@@ -8,7 +8,7 @@
88 //
99 // The compile-time for-nesting-depth counter's save/reset/restore, for
1010 // fn_statement/lambda.c to wrap around a called body's compilation (same
11-// spirit as parser/vars.h's vars_save/vars_clear/vars_restore): a
11+// spirit as parser/H/declarations/vars.h's vars_save/vars_clear/vars_restore): a
1212 // function or lambda body gets its own RBP at runtime, so its own `for`
1313 // loops can safely reuse the same offsets independently of how deep the
1414 // 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);
3636
3737 // Save/reset/restore the loop-nesting depth, for fn_statement/lambda.c
3838 // to wrap around a called body's compilation (same spirit as
39-// parser/vars.h's vars_save/vars_clear/vars_restore and for_loop.h's
39+// parser/H/declarations/vars.h's vars_save/vars_clear/vars_restore and for_loop.h's
4040 // for_depth_save/reset/restore): a break/continue inside a function or
4141 // lambda body must never reach past that body into an ENCLOSING loop it
4242 // happens to be textually written inside.

kiln/src/parser/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/parser/O/core/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/parser/O/declarations/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/parser/O/imports/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/parser/O/statements/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/src/pe/C/pe_dll_writer.cmodified

+9−9
@@ -1,25 +1,25 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "pe/pe_dll_writer.h"
5-#include "codegen/heap.h"
6-#include "codegen/bytes.h"
7-#include "codegen/string_alloc.h"
8-#include "codegen/print_int.h"
9-#include "codegen/errors.h"
10-#include "target.h"
4+#include "pe/H/pe_dll_writer.h"
5+#include "codegen/H/runtime/heap.h"
6+#include "codegen/H/emit/bytes.h"
7+#include "codegen/H/strings/string_alloc.h"
8+#include "codegen/H/runtime/print_int.h"
9+#include "codegen/H/runtime/errors.h"
10+#include "app/H/target.h"
1111
1212 // Hand-written PE32+ DLL: IMAGE_FILE_DLL characteristic, an Export Data
1313 // Directory instead of an Import one -- the Windows-side twin of
14-// elf/elf_so_writer.c. The Windows loader resolves imports-by-name via a
14+// elf/C/elf_so_writer.c. The Windows loader resolves imports-by-name via a
1515 // BINARY SEARCH over the DLL's Name Pointer Table, which means (unlike
1616 // ELF's hash-table symbol lookup) that table must be in sorted order, or
1717 // GetProcAddress-style resolution silently fails to find some exports --
1818 // see the sort below.
1919
2020 static const char *const export_names[] = {
2121 #define RUNTIME_EXPORT(name, str) str,
22-#include "codegen/runtime_exports.def"
22+#include "codegen/H/emit/runtime_exports.def"
2323 #undef RUNTIME_EXPORT
2424 };
2525

kiln/src/pe/C/pe_dynamic.cmodified

+4−4
@@ -1,26 +1,26 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "pe/pe_writer.h"
4+#include "pe/H/pe_writer.h"
55
66 // --link=shared PE executable: same "tiny PE" single-RWX-section
77 // technique as pe_writer.c's static-mode writer, but importing from TWO
88 // DLLs (kernel32.dll for OS calls, libkilnrt.dll for the runtime -- see
9-// pe/pe_dll_writer.h for the library side).
9+// pe/H/pe_dll_writer.h for the library side).
1010 //
1111 // Section layout:
1212 // [globals][import dir: k32,rt,null][ILT k32][IAT k32][ILT rt][IAT rt]
1313 // [code][hint/name: k32's 9, rt's 5][kernel32.dll][libkilnrt.dll]
1414
1515 static const char *const pe_import_names[] = {
1616 #define PE_IMPORT(name, str) str,
17-#include "pe/pe_imports.def"
17+#include "pe/H/pe_imports.def"
1818 #undef PE_IMPORT
1919 };
2020
2121 static const char *const runtime_import_names[] = {
2222 #define RUNTIME_EXPORT(name, str) str,
23-#include "codegen/runtime_exports.def"
23+#include "codegen/H/emit/runtime_exports.def"
2424 #undef RUNTIME_EXPORT
2525 };
2626

kiln/src/pe/C/pe_writer.cmodified

+4−4
@@ -1,11 +1,11 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33 #include <string.h>
4-#include "pe/pe_writer.h"
5-#include "target.h"
4+#include "pe/H/pe_writer.h"
5+#include "app/H/target.h"
66
77 // Hand-written minimal PE32+ console executable -- the Windows-side twin
8-// of elf/elf_writer.c's "tiny ELF" technique: one RWX section holding
8+// of elf/C/elf_writer.c's "tiny ELF" technique: one RWX section holding
99 // everything (globals, import tables, code), a fixed non-relocated image
1010 // base, no external linker involved.
1111 //
@@ -20,7 +20,7 @@
2020
2121 static const char *const pe_import_names[] = {
2222 #define PE_IMPORT(name, str) str,
23-#include "pe/pe_imports.def"
23+#include "pe/H/pe_imports.def"
2424 #undef PE_IMPORT
2525 };
2626

kiln/src/pe/D/pe_dll_writer.dadded

+21−0
@@ -0,0 +1,21 @@
1+src/pe/O/pe_dll_writer.o: src/pe/C/pe_dll_writer.c \
2+ src/pe/H/pe_dll_writer.h src/codegen/H/emit/runtime_import_enum.h \
3+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_writer.h \
4+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \
5+ src/pe/H/pe_imports.def src/codegen/H/runtime/heap.h \
6+ src/codegen/H/emit/bytes.h src/codegen/H/strings/string_alloc.h \
7+ src/codegen/H/runtime/print_int.h src/codegen/H/runtime/errors.h \
8+ src/app/H/target.h
9+src/pe/H/pe_dll_writer.h:
10+src/codegen/H/emit/runtime_import_enum.h:
11+src/codegen/H/emit/runtime_exports.def:
12+src/pe/H/pe_writer.h:
13+src/codegen/H/emit/emit.h:
14+src/codegen/H/emit/runtime_layout.h:
15+src/pe/H/pe_imports.def:
16+src/codegen/H/runtime/heap.h:
17+src/codegen/H/emit/bytes.h:
18+src/codegen/H/strings/string_alloc.h:
19+src/codegen/H/runtime/print_int.h:
20+src/codegen/H/runtime/errors.h:
21+src/app/H/target.h:

kiln/src/pe/D/pe_dynamic.dadded

+10−0
@@ -0,0 +1,10 @@
1+src/pe/O/pe_dynamic.o: src/pe/C/pe_dynamic.c src/pe/H/pe_writer.h \
2+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \
3+ src/codegen/H/emit/runtime_import_enum.h \
4+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def
5+src/pe/H/pe_writer.h:
6+src/codegen/H/emit/emit.h:
7+src/codegen/H/emit/runtime_layout.h:
8+src/codegen/H/emit/runtime_import_enum.h:
9+src/codegen/H/emit/runtime_exports.def:
10+src/pe/H/pe_imports.def:

kiln/src/pe/D/pe_writer.dadded

+12−0
@@ -0,0 +1,12 @@
1+src/pe/O/pe_writer.o: src/pe/C/pe_writer.c src/pe/H/pe_writer.h \
2+ src/codegen/H/emit/emit.h src/codegen/H/emit/runtime_layout.h \
3+ src/codegen/H/emit/runtime_import_enum.h \
4+ src/codegen/H/emit/runtime_exports.def src/pe/H/pe_imports.def \
5+ src/app/H/target.h
6+src/pe/H/pe_writer.h:
7+src/codegen/H/emit/emit.h:
8+src/codegen/H/emit/runtime_layout.h:
9+src/codegen/H/emit/runtime_import_enum.h:
10+src/codegen/H/emit/runtime_exports.def:
11+src/pe/H/pe_imports.def:
12+src/app/H/target.h:

kiln/src/pe/H/pe_dll_writer.hmodified

+3−3
@@ -1,7 +1,7 @@
11 #ifndef KILN_PE_DLL_WRITER_H
22 #define KILN_PE_DLL_WRITER_H
3-#include "codegen/runtime_import_enum.h"
4-#include "pe/pe_writer.h"
3+#include "codegen/H/emit/runtime_import_enum.h"
4+#include "pe/H/pe_writer.h"
55
66 // libkilnrt.dll: same fixed-base, no-ASLR, no-relocations philosophy as
77 // every other kiln output (a real DLL would normally get a .reloc
@@ -16,7 +16,7 @@
1616 // IMAGE_EXPORT_DIRECTORY (40 bytes) + 3 fixed-size arrays (sized only by
1717 // RUNTIME_IMPORT_COUNT_, never by name length) -- code starts right after,
1818 // so its address is a compile-time constant kiln_code_base() can use
19-// (see codegen/layout.c); the variable-length name strings go in the
19+// (see codegen/C/emit/layout.c); the variable-length name strings go in the
2020 // tail after code, same trick as pe_writer.h's hint/name table.
2121 #define KILN_PE_DLL_EXPORT_DIR_ADDR (KILN_PE_DLL_IMAGE_BASE + KILN_PE_DLL_SECTION_RVA)
2222 #define KILN_PE_DLL_EXPORT_DIR_SIZE 40u

kiln/src/pe/H/pe_writer.hmodified

+8−8
@@ -1,11 +1,11 @@
11 #ifndef KILN_PE_WRITER_H
22 #define KILN_PE_WRITER_H
3-#include "codegen/emit.h"
4-#include "codegen/runtime_layout.h"
5-#include "codegen/runtime_import_enum.h"
3+#include "codegen/H/emit/emit.h"
4+#include "codegen/H/emit/runtime_layout.h"
5+#include "codegen/H/emit/runtime_import_enum.h"
66
77 // Kiln generates a fixed, non-relocated PE32+ executable, same "always
8-// loaded at one known address" philosophy as elf/elf_writer.h's
8+// loaded at one known address" philosophy as elf/H/elf_writer.h's
99 // KILN_LOAD_BASE -- absolute addresses for string literals, closure code
1010 // addresses, and (this file's addition) imported-function IAT slots are
1111 // all known at compile time, no relocation table needed. 0x140000000 is
@@ -33,15 +33,15 @@
3333 #define KILN_PE_TRY_HANDLERS_ADDR (KILN_PE_TRY_DEPTH_ADDR + KILN_TRY_DEPTH_SIZE)
3434 // No argv slot: GetCommandLineA() can be called at any point, unlike
3535 // Linux's argv() which has to snapshot the kernel's original RSP before
36-// anything else touches it (see codegen/argv_builtin.c).
36+// anything else touches it (see codegen/C/io/argv_builtin.c).
3737 #define KILN_PE_GLOBALS_SIZE (8 + KILN_TRY_DEPTH_SIZE + KILN_TRY_HANDLERS_SIZE)
3838
3939 // Every kernel32.dll function kiln's Windows codegen calls -- single list
4040 // in pe_imports.def, shared by this enum and pe_writer.c's actual table
4141 // bytes, so the two can never silently drift out of sync.
4242 typedef enum {
4343 #define PE_IMPORT(name, str) PE_IMPORT_##name,
44-#include "pe/pe_imports.def"
44+#include "pe/H/pe_imports.def"
4545 #undef PE_IMPORT
4646 PE_IMPORT_COUNT_
4747 } PeImport;
@@ -65,13 +65,13 @@ typedef enum {
6565 (KILN_PE_SECTION_RVA + (KILN_PE_GLOBALS_SIZE + KILN_PE_IMPORT_DIR_SIZE + KILN_PE_ILT_SIZE + KILN_PE_IAT_SIZE))
6666
6767 // Absolute VA of `which`'s IAT slot -- what the loader overwrites with
68-// the resolved function pointer at load time. codegen/win_call.c loads
68+// the resolved function pointer at load time. codegen/C/platform/win_call.c loads
6969 // this address, dereferences it, and calls through the result (see that
7070 // file for why no RIP-relative addressing is needed here).
7171 uint64_t pe_import_addr(PeImport which);
7272
7373 // ---- --link=shared layout: a SECOND imported DLL (libkilnrt.dll,
74-// see pe/pe_dll_writer.h) alongside kernel32.dll. Kept as a fully
74+// see pe/H/pe_dll_writer.h) alongside kernel32.dll. Kept as a fully
7575 // parallel set of constants, never touched by the static-mode ones
7676 // above, so --link=static output stays byte-for-byte unchanged --
7777 // pe_writer.c picks one whole layout or the other based on link mode,

kiln/src/pe/O/.gitkeepadded

+0−0

No content changes. View the file on GitHub

kiln/tests/scripts/imports_circular_check.shmodified

+3−3
@@ -1,11 +1,11 @@
11 #!/usr/bin/env bash
2-# kiln/tests/imports_circular_check.sh -- not part of run_regression.sh's
2+# kiln/tests/scripts/imports_circular_check.sh -- not part of run_regression.sh's
33 # stdout-diff loop, since this test asserts a COMPILE FAILURE with
44 # specific message content, not a successful program's stdout.
55 set -uo pipefail
6-cd "$(dirname "$0")/.."
6+cd "$(dirname "$0")/../.."
77
8-OUT=$(../bin/kiln tests/fixtures/imports_circular_a.ash -o /tmp/imports_circular_a 2>&1)
8+OUT=$(../bin/kiln tests/cases/imports/fixtures/imports_circular_a.ash -o /tmp/imports_circular_a 2>&1)
99 STATUS=$?
1010
1111 if [[ $STATUS -eq 0 ]]; then

kiln/tests/scripts/imports_collision_check.shmodified

+3−3
@@ -1,12 +1,12 @@
11 #!/usr/bin/env bash
2-# kiln/tests/imports_collision_check.sh -- asserts BOTH resolved paths
2+# kiln/tests/scripts/imports_collision_check.sh -- asserts BOTH resolved paths
33 # appear in the error message, not just that a compile error fires (see
44 # the design spec's "Testing plan" section -- with no `as` clause to
55 # disambiguate, this message is the only diagnostic a user gets).
66 set -uo pipefail
7-cd "$(dirname "$0")/.."
7+cd "$(dirname "$0")/../.."
88
9-OUT=$(../bin/kiln tests/fixtures/imports_collision_main.ash -o /tmp/imports_collision_main 2>&1)
9+OUT=$(../bin/kiln tests/cases/imports/fixtures/imports_collision_main.ash -o /tmp/imports_collision_main 2>&1)
1010 STATUS=$?
1111
1212 if [[ $STATUS -eq 0 ]]; then

kiln/tests/scripts/run_regression.shmodified

+3−3
@@ -1,7 +1,7 @@
11 #!/usr/bin/env bash
2-# kiln/tests/run_regression.sh baseline|check
2+# kiln/tests/scripts/run_regression.sh baseline|check
33 set -uo pipefail
4-cd "$(dirname "$0")/.." # -> kiln/
4+cd "$(dirname "$0")/../.." # -> kiln/
55
66 MODE="${1:-check}"
77 if [[ "$MODE" != "baseline" && "$MODE" != "check" ]]; then
@@ -21,7 +21,7 @@ rm -f /tmp/kiln_file_test.txt
2121 make -s || { echo "build failed"; exit 1; }
2222
2323 fail=0
24-for f in tests/*.ash; do
24+for f in tests/cases/*/*.ash; do
2525 name=$(basename "$f" .ash)
2626 bin="$BINDIR/${name}.bin"
2727 out="$OUTDIR/${name}.out"