mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-17 07:32:29 +00:00
Fixed: AS3 - displaying imports of class parent chain
Fixed: AS3 - imports for script traits
This commit is contained in:
@@ -353,7 +353,16 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
if (isSimple) {
|
||||
ignorePackage = getPathPackage();
|
||||
}
|
||||
Trait.writeImports(null, script_init, abcIndex, scriptIndex, -1, true, abc, writer, ignorePackage, fullyQualifiedNames);
|
||||
List<Trait> importTraits = new ArrayList<>();
|
||||
for (int t : traitIndices) {
|
||||
Trait trait = traits.get(t);
|
||||
|
||||
if (!(trait instanceof TraitSlotConst)) {
|
||||
continue;
|
||||
}
|
||||
importTraits.add(trait);
|
||||
}
|
||||
Trait.writeImports(importTraits, script_init, abcIndex, scriptIndex, -1, true, abc, writer, ignorePackage, fullyQualifiedNames);
|
||||
first = true;
|
||||
|
||||
//Slot const last
|
||||
|
||||
@@ -368,7 +368,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
* @return True if its not empty
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public static boolean writeImports(Trait trait, int methodIndex, AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, ABC abc, GraphTextWriter writer, DottedChain ignorePackage, List<DottedChain> fullyQualifiedNames) throws InterruptedException {
|
||||
public static boolean writeImports(List<Trait> traits, int methodIndex, AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, ABC abc, GraphTextWriter writer, DottedChain ignorePackage, List<DottedChain> fullyQualifiedNames) throws InterruptedException {
|
||||
|
||||
List<String> namesInThisPackage = new ArrayList<>();
|
||||
for (ABCContainerTag tag : abc.getAbcTags()) {
|
||||
@@ -398,7 +398,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
Reference<Integer> numberContextRef = new Reference<>(null);
|
||||
|
||||
|
||||
if (trait != null) {
|
||||
for (Trait trait : traits) {
|
||||
Multiname multiname = trait.getName(abc);
|
||||
int nskind = multiname.getSimpleNamespaceKind(abc.constants);
|
||||
if (nskind == Namespace.KIND_NAMESPACE) {
|
||||
@@ -407,7 +407,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
trait.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNs, abc, dependencies, ignorePackage, new ArrayList<>(), uses, numberContextRef);
|
||||
}
|
||||
if (methodIndex != -1) {
|
||||
DependencyParser.parseDependenciesFromMethodInfo(abcIndex, trait, scriptIndex, classIndex, isStatic, customNs, abc, methodIndex, dependencies, ignorePackage, fullyQualifiedNames, new ArrayList<>(), uses, numberContextRef);
|
||||
DependencyParser.parseDependenciesFromMethodInfo(abcIndex, null, scriptIndex, classIndex, isStatic, customNs, abc, methodIndex, dependencies, ignorePackage, fullyQualifiedNames, new ArrayList<>(), uses, numberContextRef);
|
||||
}
|
||||
List<DottedChain> imports = new ArrayList<>();
|
||||
for (Dependency d : dependencies) {
|
||||
|
||||
@@ -234,7 +234,9 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
Reference<Boolean> first = new Reference<>(true);
|
||||
|
||||
if (getName(abc).getNamespace(abc.constants).kind != Namespace.KIND_PACKAGE_INTERNAL) {
|
||||
first.setVal(!writeImports(this, -1, abcIndex, scriptIndex, classIndex, false, abc, writer, packageName, fullyQualifiedNames));
|
||||
List<Trait> traits = new ArrayList<>();
|
||||
traits.add(this);
|
||||
first.setVal(!writeImports(traits, -1, abcIndex, scriptIndex, classIndex, false, abc, writer, packageName, fullyQualifiedNames));
|
||||
}
|
||||
|
||||
String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false, true);
|
||||
|
||||
@@ -161,7 +161,9 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
*/
|
||||
@Override
|
||||
public GraphTextWriter toString(AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, boolean insideInterface) throws InterruptedException {
|
||||
writeImports(this, -1, abcIndex, scriptIndex, classIndex, false, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
List<Trait> traits = new ArrayList<>();
|
||||
traits.add(this);
|
||||
writeImports(traits, -1, abcIndex, scriptIndex, classIndex, false, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
getMetaData(this, convertData, abc, writer);
|
||||
writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false));
|
||||
toStringHeader(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface);
|
||||
@@ -202,7 +204,9 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
@Override
|
||||
public void convert(AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, ScopeStack scopeStack) throws InterruptedException {
|
||||
fullyQualifiedNames = new ArrayList<>();
|
||||
writeImports(this, -1, abcIndex, scriptIndex, classIndex, false, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
List<Trait> traits = new ArrayList<>();
|
||||
traits.add(this);
|
||||
writeImports(traits, -1, abcIndex, scriptIndex, classIndex, false, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false));
|
||||
convertHeader(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
|
||||
@@ -185,7 +185,9 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
@Override
|
||||
public void convert(AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, ScopeStack scopeStack) throws InterruptedException {
|
||||
if (classIndex < 0) {
|
||||
writeImports(this, -1, abcIndex, scriptIndex, classIndex, isStatic, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
List<Trait> traits = new ArrayList<>();
|
||||
traits.add(this);
|
||||
writeImports(traits, -1, abcIndex, scriptIndex, classIndex, isStatic, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
}
|
||||
writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false));
|
||||
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false, true);
|
||||
|
||||
@@ -184,9 +184,33 @@ public class DependencyParser {
|
||||
for (ABCException ex : body.exceptions) {
|
||||
parseDependenciesFromMultiname(abcIndex, ignoredCustom, abc, dependencies, abc.constants.getMultiname(ex.type_index), ignorePackage, fullyQualifiedNames, DependencyType.EXPRESSION /* or signature?*/, uses);
|
||||
}
|
||||
|
||||
boolean hasNewClass = false;
|
||||
|
||||
if (classIndex == -1) {
|
||||
for (int i = 0; i < body.getCode().code.size(); i++) {
|
||||
AVM2Instruction ins = body.getCode().code.get(i);
|
||||
if (ins.definition instanceof NewClassIns) {
|
||||
hasNewClass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean wasNewClass = false;
|
||||
for (int i = 0; i < body.getCode().code.size(); i++) {
|
||||
AVM2Instruction ins = body.getCode().code.get(i);
|
||||
|
||||
|
||||
//Do not parse dependencies from class parent chain
|
||||
if (classIndex == -1 && hasNewClass && !wasNewClass) {
|
||||
|
||||
if (ins.definition instanceof NewClassIns) {
|
||||
wasNewClass = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//Ignore class parents in script initializer
|
||||
if (ins.definition instanceof GetLexIns) {
|
||||
boolean foundNewClass = false;
|
||||
|
||||
Reference in New Issue
Block a user