#pragma once #include #include #include #include #include "instruction.hpp" struct ast; using ast_ptr = std::unique_ptr; struct global_definition { std::string name; std::vector params; ast_ptr body; std::vector instructions; llvm::Function* generated_function; global_definition(std::string n, std::vector ps, ast_ptr b) : name(std::move(n)), params(std::move(ps)), body(std::move(b)) {} void compile(); void declare_llvm(llvm_context& ctx); void generate_llvm(llvm_context& ctx); }; using global_definition_ptr = std::unique_ptr; struct global_scope { std::map occurence_count; std::vector definitions; global_definition_ptr& add_definition(std::string n, std::vector ps, ast_ptr b); };