-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Description / 説明
スコープに被りがなければ変数名に suffix を付けないでほしい
The current implementation avoids name conflicts of variables even when the scopes of them are distinct. For example, i and i2 are used in the following result:
int64_t solve(int64_t n, int64_t c, std::vector<int64_t> h) {
...
for (int32_t i = 0; i < 1ll; ++ i) {
...
}
for (int32_t i2 = 0; i2 < n - 1ll; ++ i2) {
...
}
return x2[n - 1ll];
}We want to use the same name, just i, for both variables in such cases.
Motivation / 動機
for more readability
Tutorial
This issue is not trivial (needs many implementation) but relatively easier than other issues, so marked as a good first issue.
For this issue, probably you need to do 3 steps:
(1.): Extend mapExprStatementExprM and mapExprStatementStatementM, mutual recursive functions to map exprs and statements in exprs and statements, to give current scopes to callback functions.
The mapSubExprM of core already did this.
(2.): Update mapVarNameProgramM in the similar manner to (1.).
(3.): Main part: Update rename function and chooseOccName function in src/Jikka/CPlusPlus/Convert/BurnFlavouredNames.hs to use information of current scopes. These functions decides strings which are used in the result code.