diff options
Diffstat (limited to 'AGENTS/CONVENTIONS')
| -rw-r--r-- | AGENTS/CONVENTIONS/STRINGS.md | 51 | ||||
| -rw-r--r-- | AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md | 4 | ||||
| -rw-r--r-- | AGENTS/CONVENTIONS/TEMPLATES_AND_OPERATORS.md | 9 | ||||
| -rw-r--r-- | AGENTS/CONVENTIONS/TYPES.md | 3 |
4 files changed, 38 insertions, 29 deletions
diff --git a/AGENTS/CONVENTIONS/STRINGS.md b/AGENTS/CONVENTIONS/STRINGS.md index d07c217..d036fb4 100644 --- a/AGENTS/CONVENTIONS/STRINGS.md +++ b/AGENTS/CONVENTIONS/STRINGS.md @@ -2,29 +2,34 @@ Part of [Load-bearing conventions](../CONVENTIONS.md). -**STRING values use the class machinery.** `string.cps` owns a std::string through an -internal handle. Ordinary literals construct STRING through NEW(C_STRING); suffixed -`"text"C` literals produce C_STRING directly. Ordinary literals retain legacy NUL -truncation. `StringValueGen.cc` bridges construction, C_STR access and file operands; -INPUT calls READ_INPUT. String functions and all concatenation/comparison operators -are ordinary library definitions, with exact overload selection. Comparisons use -case-sensitive byte ordering. A missing STRING class or required bridge method is a -compile error. +**Literals are raw C_STRING values.** Both ordinary and C-suffixed double-quoted +literals emit global text pointers; CONSTANT keeps the same raw type and read-only +binding. Text operations retain legacy NUL truncation. Single quotes remain CHAR. +An exact C_STRING overload wins over conversion to STRING. -**CHAR and STRING convert implicitly.** `emitCoercedExpr` turns a CHAR into a -one-character STRING (`emitStringFromChar`, STRING.NEW(1, ch)) and a STRING into a CHAR -(`emitCharFromString`, via the `_LENGTH()` and `C_STR()` bridge methods), so assignment, -parameter passing and RETURN need no special cases; a length other than 1 is a runtime -error. `resolveOperator` and `resolveCall` fall back to the STRING overload when an -exact match is missing and a CHAR is involved (`'a' & 'b'`, `"a" = 'a'`); two CHAR -operands still compare as CHARs, and CASE converts the CHAR side itself. A converted -value is a fresh temporary, so `emitAssignment` copies its source (CopySource) only when -the source type equals the target type. CHAR with INTEGER or BOOLEAN never converts. +**Automatic construction is opt-in.** `string.cps` owns a std::string through an +internal handle and declares IMPLICIT NEW(C_STRING) and IMPLICIT NEW(CHAR). +`TypeCheckGen.cc` shares direct constructor lookup, conversion ranking and emission +with calls, operators and captured CASE values. Never automatically invoke an +unmarked constructor, including in a replacement STRING class under -no-std. +Explicit casts may still use unmarked NEW(C_STRING). + +**CHAR compatibility remains.** STRING -> CHAR uses `_LENGTH()` and `C_STR()` and +checks length 1 at runtime. C_STRING -> CHAR first uses the marked STRING constructor; +this compatibility bridge ranks below a direct STRING parameter, preserving string +function selection. Two CHARs compare directly. No path may chain two IMPLICIT NEWs. + +**I/O bridges retain STRING behavior.** OUTPUT and file operands convert C_STRING +through its marked STRING constructor, then use C_STR. INPUT calls READ_INPUT. +String functions, concatenation and comparisons are ordinary library definitions; +comparisons use case-sensitive byte ordering. Missing classes or methods diagnose. **Ownership follows value copies.** STRING constructors/assignment prevent shared -handles. Records and BYVAL arrays containing STRING recursively copy their -string-bearing fields/elements; RETURN and temporary cleanup preserve ownership. -C_STRING casts borrow a STRING buffer or construct an owning STRING copy in the other -direction. FileHandler owns copied open-file names and frees them on close; READFILE -buffers are copied into STRING and released. Explicit memory-library allocations remain -separate from these internal objects. +handles. Records and BYVAL arrays containing STRING recursively clone owned string +fields/elements. Converted arguments stay Alive until ownership transfers to the +callee; failed later arguments release pending values. Converted lvalues are fresh +objects, never copy sources of a different type. RETURN, discarded values and +statement temporaries use ordinary class cleanup, including exception exits. +Explicit C_STRING casts borrow a STRING buffer or construct an owning copy in the +other direction. FileHandler copies open-file names and releases them on close; +READFILE copies and releases its buffer. Explicit memory allocations remain separate. diff --git a/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md b/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md index e21bed1..f382b61 100644 --- a/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md +++ b/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md @@ -8,8 +8,8 @@ only symbol table. - Use `symbolAddress` for an object address: class variables and BYVAL class parameters store their current object address in a reference slot (`IsReference`). -- Use SymbolInfo::isConstant() for constant checks: scalar literals use - ConstantValue; owning STRING constants use ReadOnly plus Storage. +- Use SymbolInfo::isConstant() for constant checks: literals, including raw + C_STRING text constants, use ConstantValue and have no writable storage. - Read values through emitExpr. Writable/address-taking paths reject constants through requireWritable; internal STRING copy/assignment source bindings may read their storage. diff --git a/AGENTS/CONVENTIONS/TEMPLATES_AND_OPERATORS.md b/AGENTS/CONVENTIONS/TEMPLATES_AND_OPERATORS.md index 79f1a88..675ea3e 100644 --- a/AGENTS/CONVENTIONS/TEMPLATES_AND_OPERATORS.md +++ b/AGENTS/CONVENTIONS/TEMPLATES_AND_OPERATORS.md @@ -22,11 +22,13 @@ Part of [Load-bearing conventions](../CONVENTIONS.md). Basic call resolution is - When multiple definitions share a function/procedure name, every ordinary and template definition must specify OVERLOAD. - `resolveCall` computes static argument types/ranks once, then tries exact ordinary, - non-variadic template and variadic template tiers; an expected result type filters + non-variadic template and variadic template tiers, then repeats with permitted + BYVAL conversions; an expected result type filters ordinary candidates, while template tiers still match parameters only. Same-tier ties are errors. - Candidate checking must stay silent and must not instantiate speculative class - types. Explicit arguments pre-bind types without allowing conversions. + types. Explicit arguments pre-bind types; substituted scalar BYVAL parameters + may then use permitted conversions. - Instances keep the template owner for diagnostics/library behavior and the first requester in `VisibilityUnit` for lookup (`value_or(CurrentUnit)`). - Deferred bodies use the symbol snapshot at the template declaration to preserve @@ -40,7 +42,8 @@ Part of [Load-bearing conventions](../CONVENTIONS.md). Basic call resolution is token on PrototypeAST. Canonical names contain a space (`OPERATOR +`, `Class.OPERATOR AND`) to avoid collisions with ordinary identifiers. - `OperatorGen.cc` probes visible global and left-class member signatures without - emitting diagnostics or evaluating operands. Matching is exact; member/global ties + emitting diagnostics or evaluating operands. Exact operands and directly supported + builtins precede converted overloads; member/global ties are ambiguous and access is checked only after selection. - Both getExprTypeInfo and emission must consult this resolver with the expression's result context before hardcoded builtin result types. A strict context requires the diff --git a/AGENTS/CONVENTIONS/TYPES.md b/AGENTS/CONVENTIONS/TYPES.md index 7349ab1..d13773b 100644 --- a/AGENTS/CONVENTIONS/TYPES.md +++ b/AGENTS/CONVENTIONS/TYPES.md @@ -18,7 +18,8 @@ C base type and pointer levels independently of the alias `Name`. Use `sameType` for storage compatibility (including BYREF and array arguments); never equate C types just because their LLVM types or widths match. CScalar/CPointer values are handled by CTypeGen, not the legacy representation coercions. Cross-domain -assignments, arguments and operators require explicit casts, including literals. +assignments, arguments and operators require explicit casts, including numeric literals, +except for marked IMPLICIT class constructors and the documented text bridges. Plain C char uses native signedness; pseudocode CHAR stays unsigned. Numeric conversions use source signedness, and native floating formats use numeric_limits. Allocation sizes still use LLVM sizeof; native C type widths use build-compiler |
