From 62b605c6c0ea13e9763c0a0115464007b13a8831 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 20 Oct 2026 11:57:16 +0000 Subject: refactor(strings): replace compiler builtins with the STRING library Construct literals as STRING values and route string operations through ordinary library functions and operators. Preserve value ownership in records, arrays, constants and file I/O. Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/OutputGen.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lib/CodeGen/OutputGen.cc') diff --git a/lib/CodeGen/OutputGen.cc b/lib/CodeGen/OutputGen.cc index c4ceb79..c1ea4b6 100644 --- a/lib/CodeGen/OutputGen.cc +++ b/lib/CodeGen/OutputGen.cc @@ -13,6 +13,13 @@ Value *CodeGen::emitStringNullGuard(Value *StrVal) { void CodeGen::emitOutputValue(Value *Val, const TypeInfo *Info, bool AppendNewline) { if (!Val || !Info) return; + if (Info->isString()) { + Value *Text = emitStringCString(Val); + if (Text) Builder->CreateCall(PrintfFunc, { + AppendNewline ? PrintfStringFormatStr + : Builder->CreateGlobalString("%s", "fmt_str_inline", 0, TheModule.get()), Text}); + return; + } std::vector Args; Value *Fmt = nullptr; @@ -38,16 +45,6 @@ void CodeGen::emitOutputValue(Value *Val, const TypeInfo *Info, bool AppendNewli break; } - case TypeKind::String: { - Value *StrVal = emitStringNullGuard(Val); - Fmt = AppendNewline - ? PrintfStringFormatStr - : Builder->CreateGlobalString("%s", "fmt_str_inline", 0, TheModule.get()); - Args.push_back(Fmt); - Args.push_back(StrVal); - break; - } - case TypeKind::Char: { Value *CharVal = coerceValueToType(Val, resolveType("CHAR")); Value *Promoted = Builder->CreateZExt(CharVal, Type::getInt32Ty(*TheContext), "char_for_printf"); -- cgit v1.3.1-4-g156e