Skip to content

Commit

Permalink
Fixed: #2301 AS3 direct editing - instance variables assignments prod…
Browse files Browse the repository at this point in the history
…ucing additional static assignments
  • Loading branch information
Jindřich Petřík authored and jindrapetrik committed Sep 5, 2024
1 parent 8eabe85 commit 9d421bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Fixed
- [#2293] FLA export - stackoverflow on multilevel clips extraction, clipping
- [#2294] FLA export - Nullpointer on AS3 SWFs without document class
- [#2294], [#2300] AS3 export - Nullpointer on SWFs without document class
- [#2299] AS1/2 - Nullpointer on loadMovie with register as parameter
- [#2301] AS3 direct editing - instance variables assignments producing additional static assignments

## [21.0.4] - 2024-08-27
### Fixed
Expand Down Expand Up @@ -3534,7 +3535,9 @@ Major version of SWF to XML export changed to 2.
[alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7
[#2293]: https://www.free-decompiler.com/flash/issues/2293
[#2294]: https://www.free-decompiler.com/flash/issues/2294
[#2300]: https://www.free-decompiler.com/flash/issues/2300
[#2299]: https://www.free-decompiler.com/flash/issues/2299
[#2301]: https://www.free-decompiler.com/flash/issues/2301
[#2266]: https://www.free-decompiler.com/flash/issues/2266
[#2275]: https://www.free-decompiler.com/flash/issues/2275
[#2276]: https://www.free-decompiler.com/flash/issues/2276
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ override protected function get skinParts() : Object

//List<AVM2Instruction> cinitcode = new ArrayList<>();
List<AVM2Instruction> initcode = new ArrayList<>();
/*for (GraphTargetItem ti : commands) {
for (GraphTargetItem ti : commands) {
if ((ti instanceof SlotAVM2Item) || (ti instanceof ConstAVM2Item)) {
GraphTargetItem val = null;
boolean isStatic = false;
Expand All @@ -831,12 +831,13 @@ override protected function get skinParts() : Object
continue;
}
}
if (isStatic && val != null) {
/*if (isStatic && val != null) {
cinitcode.add(ins(AVM2Instructions.FindProperty, traitName(ns, tname)));
localData.isStatic = true;
cinitcode.addAll(toInsList(val.toSource(localData, this)));
cinitcode.add(ins(isConst ? AVM2Instructions.InitProperty : AVM2Instructions.SetProperty, traitName(ns, tname)));
}
*/
if (!isStatic && val != null) {
//do not init basic values, that can be stored in trait
if (!(val instanceof IntegerValueAVM2Item) && !(val instanceof StringAVM2Item) && !(val instanceof BooleanAVM2Item) && !(val instanceof NullAVM2Item) && !(val instanceof UndefinedAVM2Item)) {
Expand All @@ -846,16 +847,8 @@ override protected function get skinParts() : Object
initcode.add(ins(isConst ? AVM2Instructions.InitProperty : AVM2Instructions.SetProperty, traitName(ns, tname)));
}
}
} else if (ti instanceof MethodAVM2Item) {
//ignore
} else {
localData.isStatic = true;
List<GraphSourceItem> srcs = ti.toSourceIgnoreReturnValue(localData, this);
for (GraphSourceItem src : srcs) {
cinitcode.add((AVM2Instruction)src);
}
}
}*/
}
MethodBody initBody = null;
if (!isInterface) {
initBody = abcIndex.getSelectedAbc().findBody(init);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ public boolean hasReturnValue() {

@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {

if (localData.isStatic != isStatic) {
return new ArrayList<>();
}

AVM2SourceGenerator agen = (AVM2SourceGenerator) generator;
int ns = agen.genNs(localData.importedClasses, pkg.name, pkg, localData.openedNamespaces, localData, line);
if (type.toString().equals("Namespace")) {
return new ArrayList<>();
}


List<GraphSourceItem> ret = new ArrayList<>();
if (value != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,14 @@ public boolean hasReturnValue() {

@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {

if (localData.isStatic != isStatic) {
return new ArrayList<>();
}

AVM2SourceGenerator agen = (AVM2SourceGenerator) generator;
int ns = agen.genNs(localData.importedClasses, pkg.name, pkg, localData.openedNamespaces, localData, line);

int ns = agen.genNs(localData.importedClasses, pkg.name, pkg, localData.openedNamespaces, localData, line);
List<GraphSourceItem> ret = new ArrayList<>();
if (value != null) {
ret.add(ins(AVM2Instructions.FindProperty, agen.traitName(ns, var)));
Expand Down

0 comments on commit 9d421bb

Please sign in to comment.