aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2026-10-22refactor(codegen): share record field default construction_ov4
copyClassValue, emitConstruct and emitStringFromCString each walked the record fields and default-constructed those that need it. Move the loop into a private emitFieldDefaults helper; each caller passes the same line as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(codegen): share file keyword filename operand emission_ov4
EOF, OPENFILE, READFILE and CLOSEFILE each rejected a whole-array filename and then emitted it as a C string. Route them through a private emitFileNameOperand helper; diagnostics are unchanged. WRITEFILE keeps its own combined check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(codegen): share array metadata registration_ov4
DECLARE and array-parameter binding both computed the dimension multipliers, filled the same ArrayMetadata and stored it in ArrayTable. Move that into a private ArrayHandler::defineMetadata helper that also yields the total element count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(codegen): extract FunctionGen prototype validation_ov4
Move the copy-constructor, operator, MAIN OVERLOAD and reserved, builtin, enum and type name checks at the start of emitPrototype into a private validatePrototype helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(codegen): narrow FunctionGen's call and type helpers_ov4
Make getLLVMType and the link-name emitCall overload private, inline the single-use GenerateCall helper into that overload, and drop the argument setName calls in createArgumentAllocas that repeat the names emitPrototype already assigned. The undefined-function diagnostic stays: a link name can be shadowed by another module global (e.g. FUNCTION stderr). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(codegen): remove dead parameters, fields and branches_ov4
Drop the never-read StackObject::IsCopy flag and registerStackObject parameter, the unused NewExprAST forward declaration, the unused Ret parameter of FunctionGen::emitReturn and CG parameter of ArrayHandler::loadElement, unused <cstdio> includes, and the coerceValueToType early returns already covered by the exact LLVM type check (builtin kinds always map to double/i64/i1/i8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(lexer): look up keywords in a static table_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(lexer): drop redundant single-character token branches_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(driver): color diagnostics like gcc with -fdiagnostics-color_ov4
Add -fdiagnostics-color[=auto|always|never] and -fno-diagnostics-color. The default auto mode colors only a terminal stderr (TERM set and not dumb on Unix; a console that accepts VT sequences on Windows), so test harnesses, the desktop bundle and other pipes stay plain. Every diagnostic label now comes from cps::diagnosticPrefix, which emits gcc's default GCC_COLORS bytes: bold locus, bold red error/fatal error, bold magenta warning, bold cyan note. compilation terminated., runtime messages of the compiled program and lld output are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(diagnostics): print source diagnostics in gcc file:line: layout_ov4
Lexer, parser, driver and codegen diagnostics now read "<path>:<line>: error: <message>" instead of "error: <message> at line N in <path>". The path is always printed as given on the command line. Call sites pass the bare message to cps::sourceError/sourceWarning, which carry printf format checking; reportError routes through the same helper. The suite iii harness parses the new layout and matches the reason against the message only. iii/template-class-pack-field passed only because its reason regex matched the case path, so it is now case-insensitive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(codegen): instantiate class templates_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(codegen): add variadic function templates_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(codegen): support explicit template arguments_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(codegen): instantiate function templates by deduction_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(parser): parse TEMPLATE declarations, template ids and parameter packs_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20fix(strings): preserve enclosing class lifetimes during assignment_ov4
Copy owned string fields without reconstructing or destroying their containing class, and retain rvalue ownership transfers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20refactor(strings): replace compiler builtins with the STRING library_ov4
Construct literals as STRING values and route string operations through ordinary library functions and operators. Preserve value ownership in records, arrays, constants and file I/O. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20feat(lexer): add C_STRING literal suffix_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(lib): add experimental _EXP_STRING backed by std::string_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(operators): allow member assignment operator overloads_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(classes): add copy constructors and statement-scoped temporaries_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(driver): add #LIB directive hiding library lines in runtime errors_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(lexer): accept identifiers starting with an underscore_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(lexer): support C++ escape sequences in literals_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(operators): add member and unary overloads with explicit calls_ov4
Select member and global candidates together, enforce private access, and reuse argument marshalling. Materialize temporary receivers for chaining and register them for the existing object cleanup mechanism. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(operators): support global binary operator overloads_ov4
Resolve exact operand types and preserve declared operator return types. Reject implicit STRING to BOOLEAN conversion at typed expression boundaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(codegen): allow identical EXTERN redeclarations across files_ov4
Repeated EXTERN declarations with the same signature share one C symbol, as C declarations do; conflicting signatures are errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(codegen): declare and call EXTERN C functions_ov4
Variadic arguments must be C values and receive C default argument promotions; narrow integer parameters carry sign/zero extension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(parser): parse EXTERN "C" declarations and INCLUDE_OBJ_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): overload methods and NEW constructors_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(codegen): overload global functions and procedures_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(parser): parse OVERLOAD prefix on FUNCTION and PROCEDURE_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17refactor(runtime): write runtime diagnostics with fprintf(stderr)_ov4
Replace snprintf+write(2) with a single fprintf call on the platform's stderr: the C library's stderr / __stderrp, or __acrt_iob_func(2) on Windows, which the embedded runner binds to the host shim. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17feat(runtime): write runtime diagnostics to stderr_ov4
Runtime check messages and the unhandled-exception message were printed to stdout by the generated program, so `cpsc x.cps -r >out.txt` captured them. They are now formatted with snprintf and written with write(2). Test expectations and docs are updated accordingly. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17feat(codegen): FUNCTION MAIN entry point_ov4
Invoke the internal entry function through the generated exception handler and truncate its INTEGER result to the process exit status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(codegen): GLOBAL variables as LLVM globals_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(driver): compile multiple source files with INCLUDE visibility_ov4
Reject builds without an entry program and duplicate cross-file definitions. Preserve source order for each unit's own constants and import visible exports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(parser): parse INCLUDE and GLOBAL blocks_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17refactor(diag): file-qualified diagnostic locations_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): destroy stack objects during exception unwinding_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): destroy stack objects at scope exit_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): destroy and release heap objects with DELETE_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): parse DELETE destructor methods and DELETE statement_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17fix(classes): preserve method-only heap objects and document NEW_ov4
Allocate at least one byte for method-only classes so their heap addresses remain usable through pointers. Complete constructor diagnostics, field-order and exception coverage, document construction and rebinding, and highlight NEW. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): allocate objects with NEW and rebind named class variables_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): construct declared objects and nested fields and arrays_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): support explicit NEW constructor method calls_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17fix(parser): accept optional DO after WHILE condition_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): warn when method declarations shadow fields_ov4
Retain parameter source lines for warnings and preserve field access prefix validation when distinguishing fields from methods. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17feat(classes): support ordinary member methods and this references_ov4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>