aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGen.cc
AgeCommit message (Collapse)Author
2026-07-26refactor: keep pseudocode signatures, single call-marshalling path_ov4
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>
2026-07-26refactor: single builtin registry, retire keyword route for builtins_ov4
All 11 builtins now live in one static {Name, Arity, ReturnTypeName} table in CodeGen.cc: emitExpr checks arity against it (uniform "Error: X expects N args" diagnostics) and getExprTypeInfo reads return types from it, removing the duplicated hard-coded table. LENGTH/MID/RIGHT/LEFT/LCASE/UCASE lose their lexer tokens and ParseStringBuiltin; they parse as ordinary identifier calls exactly like ASC/CHR/IS_NUM/NUM_TO_STR/STR_TO_NUM already did. Behavior note: these six names are no longer reserved words. AGENTS docs updated for the new builtin story and the batch-1 error contract (exit codes, verifyModule, fixed descending FOR). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26refactor: batch 1 - correctness and error contract_ov4
- MID/RIGHT/LEFT integer args now coerced at call sites (RIGHT(s, n/2) no longer emits invalid IR); drop emitLeft's private conversion - FOR loop direction decided at run time via select on STEP sign; descending FOR works, STEP evaluated once per iteration - ArrayHandler: extract emitCheckedIndices/loadElement; index count is validated before emission, fixing a compiler-crash (vector OOB UB) on OUTPUT with too many indices - Error contract: Lexer/Parser/CodeGen track errors; all silent failure paths now print Error: diagnostics with line numbers; unterminated char literal no longer truncates the rest of the program; module is verified with verifyModule; driver exits non-zero on any error Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-03-27feat: generalize typed array support_ov4
2026-03-03Added all built-in functions_ov4
2026-02-02Added STRING_ov4
2026-02-02Added logical operators_ov4
2026-02-02Added REAL and BOOLEAN types, DIV and MOD operators_ov4
2026-01-30Added BYREF and BYVAL_ov4
2026-01-30Added FUNCTION and PROCEDURE_ov4
2026-01-30Changed INTEGER from i32 to i64ov-4
2026-01-30Added runtime check for array index and divisionov-4
2026-01-29Added arrayov-4
2026-01-29Added loop statements, FOR, WHILE and REPEATov-4
2026-01-29Added half way of IF statementov-4
2026-01-29Added binary operations +-*/ov-4
2026-01-29Added INPUT, OUTPUT and DECLAREov-4