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/codegen.cpp
|
||||||
src/types.cpp
|
src/types.cpp
|
||||||
src/typechecker.cpp
|
src/typechecker.cpp
|
||||||
|
src/binops.cpp
|
||||||
)
|
)
|
||||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
|
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Weffc++ -Wextra -Wpedantic -Werror)
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Weffc++ -Wextra -Wpedantic -Werror)
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "codegen.h"
|
#include "codegen.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "binops.h"
|
||||||
#include "tokens.h"
|
#include "tokens.h"
|
||||||
#include "typechecker.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 <sstream>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "binops.h"
|
||||||
|
|
||||||
namespace types {
|
namespace types {
|
||||||
int operator_precedence(BinOp& op) {
|
int operator_precedence(BinOp& op) {
|
||||||
|
|||||||
11
src/types.h
11
src/types.h
@ -7,17 +7,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace types {
|
namespace types {
|
||||||
enum class BinOp {
|
|
||||||
Assignment,
|
|
||||||
Add,
|
|
||||||
Sub,
|
|
||||||
LessThan,
|
|
||||||
GreaterThan,
|
|
||||||
};
|
|
||||||
|
|
||||||
int operator_precedence(BinOp& op);
|
|
||||||
std::string format_operator(BinOp& op);
|
|
||||||
|
|
||||||
enum class TypeKind {
|
enum class TypeKind {
|
||||||
Fundamental,
|
Fundamental,
|
||||||
Function,
|
Function,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user