Move common code into loops.
This commit is contained in:
parent
a940503cea
commit
d3c719436a
17
13/main.cpp
17
13/main.cpp
|
@ -9,6 +9,7 @@
|
|||
#include "error.hpp"
|
||||
#include "type.hpp"
|
||||
#include "parse_driver.hpp"
|
||||
#include "type_env.hpp"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
|
@ -37,13 +38,15 @@ void prelude_types(definition_group& defs, type_env_ptr env) {
|
|||
type_ptr cmp_type = type_ptr(new type_arr(
|
||||
int_type_app,
|
||||
type_ptr(new type_arr(int_type_app, bool_type_app))));
|
||||
env->bind("+", binop_type, visibility::global);
|
||||
env->bind("-", binop_type, visibility::global);
|
||||
env->bind("*", binop_type, visibility::global);
|
||||
env->bind("/", binop_type, visibility::global);
|
||||
env->bind("%", binop_type, visibility::global);
|
||||
env->bind("==", cmp_type, visibility::global);
|
||||
env->bind("<=", cmp_type, visibility::global);
|
||||
|
||||
constexpr binop number_ops[] = { PLUS, MINUS, TIMES, DIVIDE, MODULO };
|
||||
constexpr binop cmp_ops[] = { EQUALS, LESS_EQUALS };
|
||||
for(auto& op : number_ops) {
|
||||
env->bind(op_name(op), binop_type, visibility::global);
|
||||
}
|
||||
for(auto& op : cmp_ops) {
|
||||
env->bind(op_name(op), cmp_type, visibility::global);
|
||||
}
|
||||
|
||||
env->bind("True", bool_type_app, visibility::global);
|
||||
env->bind("False", bool_type_app, visibility::global);
|
||||
|
|
Loading…
Reference in New Issue
Block a user