| Age | Commit message (Collapse) | Author |
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
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>
|
|
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>
|
|
Reuse historical runtime messages and source-line reporting for arithmetic,
array, enum, pointer and file checks while preserving anonymous exceptions.
Update the manuals and subsystem guidance to describe diagnostic output.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
|
Add TRY/CATCH/ENDTRY and anonymous THROW statements. Use LLVM exception
handling and the C++ ABI to propagate exceptions across function calls,
clean up catch state, and handle uncaught exceptions at the program boundary.
Register exception runtime symbols for the statically linked embedded runner.
Verify runtime checks, nested catches, returns, loops, and invalid syntax
with smoke programs; exercise unwinding with MCJIT, lli, and native binaries.
BREAKING CHANGE: Runtime check failures now throw anonymous exceptions and
print only a generic message when uncaught. Native binaries require linking
the C++ runtime.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
|
- Parameter syntax lands end-to-end: ARRAY OF T (rank 1, bounds travel
with the argument) and ARRAY[l:u,...] OF T (any rank, literal bounds as
a checked contract). Element type and rank must match exactly.
- Flattened ABI: each rank-R array parameter becomes a data pointer plus
kBoundArgsPerDim i64 bounds per dimension. The callee rebuilds
ArrayMetadata from those bounds (ArrayHandler::bindArrayParameter via a
binder callback injected by CodeGen, so FunctionGen stays ignorant of
the array subsystem); the checked-indexing pipeline is reused unchanged.
- BYVAL (the CIE default) copies the whole buffer at callee entry
(malloc+memcpy, never freed — consistent with the string policy) so
callee writes stay invisible; BYREF binds the caller's buffer.
- Bounded-parameter contract: compile-time comparison when the caller's
bounds are constants, else a runtime [Fatal] check
(RuntimeCheck::emitArrayArgBoundsCheck).
- marshalCallArgs gains the array branch and a call-site line number
(CallStmtAST now carries one); whole-array-to-scalar keeps a clear
error, FUNCTION RETURNS ARRAY is a dedicated parse error.
- Verified: BYREF fill/sort-style mutation, BYVAL copy invisibility,
2-D bounded params, ARRAY OF <record> with field writes through the
parameter, bounds-contract mismatches at compile time and run time.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
- TypeSystem: TypeKinds Enum/Record/Pointer with per-kind payloads and
checked accessors; two-pass registration (names first, then definitions
in source order) so pointer TYPEs may forward-reference; enum-constant
table owned by TypeSystem so constants stay visible inside function
bodies across the Symbols save/clear/restore. Dead surface removed
(Custom kind, Printable/Builtin/ReferenceLike, ElementSize, hasType,
CodeGen::getNamedValue/getLLVMType).
- Enums are i64 with 0-based ordinals (constexpr kEnumOrdinalBase); all
type identity is by NAME. New emitCoercedExpr is the single admission
gate, replacing raw coercion at assignments, array stores, BYVAL args,
RETURN, IF/WHILE/REPEAT/FOR operands, file operands and builtin args;
coerceValueToType now hard-errors if a user-kind target reaches it.
- Binary ops with user-kind operands are intercepted ahead of
ArithmeticHandler ('&'-intercept precedent): same-enum comparisons,
enum +/- INTEGER (with a runtime range check, [Fatal] on overflow, the
only site that can manufacture an invalid ordinal), same-name pointer
=/<>; everything else is a compile error naming the operator.
- OUTPUT is an exhaustive switch over TypeKind (enum prints its ordinal;
record/pointer are compile errors, also covering whole-array OUTPUT);
INPUT's silent %lld fallback for unknown kinds is now an explicit error.
- Enum value names are globally reserved: collisions with DECLARE,
array names, parameters and function names are compile errors.
- RuntimeCheck: emitEnumRangeCheck + emitNullDerefCheck (used by the
pointer phase) following the emitIndexCheck recipe.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
(OPENFILE/READFILE/WRITEFILE/CLOSEFILE/EOF)
Front end: OPENFILE/READFILE/WRITEFILE/CLOSEFILE plus reserved mode
keywords READ/WRITE/APPEND (RANDOM reserved with a dedicated
not-implemented error); statement nodes in new FileAST.h, parsing in new
ParserFile.cc; EOF joins the Builtins table as the 12th builtin and
CallExprAST now carries a line number for its runtime diagnostics.
Runtime: new FileHandler (StringHandler-shaped leaf) lazily synthesizes
internal __cps_file_* helper functions and a 16-slot open-file table
keyed by filename content (strcmp — STRING '=' is pointer identity).
EOF is an fgetc/ungetc peek; READFILE grows a malloc/realloc line buffer
and strips a trailing CR; fopen uses text modes so mingw-w64 line
translation works. File-free programs get byte-identical IR. All misuse
(not open, wrong mode, reopen, fopen failure, read past EOF, table full)
dies with the existing "[Fatal] line N:" pattern via a new
RuntimeCheck::emitErrorAndExit overload taking runtime printf args.
Also fixes a pre-existing ArithmeticHandler hole surfaced by adversarial
review: mixed-width integer operands (i1 BOOLEAN / i8 CHAR vs i64) now
widen via ZExt instead of emitting invalid IR, and remaining type
mismatches get a clean diagnostic; -EOF(f) and -IS_NUM(x) compile.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
|