Actually use the environment for binop functions.
This commit is contained in:
parent
e7afa126c8
commit
99f7f45d51
|
@ -135,7 +135,8 @@ void ast_binop::compile(const env_ptr& env, std::vector<instruction_ptr>& into)
|
||||||
right->compile(env, into);
|
right->compile(env, into);
|
||||||
left->compile(env_ptr(new env_offset(1, env)), into);
|
left->compile(env_ptr(new env_offset(1, env)), into);
|
||||||
|
|
||||||
into.push_back(instruction_ptr(new instruction_pushglobal(op_action(op))));
|
auto mangled_name = this->env->get_mangled_name(op_name(op));
|
||||||
|
into.push_back(instruction_ptr(new instruction_pushglobal(mangled_name)));
|
||||||
into.push_back(instruction_ptr(new instruction_mkapp()));
|
into.push_back(instruction_ptr(new instruction_mkapp()));
|
||||||
into.push_back(instruction_ptr(new instruction_mkapp()));
|
into.push_back(instruction_ptr(new instruction_mkapp()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,11 @@ void prelude_types(definition_group& defs, type_env_ptr env) {
|
||||||
constexpr binop cmp_ops[] = { EQUALS, LESS_EQUALS };
|
constexpr binop cmp_ops[] = { EQUALS, LESS_EQUALS };
|
||||||
for(auto& op : number_ops) {
|
for(auto& op : number_ops) {
|
||||||
env->bind(op_name(op), binop_type, visibility::global);
|
env->bind(op_name(op), binop_type, visibility::global);
|
||||||
|
env->set_mangled_name(op_name(op), op_action(op));
|
||||||
}
|
}
|
||||||
for(auto& op : cmp_ops) {
|
for(auto& op : cmp_ops) {
|
||||||
env->bind(op_name(op), cmp_type, visibility::global);
|
env->bind(op_name(op), cmp_type, visibility::global);
|
||||||
|
env->set_mangled_name(op_name(op), op_action(op));
|
||||||
}
|
}
|
||||||
|
|
||||||
env->bind("True", bool_type_app, visibility::global);
|
env->bind("True", bool_type_app, visibility::global);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user