aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/OutputGen.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-30 14:31:07 +0000
committer_ov4 <ov4@ov4.org>2026-10-30 14:31:07 +0000
commit0cf54b4f77ccf8376341950b02ceb7c1d1268ed7 (patch)
treeeebbba01063451c28f0a2e1cc048215f50beb98f /lib/CodeGen/OutputGen.cc
parent4cb0d9b196008bc55dbfcdac1f9211dbbc879895 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/OutputGen.cc')
-rw-r--r--lib/CodeGen/OutputGen.cc13
1 files changed, 13 insertions, 0 deletions
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, {