Closed j-hui closed 1 year ago
The lambda lift pass is still broken with respect to #111 . To fix it, I need to add type information to the varNames
map, which will allow me to simplify the lambda lifting pass to not have to manage local scope anymore.
This pass adds a name mangling pass that ensures all variable identifiers are globally unique, while also making sure that identifier names are actually valid C identifiers.
My mangling strategy is conservative; when picking a new identifier, it appends ascending numbers until it finds a name that hasn't already been defined. Though this is somewhat inefficient when there are consistent clashes, it produces much more readable mangled names.
This pass also introduces a global identifiers map in the
Program
record that maps those global identifiers to their original names. This can be used for nicer pretty-printing, or to ensure that newly generated names do not clash with any other identifiers.Still left to do: