diff options
| author | _ov4 <ov4@ov4.org> | 2026-07-26 12:07:51 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-07-26 12:07:51 +0000 |
| commit | 4a25b279d8f6c662fa8152cfe42e038d1ea06901 (patch) | |
| tree | 58223f2db133a10827e0a6d0c18c33f04bbc2527 /AGENTS/CONVENTIONS.md | |
| parent | efc86b5c7625cf4c7074319f42f68807a25bde9d (diff) | |
refactor: keep pseudocode signatures, single call-marshalling path
emitPrototype now records each FUNCTION/PROCEDURE's pseudocode signature
(FuncSig: return type + per-param type/BYREF flag). CodeGen::
marshalCallArgs replaces the two verbatim-duplicated marshalling blocks
and dispatches on the declared signature instead of inferring BYREF from
pointer-typed LLVM params: BYVAL STRING params now receive the string
data pointer (no more runtime garbage), and BYVAL args are coerced to
the declared type (INTEGER->REAL args no longer emit invalid IR).
Top-level prototypes are pre-registered in compile(), so calls may
precede definitions; GenerateCall no longer fabricates i64 externs for
unknown names - an unregistered callee is a compile error. OUTPUT
reports an error when it cannot infer the expression type instead of
printing with the INTEGER format.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'AGENTS/CONVENTIONS.md')
| -rw-r--r-- | AGENTS/CONVENTIONS.md | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/AGENTS/CONVENTIONS.md b/AGENTS/CONVENTIONS.md index c05734f..e09b6ee 100644 --- a/AGENTS/CONVENTIONS.md +++ b/AGENTS/CONVENTIONS.md @@ -58,16 +58,15 @@ non-zero when any flag is set. The parser still drops a failed statement, skips token, and continues — later statements can be swallowed during recovery, but the failure is always diagnosed and reflected in the exit code. -**BYREF is a pointer-typed parameter, inferred structurally at call sites.** -`FunctionGen` emits pointer params for BYREF; call sites (in CodeGen, duplicated for -call-expr and call-stmt) treat *any* pointer-typed callee param as BYREF and require the -argument to be a bare variable whose alloca is passed. The callee side, however, binds -by the *declared* flag. Since STRING itself lowers to `ptr`, the two sides disagree for -STRING: the caller always passes the alloca, but a declared-BYVAL STRING param (the -default) copies that alloca *address* and treats it as the string data pointer — reading -garbage at runtime. Only declared-BYREF STRING parameters work, and STRING arguments can -never be literals/expressions. Function names get no mangling — a pseudocode -`FUNCTION printf` collides with libc. +**Calls dispatch on the declared signature.** `FunctionGen::emitPrototype` records every +function's pseudocode signature (`FuncSig`: return type name + per-param type name and +BYREF flag); `CodeGen::marshalCallArgs` — the single call-marshalling path for both +call-expr and call-stmt — requires BYREF arguments to be bare variables (their alloca is +passed) and coerces BYVAL arguments to the declared parameter type. STRING works on both +sides in both modes. Top-level prototypes are pre-registered before statement emission, +so call-before-definition is fine; a call with no registered signature is a compile +error. Function names get no mangling — a pseudocode `FUNCTION printf` collides with +libc. **Builtins are plain identifiers backed by one table.** All 11 builtins (LENGTH/MID/RIGHT/LEFT/LCASE/UCASE/ASC/CHR/IS_NUM/NUM_TO_STR/STR_TO_NUM) parse as |
