v0.9.4 — PE Infrastructure, Self-Application & Reference Semantics
PE Infrastructure
Three new LOGOS source programs power the Futamura projection pipeline:
- PE BTI source (
pe_bti_source.logos, 1215 LOC) — a binding-time improved partial evaluator. Renames internal predicates (isStatic→checkStatic,specResults→memoCache) and uses B-suffixed entry points (peExprB,peBlockB) to avoid name collisions during self-application. This is what Projection 2 produces as a compiler.
- PE mini source (
pe_mini_source.logos, 785 LOC) — a clean-room minimal partial evaluator with its ownPEMiniStatetype (nospecResults/onStackfields). Uses M-suffixed entry points (peExprM,peBlockM). This is what Projection 3 produces as a compiler generator.
- Decompile source (
decompile_source.logos, 645 LOC) — a source-level decompiler that converts PE output back to readable LOGOS.
Genuine Self-Application
The partial evaluator can now specialize itself. Key results verified by tests:
PE(pe_source, nano-PE(CInt(42)))produces"42"— The Trick demonstratedPE(pe_source, pe_mini(5+3))produces"8"— a real PE specializing a real PE- Projection 2 with dynamic target: PE produces residual code containing the dynamic target and no source PE function definitions
Critical fixes that enabled this: CMapGet folding for CNewVariant/CNew expressions, staticEnv seeding in all-static CCall, and isLiteral → isStaticValue promotion in CLet/CSet.
Reference Semantics
Collections now use Rc-based reference semantics throughout:
LogosSeq<T>wrapsRc<RefCell<Vec<T>>>—.clone()is O(1) shared reference,.deep_clone()copies dataLogosMap<K,V>wrapsRc<RefCell<FxHashMap<K,V>>>— same semantics- Interior mutability via
RefCell::borrow_mut()— methods take&self copy ofin LOGOS source triggers.deep_clone()for value semantics where needed
PE Engine Improvements
- specResults memoization activated with deep-cloned body results
- makeKey collision fix —
exprToKeyPartcovers allCExprvariants with structural keys - MSG wiring —
internerthreaded through drive/generalize,msg()activated on whistle - BTA SCC wiring —
analyze_with_sccs()called in optimize paths - isStatic expansion —
CNew,CRange,CCopyrecognized as static - Partially-static data —
CLenfoldsCTuple,exprToValhandlesCNewVariant/CNew - extractReturn sentinel — changed fallback from
CInt(0)toCVar("__no_return__")to prevent silent miscompilation
Testing
~5,000 new Futamura projection tests across Sprints A–J, plus 191 lines of reference semantics E2E tests. All 4,513 tests pass with zero regressions.