Rewrite compiler: IR-based architecture replacing bootstrap
Replace the bootstrap mixin-based compiler with a new IR-based pipeline:
Source → Lexer → Parser → Resolver → TypeChecker → IR Builder → Optimizer → Backend
New architecture (compiler/):
- semantics/: scope resolution, type system, type checker
- ir/: intermediate representation with stable node IDs
- optimizer/: DCE via call graph BFS, CSE, constant folding
- backend/bash/: bash code generation from IR
- backend/awk/: AWK code generation sharing same IR
- symbols/: symbol table with LSP-ready serialization
Key improvements:
- Explicit shell command detection (IRCall.is_shell_cmd)
- Namespace prefixing only in bash backend, not in resolver
- DCE reduced from 580-line fixed-point to ~40-line BFS
- CSE uses stable node_id instead of Python id()
- Shell commands in assignments use || true for set -e safety
- No local keyword in global scope (when/foreach)
- Coproc uses exec to prevent orphan child processes
All 400 tests pass. Verified with real-world unified-theme-switcher service.
Showing
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
bootstrap/codegen.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
bootstrap/dce.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
bootstrap/errors.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
bootstrap/lexer.py
deleted
100644 → 0
bootstrap/parser.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
bootstrap/stdlib.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
bootstrap/tokens.py
deleted
100644 → 0
compiler/__init__.py
0 → 100644
compiler/__main__.py
0 → 100644
compiler/backend/__init__.py
0 → 100644
This diff is collapsed.
Click to expand it.
compiler/backend/bash/awk.py
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
compiler/constants.py
0 → 100644
compiler/ir/__init__.py
0 → 100644
compiler/ir/builder.py
0 → 100644
This diff is collapsed.
Click to expand it.
compiler/ir/nodes.py
0 → 100644
This diff is collapsed.
Click to expand it.
compiler/lexer/__init__.py
0 → 100644
compiler/lexer/lexer.py
0 → 100644
This diff is collapsed.
Click to expand it.
compiler/lexer/tokens.py
0 → 100644
compiler/meson.build
0 → 100644
File moved
compiler/optimizer/cse.py
0 → 100644
compiler/optimizer/dce.py
0 → 100644
This diff is collapsed.
Click to expand it.
compiler/optimizer/fold.py
0 → 100644
This diff is collapsed.
Click to expand it.
compiler/semantics/scope.py
0 → 100644
compiler/semantics/types.py
0 → 100644
compiler/symbols/__init__.py
0 → 100644
compiler/symbols/table.py
0 → 100644
compiler/syntax/__init__.py
0 → 100644
compiler/syntax/nodes.py
0 → 100644
This diff is collapsed.
Click to expand it.
compiler/syntax/parser.py
0 → 100644
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to comment