From 1749b2b4a3e55db7c9bed95376f99b7f07932b49 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sun, 26 Jul 2026 12:15:33 +0000 Subject: refactor: drop per-type micro handlers and the parallel NamedValues map Integer/Real/Boolean/CharHandler carried only five one-line LLVM API wrappers (now inlined at their call sites in CodeGen.cc) plus dead emitDeclare methods that violated the documented two-table lock-step invariant. StringHandler::emitDeclare (also dead) and its NamedValues reference go too. With the dead writers gone, NamedValues held no information not already in Symbols[].Storage, so the parallel map is removed: getNamedValue reads Symbols, ArrayHandler/FunctionGen take one table, and function bodies save/restore a single map. Behavior unchanged. Co-Authored-By: Claude Fable 5 --- AGENTS/CONVENTIONS.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'AGENTS') diff --git a/AGENTS/CONVENTIONS.md b/AGENTS/CONVENTIONS.md index cd1adfc..6d6bb81 100644 --- a/AGENTS/CONVENTIONS.md +++ b/AGENTS/CONVENTIONS.md @@ -40,14 +40,12 @@ operations (including `&` concatenation, `StringHandler::emitConcat`) live in and INPUT STRING buffers — declared in `SetupExternalFunctions`, never fetched with a bare `getFunction("malloc")`. -**One flat symbol namespace.** Two parallel maps in CodeGen — `NamedValues` -(name → storage `Value*`) and `Symbols` (name → `SymbolInfo{Storage, TypeName, -IsArray}`) — must always be updated in lock-step: via `registerSymbol()`, or directly -but both together as `FunctionGen::createArgumentAllocas` does for parameters. (The -per-type handlers' `emitDeclare` methods set `NamedValues` alone — that is dead code; -don't imitate it.) There is no scope stack. `FunctionGen` saves/clears/restores both -maps around a function body, but `ArrayHandler::ArrayTable` is *not* scoped (see -`PITFALLS.md`). +**One flat symbol namespace, one table.** `Symbols` (name → `SymbolInfo{Storage, +TypeName, IsArray}`) in CodeGen is the only symbol table; register through +`registerSymbol()` (or directly, as `FunctionGen::createArgumentAllocas` does for +parameters) and read storage through `getNamedValue()`/`getSymbolInfo()`. There is no +scope stack. `FunctionGen` saves/clears/restores the table around a function body, but +`ArrayHandler::ArrayTable` is *not* scoped (see `PITFALLS.md`). **Dispatch is by `dynamic_cast` chain, not virtual methods.** `CodeGen::emitStmt` and `emitExpr` walk a linear if-chain of casts. **A statement type missing from the chain is -- cgit v1.3.1-4-g156e