diff options
| author | _ov4 <ov4@ov4.org> | 2026-07-26 12:12:59 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-07-26 12:12:59 +0000 |
| commit | b9b7f048b0874df0f034f6b1e15e1a4ee2131475 (patch) | |
| tree | ccbe2f45205c6e05ac536e6ac73e1d5830769787 /AGENTS/CONVENTIONS.md | |
| parent | fdef2814d0d7e65573d1b666ae9bc561fa35a9f9 (diff) | |
refactor: centralize libc declarations, move '&' concat into StringHandler
CodeGen declares its own MallocFunc in SetupExternalFunctions and uses
it for char->STRING coercion and INPUT STRING buffers, removing two bare
getFunction("malloc") calls that null-deref'd if no handler happened to
declare malloc first. The CHR branch reuses the char->STRING coercion
path instead of a second hand-rolled heap wrapper.
String concatenation moves from ArithmeticHandler (which re-declared
four externs per '&' and was the LLVM 19 build-pin root cause) to
StringHandler::emitConcat; ArithmeticHandler no longer touches the
Module. Dead FreeFunc declarations removed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'AGENTS/CONVENTIONS.md')
| -rw-r--r-- | AGENTS/CONVENTIONS.md | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/AGENTS/CONVENTIONS.md b/AGENTS/CONVENTIONS.md index 753be57..cd1adfc 100644 --- a/AGENTS/CONVENTIONS.md +++ b/AGENTS/CONVENTIONS.md @@ -33,8 +33,12 @@ pseudocode types *backwards* from LLVM types (`getExprTypeInfo`, `ArithmeticHand **Strings are malloc'd and never freed — by design.** Every string-producing operation (`&`, MID/LEFT/RIGHT/LCASE/UCASE, NUM_TO_STR, CHR, CHAR/number→STRING coercion) mallocs a fresh buffer; string literals and BOOLEAN→STRING coercion instead return pointers to -shared module globals, so a STRING value may alias a global. `free` is declared but has -zero call sites. Don't "fix" leaks piecemeal; it's a global design decision. +shared module globals, so a STRING value may alias a global. `free` is never declared or +called. Don't "fix" leaks piecemeal; it's a global design decision. All heap-string +operations (including `&` concatenation, `StringHandler::emitConcat`) live in +`StringHandler`; `CodeGen` also keeps its own `MallocFunc` for the char→STRING coercion +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, |
