diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/cps/AST.h | 9 | ||||
| -rw-r--r-- | include/cps/CodeGen.h | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/include/cps/AST.h b/include/cps/AST.h index c7764c6..c2754a5 100644 --- a/include/cps/AST.h +++ b/include/cps/AST.h @@ -125,9 +125,14 @@ public: class DeclareStmtAST : public StmtAST { std::string Name; std::string Type; + std::vector<std::unique_ptr<ExprAST>> Args; + bool HasParens; public: - DeclareStmtAST(const std::string &Name, const std::string &Type = "INTEGER") - : Name(Name), Type(Type) {} + DeclareStmtAST(const std::string &Name, const std::string &Type = "INTEGER", + std::vector<std::unique_ptr<ExprAST>> Args = {}, bool HasParens = false) + : Name(Name), Type(Type), Args(std::move(Args)), HasParens(HasParens) {} + const auto &getArgs() const { return Args; } + bool hasParens() const { return HasParens; } const std::string &getName() const { return Name; } const std::string &getType() const { return Type; } }; diff --git a/include/cps/CodeGen.h b/include/cps/CodeGen.h index 593cde0..1813d9d 100644 --- a/include/cps/CodeGen.h +++ b/include/cps/CodeGen.h @@ -36,6 +36,13 @@ class CodeGen { std::string CurrentClass; const PrototypeAST *findMethod(const std::string &Class, const std::string &Name) const; llvm::Value *emitMemberCall(MemberCallExprAST *Call); + llvm::Value *emitMethodCall(const std::string &Class, llvm::Value *Receiver, + const std::string &Name, + const std::vector<std::unique_ptr<ExprAST>> &Args, int Line); + bool typeNeedsConstruction(const std::string &TypeName) const; + bool emitConstruct(const std::string &TypeName, llvm::Value *Addr, + const std::vector<std::unique_ptr<ExprAST>> &Args, int Line); + bool emitDefaultConstruct(const std::string &TypeName, llvm::Value *Addr, int Line); struct ConstantScope { unsigned ID; IdentifierMap<std::optional<SymbolInfo>> Saved; |
