-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Name mangling #45
Comments
I started working on this and I think I realized that maybe redeclared variables shouldn't be allowed at all. The best way to do it for now could be to just do it the "java" model, where
In java, if statements are sort of a psuedo scope where anything it creates doesnt live past the if statement, but it is the same scope in the sense that It cant create a local However, this will need to be revisited later on when functions are implemented (since they do have their own entire scope)
In this case, the f() will by default inherit the global scope (so b=9, a=0), but allow it to have a local a. We will have to mangle the a within the f() to be different from the global a Here is my progress for name_mangler: ``` // Copyright © 2022-2023 Brandon Li. All rights reserved.//! Name mangling is the process of making every variable name unique. It is needed to ensure that variables in use File; /// Name Mangler for each scope of the program.
} impl<'a> Mangler<'a> {
}
|
Consider the following program:
One approach to have this behavior is to remove the "redeclare" check in type checker. In the then_block, the
a
is added toidentifier_types
in the ir. However, im thinking that redceclaring might have problems in the register allocation, as a variable in a if block would share the conflicts of whatever it previously had prematurely. Additionally, without name mangling, botha
s would be assigned to the same location and this the result would not even be correct.The text was updated successfully, but these errors were encountered: