Skip to content

Commit

Permalink
Fixed #2135 FLA Export - framescripts handling when addFrameScript us…
Browse files Browse the repository at this point in the history
…es Multinames instead of QNames
  • Loading branch information
jindrapetrik committed Dec 2, 2023
1 parent cea4a81 commit 581e1e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ All notable changes to this project will be documented in this file.
- [#2131] UseOutline flag for DefineEditText
- Wordrapping long words in DefineEditText
- [#2133] Linux/Mac - ffdec.sh not correctly parsing java build number on javas without it
- [#2135] FLA Export - framescripts handling when addFrameScript uses Multinames instead of QNames

### Changed
- [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class
Expand Down Expand Up @@ -3331,6 +3332,7 @@ Major version of SWF to XML export changed to 2.
[#2078]: https://www.free-decompiler.com/flash/issues/2078
[#2053]: https://www.free-decompiler.com/flash/issues/2053
[#2133]: https://www.free-decompiler.com/flash/issues/2133
[#2135]: https://www.free-decompiler.com/flash/issues/2135
[#2120]: https://www.free-decompiler.com/flash/issues/2120
[#1130]: https://www.free-decompiler.com/flash/issues/1130
[#1220]: https://www.free-decompiler.com/flash/issues/1220
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class TraitClass extends Trait implements TraitWithSlot {

private boolean classInitializerIsEmpty;

private List<Integer> frameTraitNames = new ArrayList<>();
private List<String> frameTraitNames = new ArrayList<>();

@Override
public void delete(ABC abc, boolean d) {
Expand Down Expand Up @@ -338,14 +338,14 @@ public void convert(AbcIndexing abcIndex, Trait parent, ConvertData convertData,
if (callProp.arguments.get(i) instanceof IntegerValueAVM2Item) {
if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) {
GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1);
frameTraitNames.add(abc.constants.getMultinameId(lex.propertyName, false));
frameTraitNames.add(lex.propertyName.getName(abc.constants, new ArrayList<>(), false, true));
} else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) {
GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1);
if (getProp.object instanceof ThisAVM2Item) {
if (getProp.propertyName instanceof FullMultinameAVM2Item) {
FullMultinameAVM2Item framePropName = (FullMultinameAVM2Item) getProp.propertyName;
int multinameIndex = framePropName.multinameIndex;
frameTraitNames.add(multinameIndex);
frameTraitNames.add(abc.constants.getMultiname(multinameIndex).getName(abc.constants, new ArrayList<>(), false, true));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public Void call() throws InterruptedException {
}
}

public GraphTextWriter toString(AbcIndexing abcIndex, Class[] traitTypes, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, List<Integer> ignoredTraitNames, boolean insideInterface) throws InterruptedException {
public GraphTextWriter toString(AbcIndexing abcIndex, Class[] traitTypes, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, List<String> ignoredTraitNames, boolean insideInterface) throws InterruptedException {

List<Trait> ordered = new ArrayList<>(traits);
loopi:
Expand Down Expand Up @@ -227,7 +227,7 @@ public GraphTextWriter toString(AbcIndexing abcIndex, Class[] traitTypes, Trait
if (!trait.isVisible(isStatic, abc)) {
continue;
}
if (ignoredTraitNames.contains(trait.name_index)) {
if (ignoredTraitNames.contains(trait.getName(abc).getName(abc.constants, new ArrayList<>(), false, false))) {
continue;
}
writer.newLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2916,7 +2916,7 @@ private static Map<Integer, String> getFrameScriptsFromPack(AbcIndexing abcIndex
callStack.add(constructorBody);
constructorBody.convert(callStack, abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, constructorMethodIndex, pack.scriptIndex, classIndex, abc, null, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, new NulWriter(), new ArrayList<>(), new Traits(), true, new HashSet<>());

Map<Integer, Multiname> frameToTraitMultiname = new HashMap<>();
Map<Integer, String> frameToTraitName = new HashMap<>();

//find all addFrameScript(xx,this.method) in constructor
/*
Expand Down Expand Up @@ -2946,14 +2946,14 @@ private static Map<Integer, String> getFrameScriptsFromPack(AbcIndexing abcIndex
int frame = frameItem.intValue();
if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) {
GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1);
frameToTraitMultiname.put(frame, lex.propertyName);
frameToTraitName.put(frame, lex.propertyName.getName(abc.constants, new ArrayList<>(), true, false));
} else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) {
GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1);
if (getProp.object instanceof ThisAVM2Item) {
if (getProp.propertyName instanceof FullMultinameAVM2Item) {
FullMultinameAVM2Item framePropName = (FullMultinameAVM2Item) getProp.propertyName;
int multinameIndex = framePropName.multinameIndex;
frameToTraitMultiname.put(frame, abc.constants.getMultiname(multinameIndex));
frameToTraitName.put(frame, abc.constants.getMultiname(multinameIndex).getName(abc.constants, new ArrayList<>(), true, false));
}
}
}
Expand All @@ -2964,18 +2964,18 @@ private static Map<Integer, String> getFrameScriptsFromPack(AbcIndexing abcIndex
}
}
}
Map<Multiname, TraitMethodGetterSetter> multinameToMethodTrait = new HashMap<>();
Map<String, TraitMethodGetterSetter> multinameToMethodTrait = new HashMap<>();
for (Trait trait : instanceInfo.instance_traits.traits) {
if (trait instanceof TraitMethodGetterSetter) {
Multiname m = abc.constants.getMultiname(trait.name_index);
multinameToMethodTrait.put(abc.constants.getMultiname(trait.name_index), (TraitMethodGetterSetter) trait);
multinameToMethodTrait.put(abc.constants.getMultiname(trait.name_index).getName(abc.constants, new ArrayList<>(), true, false), (TraitMethodGetterSetter) trait);
}
}

for (int frame : frameToTraitMultiname.keySet()) {
Multiname multiName = frameToTraitMultiname.get(frame);
if (multinameToMethodTrait.containsKey(multiName)) {
TraitMethodGetterSetter methodTrait = multinameToMethodTrait.get(multiName);
for (int frame : frameToTraitName.keySet()) {
String traitName = frameToTraitName.get(frame);
if (multinameToMethodTrait.containsKey(traitName)) {
TraitMethodGetterSetter methodTrait = multinameToMethodTrait.get(traitName);
int methodIndex = methodTrait.method_info;
MethodBody frameBody = abc.findBody(methodIndex);

Expand Down

0 comments on commit 581e1e0

Please sign in to comment.