plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
5eab4c3
— Peter John
2026-11-04T18:14:29+05:30
docs: phase 2b plan split
docs/plans/2026-11-04-compiler-cleanup-phase2b.md
CHANGED
|
@@ -33,8 +33,10 @@ flowchart LR
|
|
|
33
33
|
flowchart LR
|
|
34
34
|
T1[front-end entry]
|
|
35
35
|
T2[parseSource uses it]
|
|
36
|
-
T3[tests lowering]
|
|
36
|
+
T3[tests lowering core]
|
|
37
|
+
T9[codegen uses it]
|
|
38
|
+
T10[checker fusion options]
|
|
37
|
-
T4[compile
|
|
39
|
+
T4[compile entry]
|
|
38
40
|
T5[compile callers]
|
|
39
41
|
T6[visit helpers]
|
|
40
42
|
T7[Paren removal]
|
|
@@ -42,7 +44,9 @@ flowchart LR
|
|
|
42
44
|
%% taskgraph
|
|
43
45
|
T1 --> T2
|
|
44
46
|
T1 --> T3
|
|
45
|
-
T3 -->
|
|
47
|
+
T3 --> T9
|
|
48
|
+
T9 --> T4
|
|
49
|
+
T10 --> T4
|
|
46
50
|
T4 --> T5
|
|
47
51
|
T2 --> T7
|
|
48
52
|
T5 --> T7
|
|
@@ -77,34 +81,57 @@ e.g. frontEnd on a program using an unknown union member -> Err containing the o
|
|
|
77
81
|
**Review Focus:** `single_file_equals_loader`: for every plum-examples file without imports, `parseSource` gives the same AST as `loadAndMerge` (add this as a test in plum-core/tests/loader_test.rs); errors stay discarded in parseSource as today (callers that need them call frontEnd).
|
|
78
82
|
**Test code:** all plum-core, plum-checker, plum-lsp test binaries pass; any test whose expectation relied on an unlowered AST switches to `parseSourceRaw` (list them).
|
|
79
83
|
|
|
80
|
-
### T3 tests lowering
|
|
84
|
+
### T3 tests lowering in plum-core · Complexity 4 · Est. context 40k
|
|
81
|
-
**Owns:** plum-core/src/tests_lower.rs, plum-core/src/lib.rs, plum-
|
|
85
|
+
**Owns:** plum-core/src/tests_lower.rs, plum-core/src/lib.rs, plum-core/tests/tests_lower_test.rs
|
|
82
86
|
**Components:** 1
|
|
83
|
-
**LOC owned:**
|
|
87
|
+
**LOC owned:** 150
|
|
84
|
-
**Tests:**
|
|
88
|
+
**Tests:** fast
|
|
85
89
|
**Model:** sonnet
|
|
86
90
|
**Consumes:** lower::frontEnd(source: &mut Source) -> Result<(), String> (T1)
|
|
87
|
-
**Produces:** tests_lower::lowerTests(source: &Source) -> TestProgram
|
|
91
|
+
**Produces:** tests_lower::lowerTests(source: &Source) -> TestProgram · tests_lower::TestProgram { source: Source, names: Vec<String> }
|
|
88
92
|
e.g. lowerTests(src with `test "a" = expect 1 == 1`) -> TestProgram { names: ["a"], source with one generated fn }
|
|
89
|
-
**Review Focus:** `assert_names_per_compile`: generated temp names start at 0 for each call (no process-global
|
|
90
|
-
**Test code:** tests_lower_test.rs
|
|
91
|
-
**Steps:**
|
|
93
|
+
**Review Focus:** `assert_names_per_compile`: generated temp names start at 0 for each call (no process-global counter).
|
|
94
|
+
**Test code:** tests_lower_test.rs: the e.g. line; two calls give identical output; an assert failure message matches codegen's current text.
|
|
95
|
+
**Steps:** copy desugarTestsToFns, desugarAssertStmt, assertFailureMessage, TestProgram from codegen lib.rs ≈1812-2076 (read only; T9 deletes the codegen copy), with a per-call counter.
|
|
96
|
+
|
|
97
|
+
### T9 codegen uses core tests lowering · Complexity 2 · Est. context 35k
|
|
98
|
+
**Owns:** plum-wasm-codegen/src/lib.rs
|
|
99
|
+
**Components:** 1
|
|
100
|
+
**LOC owned:** 30
|
|
101
|
+
**Tests:** slow
|
|
102
|
+
**Model:** sonnet
|
|
103
|
+
**Consumes:** tests_lower::lowerTests(source: &Source) -> TestProgram (T3)
|
|
104
|
+
**Produces:** none
|
|
105
|
+
**Test code:** cli assert_once_test/test_scope_test pass; `plum test plum-std plum-examples` 678 passed, same output text; hashes identical.
|
|
106
|
+
**Steps:** delete codegen's desugar copies; `desugarTests` and `TestProgram` become re-exports of `plum_core::tests_lower` (T4 removes them later).
|
|
92
107
|
|
|
93
108
|
## Package B: one compile call
|
|
94
109
|
**Probe entry:** run=bash scripts/wasm-hashes.sh
|
|
95
110
|
|
|
96
|
-
###
|
|
111
|
+
### T10 checker takes fusion options · Complexity 3 · Est. context 40k
|
|
97
|
-
**Owns:** plum-
|
|
112
|
+
**Owns:** plum-checker/src/lib.rs
|
|
98
|
-
**Components:**
|
|
113
|
+
**Components:** 1
|
|
99
|
-
**LOC owned:**
|
|
114
|
+
**LOC owned:** 50
|
|
115
|
+
**Tests:** slow
|
|
116
|
+
**Model:** sonnet
|
|
117
|
+
**Produces:** plum_checker::typedSourceWith(source: &Source, fusion: FusionOptions) -> CheckResult<TypedInfo>
|
|
118
|
+
e.g. typedSourceWith(s, FusionOptions::default()) -> same TypedInfo as typedSource(s)
|
|
119
|
+
e.g. typedSourceWith(s, FusionOptions{enabled: false, ..}) -> no fused fns in the lowered program
|
|
120
|
+
**Review Focus:** `options_threaded`: fusion options are passed down as a parameter; the `FUSION_OPTIONS` thread-local stays only as the default `typedSource` reads (T7 deletes it with its setters).
|
|
121
|
+
**Test code:** checker test binaries (incl. fusion_pipeline_test) pass; hashes identical.
|
|
122
|
+
|
|
123
|
+
### T4 one compile entry · Complexity 4 · Est. context 45k
|
|
124
|
+
**Owns:** plum-wasm-codegen/src/lib.rs
|
|
125
|
+
**Components:** 1
|
|
126
|
+
**LOC owned:** 80
|
|
100
127
|
**Tests:** slow
|
|
101
128
|
**Model:** sonnet
|
|
102
|
-
**
|
|
129
|
+
**Consumes:** plum_checker::typedSourceWith(source: &Source, fusion: FusionOptions) -> CheckResult<TypedInfo> (T10) · tests_lower::lowerTests(source: &Source) -> TestProgram (T3)
|
|
130
|
+
**Produces:** plum_wasm_codegen::compile(source: &Source, opts: &CompileOptions) -> Result<Output, String> · CompileOptions { tests: bool, fusion: FusionOptions } · Output { wasm: Vec<u8>, fn_keys: Vec<String>, test_names: Vec<String> }
|
|
103
131
|
e.g. compile(src, &CompileOptions::default()) -> Ok(Output{wasm, test_names: [], ..}) same bytes as compileSource(src)
|
|
104
132
|
e.g. compile(src_with_tests, &CompileOptions{tests: true, ..}) -> test_names ["a"]
|
|
105
|
-
**
|
|
106
|
-
**
|
|
107
|
-
**Steps:** keep `compileSource(source)` as a one-line wrapper over `compile`; delete compileTyped, compileSourceWithFunctions, compileTestSource, compileTestTyped and the desugarTests re-export once T5 moves their callers (mark them `#[deprecated]` thin wrappers in this task so callers still build).
|
|
133
|
+
**Test code:** unit tests for the e.g. lines in codegen lib.rs `#[cfg(test)]`; codegen test binaries pass; hashes identical.
|
|
134
|
+
**Steps:** keep `compileSource(source)` as a one-line wrapper over `compile`; mark compileTyped, compileSourceWithFunctions, compileTestSource, compileTestTyped and the desugarTests/TestProgram re-exports `#[deprecated]` thin wrappers (T5 moves callers, T7 deletes them).
|
|
108
135
|
|
|
109
136
|
### T5 compile callers · Complexity 3 · Est. context 40k
|
|
110
137
|
**Owns:** plum-cli/src/main.rs, plum-wasm-codegen/tests/codegen_tests.rs, plum-checker/tests/fusion_pipeline_test.rs, plum-game/tests/host_test.rs
|
|
@@ -112,10 +139,10 @@ e.g. compile(src_with_tests, &CompileOptions{tests: true, ..}) -> test_names ["a
|
|
|
112
139
|
**LOC owned:** 60
|
|
113
140
|
**Tests:** slow
|
|
114
141
|
**Model:** sonnet
|
|
115
|
-
**Consumes:** plum_wasm_codegen::compile(source: &Source, opts: &CompileOptions) -> Result<Output, String> (T4) · plum_checker::typedSourceWith(source: &Source, fusion: FusionOptions) -> CheckResult<TypedInfo> (
|
|
142
|
+
**Consumes:** plum_wasm_codegen::compile(source: &Source, opts: &CompileOptions) -> Result<Output, String> (T4) · plum_checker::typedSourceWith(source: &Source, fusion: FusionOptions) -> CheckResult<TypedInfo> (T10)
|
|
116
143
|
**Produces:** none
|
|
117
144
|
**Review Focus:** `cli_flags`: `--no-fusion` and `--explain-fusion` still work (run `plum run` on an example with each and compare to master's output).
|
|
118
|
-
**Test code:** cli test binaries, codegen_tests, fusion_pipeline_test, plum-game host_test pass; no `#[deprecated]` warnings left; then
|
|
145
|
+
**Test code:** cli test binaries, codegen_tests, fusion_pipeline_test, plum-game host_test pass; no `#[deprecated]` warnings left; then T7 then deletes the deprecated wrappers and the FUSION_OPTIONS thread-local with its setters.
|
|
119
146
|
|
|
120
147
|
## Package C: tidy and remove Paren
|
|
121
148
|
**Probe entry:** run=bash scripts/wasm-hashes.sh
|