diff options
| author | ov-4 <hausemasterstream@gmail.com> | 2026-01-29 14:24:05 +0000 |
|---|---|---|
| committer | ov-4 <hausemasterstream@gmail.com> | 2026-01-29 14:24:05 +0000 |
| commit | 943ed04b775949e8bc4948bcb8d762a32ab14f76 (patch) | |
| tree | 5c8d09bcd702558e1fba25e176712a1697a6c7e7 /include/cps/CodeGen.h | |
| parent | 4573880fcc32bd76a72a4ae713190cd997194583 (diff) | |
Added array
Diffstat (limited to 'include/cps/CodeGen.h')
| -rw-r--r-- | include/cps/CodeGen.h | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/include/cps/CodeGen.h b/include/cps/CodeGen.h index 9be6cc7..8bf5819 100644 --- a/include/cps/CodeGen.h +++ b/include/cps/CodeGen.h @@ -1,40 +1,46 @@ #pragma once -#include "cps/AST.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" +#include "cps/AST.h" #include <map> +#include <memory> namespace cps { +class ArrayHandler; + class CodeGen { std::unique_ptr<llvm::LLVMContext> TheContext; std::unique_ptr<llvm::Module> TheModule; std::unique_ptr<llvm::IRBuilder<>> Builder; std::map<std::string, llvm::AllocaInst*> NamedValues; - - llvm::AllocaInst *CreateEntryBlockAlloca(llvm::Function *TheFunction, - const std::string &VarName); + + std::unique_ptr<ArrayHandler> Arrays; llvm::FunctionCallee PrintfFunc; llvm::FunctionCallee ScanfFunc; llvm::Value *PrintfFormatStr; llvm::Value *ScanfFormatStr; - - llvm::Value *emitExpr(ExprAST *Expr); - void emitStmt(StmtAST *Stmt); - + + void SetupExternalFunctions(); + llvm::AllocaInst *CreateEntryBlockAlloca(llvm::Function *TheFunction, const std::string &VarName); + void emitIfStmt(IfStmtAST *Stmt); void emitWhileStmt(WhileStmtAST *Stmt); void emitRepeatStmt(RepeatStmtAST *Stmt); void emitForStmt(ForStmtAST *Stmt); - void SetupExternalFunctions(); - public: CodeGen(); + ~CodeGen(); void compile(const std::vector<std::unique_ptr<StmtAST>> &Statements); void print(); + + llvm::Value *emitExpr(ExprAST *Expr); + void emitStmt(StmtAST *Stmt); + + friend class ArrayHandler; }; -} // namespace cps +} |
