#ifndef BINOP_H #define BINOP_H #include #include "types.h" namespace types { enum class BinOp { Assignment, Add, Sub, LessThan, GreaterThan, }; enum class Unary { AddPostfix, AddPrefix, SubPostfix, SubPrefix, Not, Negation, Plus, }; int operator_precedence(BinOp& op); std::string format_operator(BinOp& op); struct BinopDefinition { std::shared_ptr lhs; BinOp op; std::shared_ptr rhs; std::shared_ptr result; bool lhs_lvalue; llvm::Value* (*codegen)(codegen::Builder& builder, llvm::Value* lhs, llvm::Value* rhs); }; std::vector create_binops(); std::optional find_binop( std::vector& binops, std::shared_ptr lhs, BinOp op, std::shared_ptr rhs); struct UnopDefinition { std::shared_ptr value; Unary op; std::shared_ptr res; llvm::Value* (*codegen)(codegen::Builder& builder, std::shared_ptr ty, llvm::Value* value); }; std::vector create_unops(); std::optional find_unop( std::vector& unops, std::shared_ptr value, Unary op); } #endif