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 "error.hpp"
|
||||||
#include "type.hpp"
|
#include "type.hpp"
|
||||||
#include "parse_driver.hpp"
|
#include "parse_driver.hpp"
|
||||||
|
#include "type_env.hpp"
|
||||||
#include "llvm/IR/LegacyPassManager.h"
|
#include "llvm/IR/LegacyPassManager.h"
|
||||||
#include "llvm/IR/Verifier.h"
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/Support/TargetSelect.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(
|
type_ptr cmp_type = type_ptr(new type_arr(
|
||||||
int_type_app,
|
int_type_app,
|
||||||
type_ptr(new type_arr(int_type_app, bool_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);
|
constexpr binop number_ops[] = { PLUS, MINUS, TIMES, DIVIDE, MODULO };
|
||||||
env->bind("*", binop_type, visibility::global);
|
constexpr binop cmp_ops[] = { EQUALS, LESS_EQUALS };
|
||||||
env->bind("/", binop_type, visibility::global);
|
for(auto& op : number_ops) {
|
||||||
env->bind("%", binop_type, visibility::global);
|
env->bind(op_name(op), binop_type, visibility::global);
|
||||||
env->bind("==", cmp_type, visibility::global);
|
}
|
||||||
env->bind("<=", cmp_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("True", bool_type_app, visibility::global);
|
||||||
env->bind("False", bool_type_app, visibility::global);
|
env->bind("False", bool_type_app, visibility::global);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user