Skip to content

Commit

Permalink
Fixed: #2317 AS3 direct editation - local register names colliding wi…
Browse files Browse the repository at this point in the history
…th parameter names
  • Loading branch information
jindrapetrik committed Sep 23, 2024
1 parent 3b3679e commit 8da8239
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ All notable changes to this project will be documented in this file.
- [#2314] AS3 direct editation - cannot save class initializer in some cases
- [#2315] AS3 direct editation - switching scripts during editation causing missing scripts
- [#2316] AS3 direct editation - private classes
- [#2317] AS3 direct editation - local register names colliding with parameter names

## [21.0.5] - 2024-09-05
### Fixed
Expand Down Expand Up @@ -3588,6 +3589,7 @@ Major version of SWF to XML export changed to 2.
[#2314]: https://www.free-decompiler.com/flash/issues/2314
[#2315]: https://www.free-decompiler.com/flash/issues/2315
[#2316]: https://www.free-decompiler.com/flash/issues/2316
[#2317]: https://www.free-decompiler.com/flash/issues/2317
[#2293]: https://www.free-decompiler.com/flash/issues/2293
[#2294]: https://www.free-decompiler.com/flash/issues/2294
[#2299]: https://www.free-decompiler.com/flash/issues/2299
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1209,21 +1209,32 @@ public int method(boolean isStatic, int name_index, boolean subMethod, boolean i
String varName = n.getVariableName();
if (!needsActivation) {
Matcher m = pat.matcher(varName);
//In first round, make all register that match standard loc_xx register
boolean addNew = false;
//In first round, make all register that match standard loc_xx register
if ((round == 1) && (m.matches())) {
String regIndexStr = m.group(1);
int regIndex = Integer.parseInt(regIndexStr);
while (registerNames.size() <= regIndex) {
registerNames.add(UNUSED);
registerTypes.add(TypeItem.UNBOUNDED);
registerLines.add(paramLine);

boolean alreadyExistsWithDifferentName = regIndex < registerNames.size()
&& !registerNames.get(regIndex).equals(UNUSED)
&& !registerNames.get(regIndex).equals(varName);

if (alreadyExistsWithDifferentName) {
addNew = true;
} else {
while (registerNames.size() <= regIndex) {
registerNames.add(UNUSED);
registerTypes.add(TypeItem.UNBOUNDED);
registerLines.add(paramLine);
}
registerNames.set(regIndex, varName);
registerTypes.set(regIndex, n.type);
registerLines.set(regIndex, n.line);
}
registerNames.set(regIndex, varName);
registerTypes.set(regIndex, n.type);
registerLines.set(regIndex, n.line);

} else if (round == 2 && !m.matches()) { //in second round the rest

addNew = true;
}
if (addNew) {
//search for some unused indices first:
int newRegIndex = -1;
for (int j = 0; j < registerNames.size(); j++) {
Expand Down

0 comments on commit 8da8239

Please sign in to comment.