blaise/compiler
Graeme Geldenhuys 9bbcfd8b77 fix(opdf): escape string-constant values in the recConstant .ascii line
The OPDF emitter wrote a string constant's value verbatim into the debug
section's `.ascii "<val>"  # Value` line. Any double-quote, newline or
backslash in the value broke the line: an unescaped `"` closed the literal
early, leaving `..."  # Value` as a garbage mnemonic, and a newline split the
directive across two lines. Under --debug-opdf the OPDF section is appended to
the same assembly text the assembler consumes, so this aborted the compile —
the internal assembler with "unhandled mnemonic: [\"  # Value]" and the
external assembler with "junk at end of line". It was content-specific, so it
only surfaced on larger programs (e.g. building a debuggable TestRunner) whose
constants happened to contain such characters.

Add EscapeAsciiStr (C-style escapes: \" \\ \n \r \t + octal for other
non-printables) and apply it to the recConstant value. The OPDF ValueLen field
stays the RAW byte count, which `.ascii` with these escapes reproduces exactly,
so the emitted byte length is unchanged.

Tests: TOPDFTests.TestOPDF_StringConst_SpecialChars_Escaped (IR: the .ascii
line is escaped) and TInternalAsmE2ETests.TestDebugOPDF_StringConstSpecialChars_
AssemblesAndRuns (compile+run under --debug-opdf --assembler internal). Both the
internal- and external-assembler failure modes are resolved by the one escape.

Verified: all four fixpoints green; full suite passes under QBE-built and
native-built test runner (4026 tests).
2026-07-01 12:04:34 +01:00
..
src fix(opdf): escape string-constant values in the recConstant .ascii line 2026-07-01 12:04:34 +01:00
project.xml refactor(rtl): relocate RTL units into the compiler tree (dotted-flat names) 2026-06-25 16:05:44 +01:00