mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-02 12:44:19 +00:00
Display compound scripts in separate folders,
display script initializer separately. Show imported classes.
This commit is contained in:
@@ -112,7 +112,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
this.path = path;
|
||||
this.allABCs = allAbcs;
|
||||
}
|
||||
|
||||
|
||||
public DottedChain getPathPackage() {
|
||||
DottedChain packageName = DottedChain.TOPLEVEL;
|
||||
for (int t : traitIndices) {
|
||||
@@ -182,8 +182,8 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
List<MethodBody> callStack = new ArrayList<>();
|
||||
callStack.add(abc.bodies.get(sinit_bodyIndex));
|
||||
abc.bodies.get(sinit_bodyIndex).convert(callStack, abcIndex, convertData, path +/*packageName +*/ "/.scriptinitializer", exportMode, true, sinit_index, scriptIndex, -1, abc, null, new ScopeStack(), GraphTextWriter.TRAIT_SCRIPT_INITIALIZER, writer, new ArrayList<>(), ts, true, new HashSet<>());
|
||||
scriptInitializerIsEmpty = !writer.getMark();
|
||||
|
||||
scriptInitializerIsEmpty = !writer.getMark();
|
||||
|
||||
}
|
||||
ScopeStack scopeStack = new ScopeStack();
|
||||
scopeStack.push(new GlobalAVM2Item(null, null));
|
||||
@@ -206,7 +206,17 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
//script initializer
|
||||
int script_init = abc.script_info.get(scriptIndex).init_index;
|
||||
int bodyIndex = abc.findBodyIndex(script_init);
|
||||
if (bodyIndex != -1 && Configuration.enableScriptInitializerDisplay.get()) {
|
||||
|
||||
|
||||
if (!isSimple && traitIndices.isEmpty()) {
|
||||
for (Trait t : abc.script_info.get(scriptIndex).traits.traits) {
|
||||
String fullName = t.getName(abc).getNameWithNamespace(abc.constants, false).toPrintableString(true);
|
||||
writer.appendNoHilight("include(\"" + fullName.replace(".", "/") + ".as\");").newLine();
|
||||
}
|
||||
writer.newLine();
|
||||
}
|
||||
|
||||
if (bodyIndex != -1 && (isSimple || traitIndices.isEmpty())) { // && Configuration.enableScriptInitializerDisplay.get()) {
|
||||
//Note: There must be trait/method highlight even if the initializer is empty to TraitList in GUI to work correctly
|
||||
//TODO: handle this better in GUI(?)
|
||||
writer.startTrait(GraphTextWriter.TRAIT_SCRIPT_INITIALIZER);
|
||||
@@ -228,8 +238,6 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
writer.newLine();
|
||||
}
|
||||
first = false;
|
||||
} else {
|
||||
//"/*classInitializer*/";
|
||||
}
|
||||
|
||||
for (int t : traitIndices) {
|
||||
|
||||
@@ -103,6 +103,21 @@ public class ScriptInfo {
|
||||
otherTraits.add(j);
|
||||
}
|
||||
}
|
||||
|
||||
int publicTraitsCount = 0;
|
||||
for (int j = 0; j < traits.traits.size(); j++) {
|
||||
Trait t = traits.traits.get(j);
|
||||
Multiname name = t.getName(abc);
|
||||
int nskind = name.getSimpleNamespaceKind(abc.constants);
|
||||
if ((nskind == Namespace.KIND_PACKAGE_INTERNAL)
|
||||
|| (nskind == Namespace.KIND_PACKAGE)) {
|
||||
publicTraitsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSimple = publicTraitsCount == 1;
|
||||
|
||||
|
||||
for (int j = 0; j < traits.traits.size(); j++) {
|
||||
Trait t = traits.traits.get(j);
|
||||
Multiname name = t.getName(abc);
|
||||
@@ -121,14 +136,14 @@ public class ScriptInfo {
|
||||
}
|
||||
|
||||
if (packagePrefix == null || packageName.toPrintableString(true).startsWith(packagePrefix)) {
|
||||
|
||||
ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix);
|
||||
ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices));
|
||||
ScriptPack pack = new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices);
|
||||
pack.isSimple = isSimple;
|
||||
ret.add(pack);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret.size() == 1) {
|
||||
ret.get(0).isSimple = true;
|
||||
}
|
||||
}
|
||||
if (ret.isEmpty() && !otherTraits.isEmpty()) { //no public/package internal traits to determine common pack name
|
||||
//make each trait separate pack
|
||||
for (int traitIndex : otherTraits) {
|
||||
@@ -145,6 +160,9 @@ public class ScriptInfo {
|
||||
ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix);
|
||||
ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices));
|
||||
}
|
||||
}
|
||||
if (!isSimple) {
|
||||
ret.add(new ScriptPack(new ClassPath(DottedChain.EMPTY, "script_"+scriptIndex, ""), abc, allAbcs, scriptIndex, new ArrayList<>()));
|
||||
}
|
||||
if (packagePrefix == null) {
|
||||
cachedPacks = new ArrayList<>(ret);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.timeline;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem;
|
||||
@@ -47,15 +48,33 @@ public class AS3Package extends AS3ClassTreeItem {
|
||||
private boolean flat;
|
||||
|
||||
private boolean defaultPackage;
|
||||
|
||||
private Integer compoundScriptIndex;
|
||||
|
||||
private ABC abc;
|
||||
|
||||
private ScriptPack compoundInitializerPack = null;
|
||||
|
||||
public AS3Package(String packageName, Openable openable, boolean flat, boolean defaultPackage) {
|
||||
public AS3Package(String packageName, Openable openable, boolean flat, boolean defaultPackage, ABC abc, Integer compoundScriptIndex) {
|
||||
super(packageName, "", null);
|
||||
this.flat = flat;
|
||||
this.openable = openable;
|
||||
this.packageName = packageName;
|
||||
this.defaultPackage = defaultPackage;
|
||||
this.compoundScriptIndex = compoundScriptIndex;
|
||||
this.abc = abc;
|
||||
}
|
||||
|
||||
public void setCompoundInitializerPack(ScriptPack compoundInitializerPack) {
|
||||
this.compoundInitializerPack = compoundInitializerPack;
|
||||
}
|
||||
|
||||
public ScriptPack getCompoundInitializerPack() {
|
||||
return compoundInitializerPack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isDefaultPackage() {
|
||||
return defaultPackage;
|
||||
}
|
||||
@@ -63,9 +82,21 @@ public class AS3Package extends AS3ClassTreeItem {
|
||||
public boolean isFlat() {
|
||||
return flat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isCompoundScript() {
|
||||
return compoundScriptIndex != null;
|
||||
}
|
||||
|
||||
public Integer getCompoundScriptIndex() {
|
||||
return compoundScriptIndex;
|
||||
}
|
||||
|
||||
public ABC getAbc() {
|
||||
return abc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Openable getOpenable() {
|
||||
return openable;
|
||||
|
||||
@@ -248,6 +248,19 @@ public class DottedChain implements Serializable, Comparable<DottedChain> {
|
||||
newParts.add(new PathPart(name, attribute, namespaceSuffix));
|
||||
return new DottedChain(newParts, false);
|
||||
}
|
||||
|
||||
public DottedChain preAdd(String name, String namespaceSuffix) {
|
||||
return preAdd(false, name, namespaceSuffix);
|
||||
}
|
||||
|
||||
public DottedChain preAdd(boolean attribute, String name, String namespaceSuffix) {
|
||||
if (name == null) {
|
||||
return new DottedChain(this);
|
||||
}
|
||||
List<PathPart> newParts = new ArrayList<>(parts);
|
||||
newParts.add(0, new PathPart(name, attribute, namespaceSuffix));
|
||||
return new DottedChain(newParts, false);
|
||||
}
|
||||
|
||||
protected String toString(boolean as3, boolean raw, boolean withSuffix) {
|
||||
if (isNull) {
|
||||
|
||||
Reference in New Issue
Block a user