aboutsummaryrefslogtreecommitdiff
path: root/include/cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-07-26 12:17:20 +0000
committer_ov4 <ov4@ov4.org>2026-07-26 12:17:20 +0000
commit9164871fe4982bdd12866eb28ebded68ca3dacd1 (patch)
tree7cfd061e731958071f833d0a8932cc45c51ad455 /include/cps
parent1749b2b4a3e55db7c9bed95376f99b7f07932b49 (diff)
refactor: dedupe StringHandler case-convert and substring-copy code
emitLCase/emitUCase were a 45-line verbatim pair differing only in the libc callee; both now delegate to emitCaseConvert(Str, CaseFn). The malloc+memcpy+NUL tail duplicated across emitMid/emitRight/emitLeft moves into allocCopySubstring; each function keeps its own clamp logic, which is intentionally different. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'include/cps')
-rw-r--r--include/cps/StringHandler.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/cps/StringHandler.h b/include/cps/StringHandler.h
index 0af0cc7..e9a8752 100644
--- a/include/cps/StringHandler.h
+++ b/include/cps/StringHandler.h
@@ -19,6 +19,9 @@ class StringHandler {
llvm::FunctionCallee ToUpperFunc;
llvm::FunctionCallee ToLowerFunc;
+ llvm::Value *emitCaseConvert(llvm::Value *Str, llvm::FunctionCallee CaseFn);
+ llvm::Value *allocCopySubstring(llvm::Value *Src, llvm::Value *StartIdx, llvm::Value *Len);
+
public:
StringHandler(llvm::LLVMContext &Ctx, llvm::IRBuilder<> &B, llvm::Module &M);