Add assertion regarding local name mangling.

This commit is contained in:
Danila Fedorin 2020-09-10 15:05:02 -07:00
parent d3c719436a
commit 688463570c

View File

@ -55,9 +55,13 @@ void ast_lid::translate(global_scope& scope) {
void ast_lid::compile(const env_ptr& env, std::vector<instruction_ptr>& into) const { void ast_lid::compile(const env_ptr& env, std::vector<instruction_ptr>& into) const {
auto mangled_name = this->env->get_mangled_name(id); auto mangled_name = this->env->get_mangled_name(id);
// Local names shouldn't need mangling.
assert(!(mangled_name != id && !this->env->is_global(id)));
into.push_back(instruction_ptr( into.push_back(instruction_ptr(
(env->has_variable(mangled_name) && !this->env->is_global(id)) ? (env->has_variable(mangled_name) && !this->env->is_global(id)) ?
(instruction*) new instruction_push(env->get_offset(mangled_name)) : (instruction*) new instruction_push(env->get_offset(id)) :
(instruction*) new instruction_pushglobal(mangled_name))); (instruction*) new instruction_pushglobal(mangled_name)));
} }