diff options
Diffstat (limited to 'include/cps/StringConversionHandler.h')
| -rw-r--r-- | include/cps/StringConversionHandler.h | 33 |
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 |
