diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e5e532..a281ec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ add_executable(${PROJECT_NAME} src/codegen.cpp src/types.cpp src/typechecker.cpp + src/binops.cpp ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Weffc++ -Wextra -Wpedantic -Werror) diff --git a/src/ast.h b/src/ast.h index 37917c7..762c91d 100644 --- a/src/ast.h +++ b/src/ast.h @@ -7,6 +7,7 @@ #include "codegen.h" #include "types.h" +#include "binops.h" #include "tokens.h" #include "typechecker.h" diff --git a/src/binops.cpp b/src/binops.cpp new file mode 100644 index 0000000..9a323a6 --- /dev/null +++ b/src/binops.cpp @@ -0,0 +1,8 @@ + +#include "binops.h" + +namespace types { + std::vector create_binops() { + return {}; + } +} \ No newline at end of file diff --git a/src/binops.h b/src/binops.h new file mode 100644 index 0000000..706fca7 --- /dev/null +++ b/src/binops.h @@ -0,0 +1,33 @@ + +#ifndef BINOP_H +#define BINOP_H + +#include + +#include "types.h" + +namespace types { + enum class BinOp { + Assignment, + Add, + Sub, + LessThan, + GreaterThan, + }; + + 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; + llvm::Value* (*codegen)(codegen::Builder& builder); + }; + + std::vector create_binops(); + +} + +#endif \ No newline at end of file diff --git a/src/types.cpp b/src/types.cpp index 785be71..acca953 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -2,6 +2,7 @@ #include #include "types.h" +#include "binops.h" namespace types { int operator_precedence(BinOp& op) { diff --git a/src/types.h b/src/types.h index 596eac2..95d3769 100644 --- a/src/types.h +++ b/src/types.h @@ -7,17 +7,6 @@ #include namespace types { - enum class BinOp { - Assignment, - Add, - Sub, - LessThan, - GreaterThan, - }; - - int operator_precedence(BinOp& op); - std::string format_operator(BinOp& op); - enum class TypeKind { Fundamental, Function,