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/ControlFlowGen.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/CodeGen/ControlFlowGen.cc') diff --git a/lib/CodeGen/ControlFlowGen.cc b/lib/CodeGen/ControlFlowGen.cc index 414fe19..771669d 100644 --- a/lib/CodeGen/ControlFlowGen.cc +++ b/lib/CodeGen/ControlFlowGen.cc @@ -189,7 +189,9 @@ void CodeGen::emitCaseStmt(CaseStmtAST *Stmt) { return; } const TypeInfo *SelectorType = getExprTypeInfo(&Selector); - Value *Selected = emitExpr(&Selector); + std::vector Captured; + Value *Selected = containsString(SelectorType) + ? emitOwnedValue(&Selector, SelectorType, Captured) : emitExpr(&Selector); if (!Selected || !SelectorType) return; auto *F = Builder->GetInsertBlock()->getParent(); @@ -210,7 +212,10 @@ void CodeGen::emitCaseStmt(CaseStmtAST *Stmt) { reportError("Cannot determine CASE label type"); return nullptr; } + size_t Temporaries = StackObjects.size(); Value *LabelValue = emitExpr(Label); + if (containsString(LabelType) && !isObjectLValue(Label)) + materializeOperatorReceiver(LabelValue, LabelType); auto Overload = resolveOperator(Op, SelectorType, LabelType); if (Overload.Signature && !Overload.Ambiguous) { const TypeInfo *Result = resolveType(Overload.Signature->ReturnTypeName); @@ -219,7 +224,9 @@ void CodeGen::emitCaseStmt(CaseStmtAST *Stmt) { return nullptr; } } - return emitBinaryOp(Op, Selected, SelectorType, LabelValue, LabelType, Branch.Line); + Value *Result = emitBinaryOp(Op, Selected, SelectorType, LabelValue, LabelType, Branch.Line); + cleanupTemporaries(Temporaries); + return Result; }; if (!Branch.Lower) { Builder->CreateBr(Body); -- cgit v1.3.1-4-g156e