diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-20 11:57:16 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-20 11:57:16 +0000 |
| commit | 62b605c6c0ea13e9763c0a0115464007b13a8831 (patch) | |
| tree | 53c27965f5a365682e0d79fd96e25b228ecb9dca /lib/CodeGen/ControlFlowGen.cc | |
| parent | bfe2e75d7e3b372e55369677028429990c49bc54 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ControlFlowGen.cc')
| -rw-r--r-- | lib/CodeGen/ControlFlowGen.cc | 11 |
1 files changed, 9 insertions, 2 deletions
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<size_t> 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); |
