#ifndef FORSPLL_AST_HPP #define FORSPLL_AST_HPP #include "llvm.hpp" #include "var.hpp" #include #include #include struct BaseAST { std::string name; BaseAST(const std::string& n): name(n) {} virtual ~BaseAST() = default; virtual llvm::Value *codegen(LLVMState&) const = 0; }; struct NumberAST : public BaseAST { // push number onto stack explicit NumberAST(const std::string& n); llvm::Value *codegen(LLVMState& llvmState) const override; }; struct PushAST : public BaseAST { // push named value to stack explicit PushAST(const std::string& n); llvm::Value *codegen(LLVMState& llvmState) const override; }; struct PopAST : public BaseAST { // pop value on stack to named var explicit PopAST(const std::string& n); llvm::Value *codegen(LLVMState& llvmState) const override; }; struct CallAST : public BaseAST { // invoke named invocable explicit CallAST(const std::string& n); llvm::Value *codegen(LLVMState& llvmState) const override; }; struct ThunkAST : public BaseAST { static int tcount; std::list> body; llvm::IRBuilderBase::InsertPoint parent; llvm::Function *func; explicit ThunkAST(LLVMState& llvmState); explicit ThunkAST(LLVMState& llvmState, std::string n); llvm::Value *codegen(LLVMState& llvmState) const override; }; #endif // FORSPLL_AST_HPP