aboutsummaryrefslogtreecommitdiff
path: root/include/cps/StringConversionHandler.h
diff options
context:
space:
mode:
author_ov4 <hausemasterstream@gmail.com>2026-03-03 07:22:19 +0000
committer_ov4 <hausemasterstream@gmail.com>2026-03-03 07:22:19 +0000
commitcc7b9b34e99fa17357e14ac69f5fb2d1535b5512 (patch)
tree40f093ef98c062a14a3b839ad2337646437645e9 /include/cps/StringConversionHandler.h
parent1b524f75401a6318fbaf3fee0bfcbe59348f2e51 (diff)
Added all built-in functions
Diffstat (limited to 'include/cps/StringConversionHandler.h')
-rw-r--r--include/cps/StringConversionHandler.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/cps/StringConversionHandler.h b/include/cps/StringConversionHandler.h
new file mode 100644
index 0000000..db493bf
--- /dev/null
+++ b/include/cps/StringConversionHandler.h
@@ -0,0 +1,33 @@
+#pragma once
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+
+namespace cps {
+
+class StringConversionHandler {
+ llvm::LLVMContext &Context;
+ llvm::IRBuilder<> &Builder;
+ llvm::Module &Module;
+
+ llvm::FunctionCallee SprintfFunc;
+ llvm::FunctionCallee StrtolFunc;
+ llvm::FunctionCallee StrtodFunc;
+ llvm::FunctionCallee MallocFunc;
+
+public:
+ StringConversionHandler(llvm::LLVMContext &Ctx, llvm::IRBuilder<> &B, llvm::Module &M);
+
+ void setupExternalFunctions();
+
+ // NUM TO STR(x) RETURNS STRING
+ llvm::Value *emitNumToStr(llvm::Value *Num, bool IsReal);
+
+ // STR TO NUM(x) RETURNS NUMBER
+ llvm::Value *emitStrToNum(llvm::Value *Str, bool AsReal);
+
+ // IS NUM(ThisString) RETURNS BOOLEAN
+ llvm::Value *emitIsNum(llvm::Value *Str);
+};
+
+} // namespace cps