diff --git a/code/compiler/13/main.cpp b/code/compiler/13/main.cpp index 1c1fb4a..19904a3 100644 --- a/code/compiler/13/main.cpp +++ b/code/compiler/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);