Commit eb8b7aa9

eb8b7aa99e79Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified

Description

prepare: emit string literals with 0xff marker prefix

All string literals from c_string_literal now emit as: ("\xff" "content" + 1)

This prepends a 0xff marker byte to every literal. The pointer returned is offset by +1 to skip the marker, so normal C string operations (strlen, strcmp, printf, etc.) work unchanged.

This is preparation for GC-managed dynamic strings: reading s[-1] on a literal safely returns 0xff (within the allocated region), allowing GC to distinguish literals from dynamic strings without UB or magic numbers.

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
eb8b7aa99e79
Parent
2e36d4d4d650

spinel_codegen.rbmodifiedView file

@@ -10539,7 +10539,9 @@
1053910539 i = i + 1
1054010540 end
1054110541 end
10542- result + "\""
10542+ # Prepend 0xff marker byte so GC can identify static literals.
10543+ # Return form: ("\xff" "content" + 1) — C concatenates adjacent literals.
10544+ "(\"\\xff\" " + result + "\" + 1)"
1054310545 end
1054410546
1054510547 def compile_interpolated(nid)