Add binops.h and binops.cpp
This commit is contained in:
parent
e3e0cd9f9f
commit
9791c9c8da
@ -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)
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "codegen.h"
|
||||
#include "types.h"
|
||||
#include "binops.h"
|
||||
#include "tokens.h"
|
||||
#include "typechecker.h"
|
||||
|
||||
|
||||
8
src/binops.cpp
Normal file
8
src/binops.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
#include "binops.h"
|
||||
|
||||
namespace types {
|
||||
std::vector<BinopDefinition> create_binops() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
33
src/binops.h
Normal file
33
src/binops.h
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
#ifndef BINOP_H
|
||||
#define BINOP_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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<Type> lhs;
|
||||
BinOp op;
|
||||
std::shared_ptr<Type> rhs;
|
||||
std::shared_ptr<Type> result;
|
||||
llvm::Value* (*codegen)(codegen::Builder& builder);
|
||||
};
|
||||
|
||||
std::vector<BinopDefinition> create_binops();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -2,6 +2,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "types.h"
|
||||
#include "binops.h"
|
||||
|
||||
namespace types {
|
||||
int operator_precedence(BinOp& op) {
|
||||
|
||||
11
src/types.h
11
src/types.h
@ -7,17 +7,6 @@
|
||||
#include <memory>
|
||||
|
||||
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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user