Fix use of wrong environment for name mangling.
This commit is contained in:
parent
d3b1047d37
commit
5db864881a
|
@ -54,7 +54,7 @@ void compiler::translate() {
|
||||||
}
|
}
|
||||||
for(auto& defn : global_defs.defs_defn) {
|
for(auto& defn : global_defs.defs_defn) {
|
||||||
auto& function = defn.second->into_global(global_scp);
|
auto& function = defn.second->into_global(global_scp);
|
||||||
global_env->set_mangled_name(defn.first, function.name);
|
defn.second->env->set_mangled_name(defn.first, function.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
title: Compiling a Functional Language Using C++, Part 13 - More Improvements
|
title: Compiling a Functional Language Using C++, Part 13 - Cleanup
|
||||||
date: 2020-09-10T18:50:02-07:00
|
date: 2020-09-10T18:50:02-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
description: "In this post, we clean up our compiler and add some basic optimizations."
|
description: "In this post, we clean up our compiler."
|
||||||
---
|
---
|
||||||
|
|
||||||
In [part 12]({{< relref "12_compiler_let_in_lambda" >}}), we added `let/in`
|
In [part 12]({{< relref "12_compiler_let_in_lambda" >}}), we added `let/in`
|
||||||
|
@ -809,9 +809,10 @@ And here's what it is now:
|
||||||
|
|
||||||
{{< codelines "C++" "compiler/13/compiler.cpp" 55 58 >}}
|
{{< codelines "C++" "compiler/13/compiler.cpp" 55 58 >}}
|
||||||
|
|
||||||
We always declare the `definition_defn` function in
|
Rather than traversing the chain of environments from
|
||||||
the `global_env`. Thus, that's the only environment
|
the body of the definition, we just use the definition's
|
||||||
we need to know about to update the mangled name.
|
own `env_ptr`. This is cleaner and more explicit, and
|
||||||
|
it helps us not use the private members of `type_env`!
|
||||||
|
|
||||||
The deal with `env` is about as simple. We just make
|
The deal with `env` is about as simple. We just make
|
||||||
it and its two descendants classes, and mark their
|
it and its two descendants classes, and mark their
|
||||||
|
|
Loading…
Reference in New Issue
Block a user