From 0cf54b4f77ccf8376341950b02ceb7c1d1268ed7 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Fri, 30 Oct 2026 14:31:07 +0000 Subject: refactor(strings): construct string values implicitly from raw literals Keep double-quoted literals and text constants as C_STRING values. Use marked STRING constructors for text and CHAR conversion, preserving string operations and I/O through the existing class machinery. Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/OutputGen.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/CodeGen/OutputGen.cc') diff --git a/lib/CodeGen/OutputGen.cc b/lib/CodeGen/OutputGen.cc index faf21df..cecf0b7 100644 --- a/lib/CodeGen/OutputGen.cc +++ b/lib/CodeGen/OutputGen.cc @@ -105,6 +105,19 @@ Value *CodeGen::emitStringNullGuard(Value *StrVal) { void CodeGen::emitOutputValue(Value *Val, const TypeInfo *Info, bool AppendNewline) { if (!Val || !Info) return; + if (Info->CIdentity == "char*") { + const TypeInfo *String = requireStringType(); + const FuncSig *Constructor = findImplicitConstructor(Info, String); + if (!Constructor) { + if (String) reportError("STRING requires an IMPLICIT constructor NEW(Text : C_STRING)"); + return; + } + Value *Converted = emitImplicitConstruct(*Constructor, String, Val); + if (!Converted) return; + materializeOperatorReceiver(Converted, String); + emitOutputValue(Converted, String, AppendNewline); + return; + } if (Info->isString()) { Value *Text = emitStringCString(Val); if (Text) Builder->CreateCall(PrintfFunc, { -- cgit v1.3.1-4-g156e