mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-16 06:11:54 +00:00
Propagate ABCIndex everywhere
This commit is contained in:
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
|
||||
import com.jpexs.decompiler.flash.action.ActionList;
|
||||
@@ -89,7 +90,7 @@ public class DecompilerPool {
|
||||
return submit(callable);
|
||||
}
|
||||
|
||||
public Future<HighlightedText> submitTask(ScriptPack pack, ScriptDecompiledListener<HighlightedText> listener) {
|
||||
public Future<HighlightedText> submitTask(AbcIndexing abcIndex, ScriptPack pack, ScriptDecompiledListener<HighlightedText> listener) {
|
||||
Callable<HighlightedText> callable = new Callable<HighlightedText>() {
|
||||
@Override
|
||||
public HighlightedText call() throws Exception {
|
||||
@@ -104,7 +105,7 @@ public class DecompilerPool {
|
||||
}
|
||||
boolean parallel = Configuration.parallelSpeedUp.get();
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
pack.toSource(writer, script == null ? null : script.traits.traits, new ConvertData(), ScriptExportMode.AS, parallel, false);
|
||||
pack.toSource(abcIndex, writer, script == null ? null : script.traits.traits, new ConvertData(), ScriptExportMode.AS, parallel, false);
|
||||
|
||||
HighlightedText result = new HighlightedText(writer);
|
||||
Openable openable = pack.getOpenable();
|
||||
@@ -179,8 +180,8 @@ public class DecompilerPool {
|
||||
return null;
|
||||
}
|
||||
|
||||
public HighlightedText decompile(ScriptPack pack) throws InterruptedException {
|
||||
Future<HighlightedText> future = submitTask(pack, null);
|
||||
public HighlightedText decompile(AbcIndexing abcIndex, ScriptPack pack) throws InterruptedException {
|
||||
Future<HighlightedText> future = submitTask(abcIndex, pack, null);
|
||||
|
||||
Openable openable = pack.getOpenable();
|
||||
if (!openableToFutures.containsKey(openable)) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NewArrayAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
@@ -73,6 +74,8 @@ import com.jpexs.decompiler.flash.cache.AS2Cache;
|
||||
import com.jpexs.decompiler.flash.cache.AS3Cache;
|
||||
import com.jpexs.decompiler.flash.cache.ScriptDecompiledListener;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.configuration.CustomConfigurationKeys;
|
||||
import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
@@ -181,6 +184,7 @@ import java.awt.geom.AffineTransform;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -380,6 +384,13 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
private static final DecompilerPool decompilerPool = new DecompilerPool();
|
||||
|
||||
@Internal
|
||||
private AbcIndexing abcIndex;
|
||||
|
||||
private static AbcIndexing playerGlobalAbcIndex;
|
||||
|
||||
private static AbcIndexing airGlobalAbcIndex;
|
||||
|
||||
public static final String AS2_PKG_PREFIX = "__Packages.";
|
||||
|
||||
public static List<String> swfSignatures = Arrays.asList(
|
||||
@@ -396,6 +407,43 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
*/
|
||||
public static final Color ERROR_COLOR = Color.red;
|
||||
|
||||
public static final int LIBRARY_AIR = 0;
|
||||
public static final int LIBRARY_FLASH = 1;
|
||||
|
||||
public static AbcIndexing getPlayerGlobalAbcIndex() {
|
||||
return playerGlobalAbcIndex;
|
||||
}
|
||||
|
||||
public static AbcIndexing getAirGlobalAbcIndex() {
|
||||
return airGlobalAbcIndex;
|
||||
}
|
||||
|
||||
public AbcIndexing getAbcIndex() {
|
||||
return abcIndex;
|
||||
}
|
||||
|
||||
|
||||
public static void initPlayer() throws IOException, InterruptedException {
|
||||
if (playerGlobalAbcIndex == null) {
|
||||
/*if (Configuration.getPlayerSWC() == null) {
|
||||
throw new IOException("Player SWC library not found, please place it to " + Configuration.getFlashLibPath());
|
||||
}*/
|
||||
|
||||
if (Configuration.getPlayerSWC() != null) {
|
||||
SWC swc = new SWC(new FileInputStream(Configuration.getPlayerSWC()));
|
||||
SWF swf = new SWF(swc.getOpenable("library.swf"), true);
|
||||
playerGlobalAbcIndex = new AbcIndexing(swf);
|
||||
}
|
||||
}
|
||||
if (airGlobalAbcIndex == null) {
|
||||
if (Configuration.getAirSWC() != null) {
|
||||
SWC swc = new SWC(new FileInputStream(Configuration.getAirSWC()));
|
||||
SWF swf = new SWF(swc.getOpenable("library.swf"), true);
|
||||
airGlobalAbcIndex = new AbcIndexing(swf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
return charset;
|
||||
}
|
||||
@@ -986,7 +1034,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
byte[] uncompressedData = saveToByteArray();
|
||||
compress(new ByteArrayInputStream(uncompressedData), os, compression, lzmaProperties);
|
||||
}
|
||||
|
||||
|
||||
public void saveTo(OutputStream os, boolean gfx) throws IOException {
|
||||
checkCharset();
|
||||
byte[] uncompressedData = saveToByteArray(gfx);
|
||||
@@ -1413,6 +1461,20 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
|
||||
getASMs(true); // Add scriptNames to ASMs
|
||||
|
||||
boolean air = false;
|
||||
SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(getShortPathTitle());
|
||||
if (conf != null) {
|
||||
if (conf.getCustomData(CustomConfigurationKeys.KEY_LIBRARY, "" + LIBRARY_FLASH).equals("" + LIBRARY_AIR)) {
|
||||
air = true;
|
||||
}
|
||||
}
|
||||
abcIndex = new AbcIndexing(air ? SWF.getAirGlobalAbcIndex() : SWF.getPlayerGlobalAbcIndex());
|
||||
for (Tag tag:tags) {
|
||||
if (tag instanceof ABCContainerTag) {
|
||||
abcIndex.addAbc(((ABCContainerTag)tag).getABC());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveImported(UrlResolver resolver) {
|
||||
@@ -1974,7 +2036,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
} else if (treeItem instanceof AS2Package) {
|
||||
AS2Package as2Package = (AS2Package) treeItem;
|
||||
for (TreeItem subItem : as2Package.subPackages.values()) {
|
||||
if ((subItem instanceof AS2Package) && ((AS2Package)subItem).isDefaultPackage()) {
|
||||
if ((subItem instanceof AS2Package) && ((AS2Package) subItem).isDefaultPackage()) {
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path);
|
||||
} else {
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem));
|
||||
@@ -1998,8 +2060,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
return String.join(File.separator, parts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!exportFileName) {
|
||||
return treeItem.toString();
|
||||
}
|
||||
@@ -2893,7 +2954,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public static void uncache(ScriptPack pack) {
|
||||
if (pack != null) {
|
||||
Openable openable = pack.getOpenable();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC)openable).getSwf();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf();
|
||||
if (swf != null) {
|
||||
swf.as3Cache.remove(pack);
|
||||
}
|
||||
@@ -2925,7 +2986,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public static boolean isCached(ScriptPack pack) {
|
||||
if (pack != null) {
|
||||
Openable openable = pack.getOpenable();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC)openable).getSwf();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf();
|
||||
if (swf != null) {
|
||||
return swf.as3Cache.isCached(pack);
|
||||
}
|
||||
@@ -2959,7 +3020,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public static HighlightedText getFromCache(ScriptPack pack) {
|
||||
if (pack != null) {
|
||||
Openable openable = pack.getOpenable();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC)openable).getSwf();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf();
|
||||
if (swf != null) {
|
||||
return swf.as3Cache.get(pack);
|
||||
}
|
||||
@@ -3020,7 +3081,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
public static HighlightedText getCached(ScriptPack pack) throws InterruptedException {
|
||||
Openable openable = pack.getOpenable();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC)openable).getSwf();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf();
|
||||
HighlightedText res;
|
||||
if (swf != null) {
|
||||
res = swf.as3Cache.get(pack);
|
||||
@@ -3029,7 +3090,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
}
|
||||
|
||||
return decompilerPool.decompile(pack);
|
||||
return decompilerPool.decompile(swf.abcIndex, pack);
|
||||
}
|
||||
|
||||
public static Future<HighlightedText> getCachedFuture(ASMSource src, ActionList actions, ScriptDecompiledListener<HighlightedText> listener) throws InterruptedException {
|
||||
@@ -3051,7 +3112,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
public static Future<HighlightedText> getCachedFuture(ScriptPack pack, ScriptDecompiledListener<HighlightedText> listener) throws InterruptedException {
|
||||
Openable openable = pack.getOpenable();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC)openable).getSwf();
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf();
|
||||
HighlightedText res;
|
||||
if (swf != null) {
|
||||
res = swf.as3Cache.get(pack);
|
||||
@@ -3064,7 +3125,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
}
|
||||
|
||||
return decompilerPool.submitTask(pack, listener);
|
||||
return decompilerPool.submitTask(swf.abcIndex, pack, listener);
|
||||
}
|
||||
|
||||
public DecompilerPool getDecompilerPool() {
|
||||
@@ -3975,7 +4036,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
int mi = ((TraitMethodGetterSetter) t).method_info;
|
||||
try {
|
||||
documentPack.abc.findBody(mi).convert(new ConvertData(), "??", ScriptExportMode.AS, true, mi, documentPack.scriptIndex, cindex, documentPack.abc, t, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
documentPack.abc.findBody(mi).convert(abcIndex, new ConvertData(), "??", ScriptExportMode.AS, true, mi, documentPack.scriptIndex, cindex, documentPack.abc, t, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
List<GraphTargetItem> infos = documentPack.abc.findBody(mi).convertedItems;
|
||||
if (!infos.isEmpty()) {
|
||||
if (infos.get(0) instanceof IfItem) {
|
||||
@@ -4051,7 +4112,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
if (tr instanceof TraitClass) {
|
||||
int ci = ((TraitClass) tr).class_info;
|
||||
int cinit = p.abc.class_info.get(ci).cinit_index;
|
||||
p.abc.findBody(cinit).convert(new ConvertData(), "??", ScriptExportMode.AS, true, cinit, p.scriptIndex, cindex, p.abc, t, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
p.abc.findBody(cinit).convert(abcIndex, new ConvertData(), "??", ScriptExportMode.AS, true, cinit, p.scriptIndex, cindex, p.abc, t, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
List<GraphTargetItem> cinitBody = p.abc.findBody(cinit).convertedItems;
|
||||
for (GraphTargetItem cit : cinitBody) {
|
||||
if (cit instanceof SetPropertyAVM2Item) {
|
||||
@@ -4172,5 +4233,5 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
@Override
|
||||
public OpenableList getOpenableList() {
|
||||
return openableList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.CodeStats;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
@@ -53,6 +54,8 @@ public class AVM2LocalData extends BaseLocalData {
|
||||
public MethodBody methodBody;
|
||||
|
||||
public ABC abc;
|
||||
|
||||
public AbcIndexing abcIndex;
|
||||
|
||||
public HashMap<Integer, String> localRegNames;
|
||||
|
||||
@@ -141,6 +144,7 @@ public class AVM2LocalData extends BaseLocalData {
|
||||
scopeStack = localData.scopeStack;
|
||||
methodBody = localData.methodBody;
|
||||
abc = localData.abc;
|
||||
abcIndex = localData.abcIndex;
|
||||
localRegNames = localData.localRegNames;
|
||||
fullyQualifiedNames = localData.fullyQualifiedNames;
|
||||
parsedExceptions = localData.parsedExceptions;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.debug.DebugFileIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.debug.DebugIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.debug.DebugLineIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
@@ -176,7 +177,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
return packageName.equals("") ? scriptName : packageName + "." + scriptName;
|
||||
}*/
|
||||
public void convert(final NulWriter writer, final List<Trait> traits, final ConvertData convertData, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
|
||||
public void convert(AbcIndexing abcIndex, final NulWriter writer, final List<Trait> traits, final ConvertData convertData, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
|
||||
|
||||
int sinit_index = abc.script_info.get(scriptIndex).init_index;
|
||||
int sinit_bodyIndex = abc.findBodyIndex(sinit_index);
|
||||
@@ -190,7 +191,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
ts.add(abc.script_info.get(scriptIndex).traits);
|
||||
writer.mark();
|
||||
abc.bodies.get(sinit_bodyIndex).convert(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<>());
|
||||
abc.bodies.get(sinit_bodyIndex).convert(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();
|
||||
|
||||
}
|
||||
@@ -199,14 +200,14 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Multiname name = trait.getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
trait.convertPackaged(null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
trait.convertPackaged(abcIndex, null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
} else {
|
||||
trait.convert(null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
trait.convert(abcIndex, null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void appendTo(GraphTextWriter writer, List<Trait> traits, ConvertData convertData, ScriptExportMode exportMode, boolean parallel) throws InterruptedException {
|
||||
private void appendTo(AbcIndexing abcIndex, GraphTextWriter writer, List<Trait> traits, ConvertData convertData, ScriptExportMode exportMode, boolean parallel) throws InterruptedException {
|
||||
boolean first = true;
|
||||
//script initializer
|
||||
int script_init = abc.script_info.get(scriptIndex).init_index;
|
||||
@@ -219,7 +220,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
if (exportMode != ScriptExportMode.AS_METHOD_STUBS) {
|
||||
if (!scriptInitializerIsEmpty) {
|
||||
writer.startBlock();
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/.scriptinitializer", exportMode, abc, null, writer, new ArrayList<>(), new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).toString(abcIndex, path +/*packageName +*/ "/.scriptinitializer", exportMode, abc, null, writer, new ArrayList<>(), new HashSet<>());
|
||||
writer.endBlock();
|
||||
} else {
|
||||
writer.append(" ");
|
||||
@@ -248,9 +249,9 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Multiname name = trait.getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
trait.toStringPackaged(null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
trait.toStringPackaged(abcIndex, null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
} else {
|
||||
trait.toString(null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
trait.toString(abcIndex, null, convertData, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<>(), parallel);
|
||||
}
|
||||
if (!(trait instanceof TraitClass)) {
|
||||
writer.endTrait();
|
||||
@@ -259,14 +260,14 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
}
|
||||
|
||||
public void toSource(GraphTextWriter writer, final List<Trait> traits, final ConvertData convertData, final ScriptExportMode exportMode, final boolean parallel, boolean ignoreFrameScripts) throws InterruptedException {
|
||||
public void toSource(AbcIndexing abcIndex, GraphTextWriter writer, final List<Trait> traits, final ConvertData convertData, final ScriptExportMode exportMode, final boolean parallel, boolean ignoreFrameScripts) throws InterruptedException {
|
||||
writer.suspendMeasure();
|
||||
int timeout = Configuration.decompilationTimeoutFile.get();
|
||||
try {
|
||||
CancellableWorker.call(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
convert(new NulWriter(), traits, convertData, exportMode, parallel);
|
||||
convert(abcIndex, new NulWriter(), traits, convertData, exportMode, parallel);
|
||||
return null;
|
||||
}
|
||||
}, timeout, TimeUnit.SECONDS);
|
||||
@@ -297,10 +298,10 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
writer.continueMeasure();
|
||||
|
||||
appendTo(writer, traits, convertData, exportMode, parallel);
|
||||
appendTo(abcIndex, writer, traits, convertData, exportMode, parallel);
|
||||
}
|
||||
|
||||
public File export(File file, ScriptExportSettings exportSettings, boolean parallel) throws IOException, InterruptedException {
|
||||
public File export(AbcIndexing abcIndex, File file, ScriptExportSettings exportSettings, boolean parallel) throws IOException, InterruptedException {
|
||||
if (!exportSettings.singleFile) {
|
||||
if (file.exists() && !Configuration.overwriteExistingFiles.get()) {
|
||||
return file;
|
||||
@@ -315,7 +316,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
FileTextWriter writer2 = exportSettings.singleFile ? exportSettings.singleFileWriter : writer;
|
||||
ConvertData convertData = new ConvertData();
|
||||
convertData.ignoreFrameScripts = exportSettings.ignoreFrameScripts;
|
||||
toSource(writer2, abc.script_info.get(scriptIndex).traits.traits, convertData, exportSettings.mode, parallel, exportSettings.ignoreFrameScripts);
|
||||
toSource(abcIndex, writer2, abc.script_info.get(scriptIndex).traits.traits, convertData, exportSettings.mode, parallel, exportSettings.ignoreFrameScripts);
|
||||
} catch (FileNotFoundException ex) {
|
||||
logger.log(Level.SEVERE, "The file path is probably too long", ex);
|
||||
}
|
||||
|
||||
@@ -271,6 +271,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.DeclarationAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForEachInAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForInAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.AssignedValue;
|
||||
@@ -2126,7 +2127,7 @@ public class AVM2Code implements Cloneable {
|
||||
}*/
|
||||
}
|
||||
|
||||
public List<GraphTargetItem> toGraphTargetItems(boolean thisHasDefaultToPrimitive, ConvertData convertData, String path, int methodIndex, boolean isStatic, int scriptIndex, int classIndex, ABC abc, MethodBody body, HashMap<Integer, String> localRegNames, ScopeStack scopeStack, int initializerType, List<DottedChain> fullyQualifiedNames, List<Traits> initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) throws InterruptedException {
|
||||
public List<GraphTargetItem> toGraphTargetItems(AbcIndexing abcIndex, boolean thisHasDefaultToPrimitive, ConvertData convertData, String path, int methodIndex, boolean isStatic, int scriptIndex, int classIndex, ABC abc, MethodBody body, HashMap<Integer, String> localRegNames, ScopeStack scopeStack, int initializerType, List<DottedChain> fullyQualifiedNames, List<Traits> initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) throws InterruptedException {
|
||||
initToSource();
|
||||
List<GraphTargetItem> list;
|
||||
HashMap<Integer, GraphTargetItem> localRegs = new HashMap<>();
|
||||
@@ -2137,7 +2138,7 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
|
||||
//try {
|
||||
list = AVM2Graph.translateViaGraph(path, this, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, staticOperation, localRegAssigmentIps, refs, thisHasDefaultToPrimitive);
|
||||
list = AVM2Graph.translateViaGraph(abcIndex, path, this, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, staticOperation, localRegAssigmentIps, refs, thisHasDefaultToPrimitive);
|
||||
|
||||
if (initTraits != null) {
|
||||
loopi:
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CodeStats {
|
||||
if (stats.stackpos > ms) {
|
||||
ms = stats.stackpos;
|
||||
}
|
||||
writer.appendNoHilight(i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(writer, LocalData.create(abc, null, fullyQualifiedNames, new HashSet<>()))).newLine();
|
||||
writer.appendNoHilight(i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(writer, LocalData.create(null, abc, null, fullyQualifiedNames, new HashSet<>()))).newLine();
|
||||
i++;
|
||||
}
|
||||
return writer;
|
||||
|
||||
@@ -83,6 +83,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForEachInAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForInAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.TryAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
@@ -146,6 +147,8 @@ public class AVM2Graph extends Graph {
|
||||
private final ABC abc;
|
||||
|
||||
private final MethodBody body;
|
||||
|
||||
private final AbcIndexing abcIndex;
|
||||
|
||||
private final Logger logger = Logger.getLogger(AVM2Graph.class.getName());
|
||||
|
||||
@@ -167,11 +170,12 @@ public class AVM2Graph extends Graph {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public AVM2Graph(AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
|
||||
public AVM2Graph(AbcIndexing abcIndex, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
|
||||
super(new AVM2GraphSource(code, isStatic, scriptIndex, classIndex, localRegs, scopeStack, abc, body, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs), getExceptionEntries(body));
|
||||
this.avm2code = code;
|
||||
this.abc = abc;
|
||||
this.body = body;
|
||||
this.abcIndex = abcIndex;
|
||||
/*heads = makeGraph(code, new ArrayList<GraphPart>(), body);
|
||||
this.code = code;
|
||||
this.abc = abc;
|
||||
@@ -629,8 +633,8 @@ public class AVM2Graph extends Graph {
|
||||
return setLocalPosToGetLocalPos;
|
||||
}
|
||||
|
||||
public static List<GraphTargetItem> translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs, boolean thisHasDefaultToPrimitive) throws InterruptedException {
|
||||
AVM2Graph g = new AVM2Graph(code, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs);
|
||||
public static List<GraphTargetItem> translateViaGraph(AbcIndexing abcIndex, String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs, boolean thisHasDefaultToPrimitive) throws InterruptedException {
|
||||
AVM2Graph g = new AVM2Graph(abcIndex, code, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs);
|
||||
|
||||
AVM2LocalData localData = new AVM2LocalData();
|
||||
localData.thisHasDefaultToPrimitive = thisHasDefaultToPrimitive;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class NewClassIns extends InstructionDefinition {
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) throws InterruptedException {
|
||||
int clsIndex = ins.operands[0];
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
stack.pop().toString(writer, LocalData.create(localData.abc, localData.localRegNames, localData.fullyQualifiedNames, new HashSet<>()));
|
||||
stack.pop().toString(writer, LocalData.create(localData.abcIndex, localData.abc, localData.localRegNames, localData.fullyQualifiedNames, new HashSet<>()));
|
||||
String baseType = writer.toString();
|
||||
ABC abc = localData.abc;
|
||||
stack.push(new UnparsedAVM2Item(ins, localData.lineStartInstruction, "§§newclass(" + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.getConstants(), localData.fullyQualifiedNames, false, true) + "," + baseType + ")"));
|
||||
|
||||
@@ -92,13 +92,13 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
public boolean isTopLevel(String tname, ABC abc, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames, Set<Integer> seenMethods) throws InterruptedException {
|
||||
String cname;
|
||||
if (name != null) {
|
||||
cname = name.toString(LocalData.create(abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
cname = name.toString(LocalData.create(null, abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
} else {
|
||||
cname = (abc.constants.getMultiname(multinameIndex).getName(abc.constants, fullyQualifiedNames, true, true));
|
||||
}
|
||||
String cns = "";
|
||||
if (namespace != null) {
|
||||
cns = namespace.toString(LocalData.create(abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
cns = namespace.toString(LocalData.create(null, abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
} else {
|
||||
Namespace ns = abc.constants.getMultiname(multinameIndex).getNamespace(abc.constants);
|
||||
if ((ns != null) && (ns.name_index != 0)) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
@@ -93,8 +94,8 @@ public class NewFunctionAVM2Item extends AVM2Item {
|
||||
abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames);
|
||||
writer.startBlock();
|
||||
if (body != null) {
|
||||
body.convert(new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, new ScopeStack(), 0, new NulWriter(), fullyQualifiedNames, null, false, new HashSet<>(localData.seenMethods));
|
||||
body.toString(path + "/inner", ScriptExportMode.AS, abc, null, writer, fullyQualifiedNames, new HashSet<>(localData.seenMethods));
|
||||
body.convert(localData.abcIndex, new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, new ScopeStack(), 0, new NulWriter(), fullyQualifiedNames, null, false, new HashSet<>(localData.seenMethods));
|
||||
body.toString(localData.abcIndex, path + "/inner", ScriptExportMode.AS, abc, null, writer, fullyQualifiedNames, new HashSet<>(localData.seenMethods));
|
||||
}
|
||||
writer.endBlock();
|
||||
writer.endMethod();
|
||||
|
||||
@@ -1314,7 +1314,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
initt.add(ci.abc.class_info.get(ci.index).static_traits);
|
||||
|
||||
try {
|
||||
pcinit.convert(d, "-", ScriptExportMode.AS, true, mi, -1, ci.index, ci.abc, null, new ScopeStack(), GraphTextWriter.TRAIT_CLASS_INITIALIZER, new NulWriter(), new ArrayList<>(), initt, false, new HashSet<>());
|
||||
pcinit.convert(null, d, "-", ScriptExportMode.AS, true, mi, -1, ci.index, ci.abc, null, new ScopeStack(), GraphTextWriter.TRAIT_CLASS_INITIALIZER, new NulWriter(), new ArrayList<>(), initt, false, new HashSet<>());
|
||||
//FIXME! Add skinparts from _skinParts attribute of parent class!!!
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(AVM2SourceGenerator.class.getName()).log(Level.SEVERE, "Getting parent skinparts interrupted", ex);
|
||||
|
||||
@@ -149,9 +149,7 @@ public class ActionScript3Parser {
|
||||
|
||||
// private final AbcIndexing otherABCs;
|
||||
//private static final List<ABC> playerABCs = new ArrayList<>();
|
||||
private static AbcIndexing playerGlobalAbcIndex;
|
||||
|
||||
private static AbcIndexing airGlobalAbcIndex;
|
||||
|
||||
private long uniqId() {
|
||||
uniqLast++;
|
||||
@@ -2602,9 +2600,9 @@ public class ActionScript3Parser {
|
||||
}
|
||||
|
||||
public ActionScript3Parser(ABC abc, List<ABC> otherAbcs, boolean air) throws IOException, InterruptedException {
|
||||
initPlayer();
|
||||
SWF.initPlayer();
|
||||
|
||||
abcIndex = new AbcIndexing(air ? airGlobalAbcIndex : playerGlobalAbcIndex);
|
||||
abcIndex = new AbcIndexing(air ? SWF.getAirGlobalAbcIndex() : SWF.getPlayerGlobalAbcIndex());
|
||||
for (ABC a : otherAbcs) {
|
||||
abcIndex.addAbc(a);
|
||||
}
|
||||
@@ -2612,29 +2610,11 @@ public class ActionScript3Parser {
|
||||
abcIndex.addAbc(abc);
|
||||
}
|
||||
|
||||
private static void initPlayer() throws IOException, InterruptedException {
|
||||
if (playerGlobalAbcIndex == null) {
|
||||
if (Configuration.getPlayerSWC() == null) {
|
||||
throw new IOException("Player SWC library not found, please place it to " + Configuration.getFlashLibPath());
|
||||
}
|
||||
|
||||
SWC swc = new SWC(new FileInputStream(Configuration.getPlayerSWC()));
|
||||
SWF swf = new SWF(swc.getOpenable("library.swf"), true);
|
||||
playerGlobalAbcIndex = new AbcIndexing(swf);
|
||||
}
|
||||
if (airGlobalAbcIndex == null) {
|
||||
if (Configuration.getAirSWC() == null) {
|
||||
return;
|
||||
}
|
||||
SWC swc = new SWC(new FileInputStream(Configuration.getAirSWC()));
|
||||
SWF swf = new SWF(swc.getOpenable("library.swf"), true);
|
||||
airGlobalAbcIndex = new AbcIndexing(swf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void compile(String src, ABC abc, List<ABC> otherABCs, String fileName, int classPos, int scriptIndex, boolean air) throws AVM2ParseException, IOException, InterruptedException, CompilationException {
|
||||
//List<ABC> parABCs = new ArrayList<>();
|
||||
initPlayer();
|
||||
SWF.initPlayer();
|
||||
ActionScript3Parser parser = new ActionScript3Parser(abc, otherABCs, air);
|
||||
boolean success = false;
|
||||
ABC originalAbc = ((ABCContainerTag) ((Tag) abc.parentTag).cloneTag()).getABC();
|
||||
@@ -2659,7 +2639,7 @@ public class ActionScript3Parser {
|
||||
public static void compile(SWF swf, String src, String dst, int classPos, int scriptIndex, boolean air) {
|
||||
System.err.println("WARNING: AS3 compiler is not finished yet. This is only used for debuggging!");
|
||||
try {
|
||||
initPlayer();
|
||||
SWF.initPlayer();
|
||||
ABC abc = new ABC(null);
|
||||
ActionScript3Parser parser = new ActionScript3Parser(abc, new ArrayList<>(), air);
|
||||
parser.addScript(new String(Helper.readFile(src), Utf8Helper.charset), src, classPos, scriptIndex);
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.CodeStats;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.DeobfuscationLevel;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
@@ -286,7 +287,7 @@ public final class MethodBody implements Cloneable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void convert(final ConvertData convertData, final String path, ScriptExportMode exportMode, final boolean isStatic, final int methodIndex, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ScopeStack scopeStack, final int initializerType, final NulWriter writer, final List<DottedChain> fullyQualifiedNames, final List<Traits> initTraits, boolean firstLevel, Set<Integer> seenMethods) throws InterruptedException {
|
||||
public void convert(AbcIndexing abcIndex, final ConvertData convertData, final String path, ScriptExportMode exportMode, final boolean isStatic, final int methodIndex, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ScopeStack scopeStack, final int initializerType, final NulWriter writer, final List<DottedChain> fullyQualifiedNames, final List<Traits> initTraits, boolean firstLevel, Set<Integer> seenMethods) throws InterruptedException {
|
||||
seenMethods.add(this.method_info);
|
||||
if (debugMode) {
|
||||
System.err.println("Decompiling " + path);
|
||||
@@ -309,10 +310,10 @@ public final class MethodBody implements Cloneable {
|
||||
HashMap<Integer, String> localRegNames = getLocalRegNames(abc);
|
||||
List<GraphTargetItem> convertedItems1;
|
||||
try (Statistics s = new Statistics("AVM2Code.toGraphTargetItems")) {
|
||||
convertedItems1 = converted.getCode().toGraphTargetItems(convertData.thisHasDefaultToPrimitive, convertData, path, methodIndex, isStatic, scriptIndex, classIndex, abc, converted, localRegNames, scopeStack, initializerType, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<>(), converted.getCode().visitCode(converted));
|
||||
convertedItems1 = converted.getCode().toGraphTargetItems(abcIndex, convertData.thisHasDefaultToPrimitive, convertData, path, methodIndex, isStatic, scriptIndex, classIndex, abc, converted, localRegNames, scopeStack, initializerType, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<>(), converted.getCode().visitCode(converted));
|
||||
}
|
||||
try (Statistics s = new Statistics("Graph.graphToString")) {
|
||||
Graph.graphToString(convertedItems1, writer, LocalData.create(abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
Graph.graphToString(convertedItems1, writer, LocalData.create(abcIndex, abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
}
|
||||
convertedItems = convertedItems1;
|
||||
}
|
||||
@@ -344,7 +345,7 @@ public final class MethodBody implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public GraphTextWriter toString(final String path, ScriptExportMode exportMode, final ABC abc, final Trait trait, final GraphTextWriter writer, final List<DottedChain> fullyQualifiedNames, Set<Integer> seenMethods) throws InterruptedException {
|
||||
public GraphTextWriter toString(AbcIndexing abcIndex, final String path, ScriptExportMode exportMode, final ABC abc, final Trait trait, final GraphTextWriter writer, final List<DottedChain> fullyQualifiedNames, Set<Integer> seenMethods) throws InterruptedException {
|
||||
seenMethods.add(method_info);
|
||||
|
||||
if (exportMode != ScriptExportMode.AS) {
|
||||
@@ -369,7 +370,7 @@ public final class MethodBody implements Cloneable {
|
||||
writer.appendNoHilight(this.method_info);
|
||||
writer.newLine();
|
||||
}
|
||||
Graph.graphToString(convertedItems, writer, LocalData.create(abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
Graph.graphToString(convertedItems, writer, LocalData.create(abcIndex, abc, localRegNames, fullyQualifiedNames, seenMethods));
|
||||
//writer.endMethod();
|
||||
} else if (convertException instanceof TimeoutException) {
|
||||
// exception was logged in convert method
|
||||
@@ -419,14 +420,14 @@ public final class MethodBody implements Cloneable {
|
||||
return body;
|
||||
}
|
||||
|
||||
public String toSource(int scriptIndex, Set<Integer> seenMethods) {
|
||||
public String toSource(AbcIndexing abcIndex, int scriptIndex, Set<Integer> seenMethods) {
|
||||
ConvertData convertData = new ConvertData();
|
||||
convertData.deobfuscationMode = 0;
|
||||
try {
|
||||
convert(convertData, "", ScriptExportMode.AS, false, method_info, 0, 0, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, seenMethods);
|
||||
convert(abcIndex, convertData, "", ScriptExportMode.AS, false, method_info, 0, 0, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, seenMethods);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
writer.indent().indent().indent();
|
||||
toString("", ScriptExportMode.AS, abc, null, writer, new ArrayList<>(), seenMethods);
|
||||
toString(abcIndex, "", ScriptExportMode.AS, abc, null, writer, new ArrayList<>(), seenMethods);
|
||||
writer.unindent().unindent().unindent();
|
||||
return writer.toString();
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NameValuePair;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
@@ -362,12 +363,12 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
return abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public GraphTextWriter toString(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
writer.appendNoHilight(abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata));
|
||||
return writer;
|
||||
}
|
||||
|
||||
public void convert(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
}
|
||||
|
||||
public abstract GraphTextWriter convertTraitHeader(ABC abc, GraphTextWriter writer);
|
||||
@@ -438,7 +439,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public GraphTextWriter toStringPackaged(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
public GraphTextWriter toStringPackaged(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) throws InterruptedException {
|
||||
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
String nsname = ns.getName(abc.constants).toPrintableString(true);
|
||||
@@ -447,28 +448,28 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
writer.appendNoHilight(" " + nsname); //assume not null name
|
||||
}
|
||||
writer.startBlock();
|
||||
toString(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
toString(abcIndex, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
writer.endBlock();
|
||||
writer.newLine();
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
public void convertPackaged(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
public void convertPackaged(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) throws InterruptedException {
|
||||
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
String nsname = ns.getName(abc.constants).toPrintableString(true);
|
||||
convert(parent, convertData, path + nsname, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
convert(abcIndex, parent, convertData, path + nsname, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
}
|
||||
}
|
||||
|
||||
public GraphTextWriter toStringHeader(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
toString(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
toString(null, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
return writer;
|
||||
}
|
||||
|
||||
public void convertHeader(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
convert(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
convert(null, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
}
|
||||
|
||||
public final Multiname getName(ABC abc) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
Multiname instanceInfoMultiname = instanceInfo.getName(abc.constants);
|
||||
@@ -136,7 +136,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
|
||||
//static variables & constants
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
classInfo.static_traits.toString(new Class[]{TraitSlotConst.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, new ArrayList<>());
|
||||
classInfo.static_traits.toString(abcIndex, new Class[]{TraitSlotConst.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, new ArrayList<>());
|
||||
|
||||
//static initializer
|
||||
int bodyIndex = abc.findBodyIndex(classInfo.cinit_index);
|
||||
@@ -146,7 +146,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
if (exportMode != ScriptExportMode.AS_METHOD_STUBS) {
|
||||
if (!classInitializerIsEmpty) {
|
||||
writer.startBlock();
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).toString(abcIndex, path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
writer.endBlock();
|
||||
} else {
|
||||
//Note: There must be trait/method highlight even if the initializer is empty to TraitList in GUI to work correctly
|
||||
@@ -164,7 +164,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
//instance variables
|
||||
instanceInfo.instance_traits.toString(new Class[]{TraitSlotConst.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, new ArrayList<>());
|
||||
instanceInfo.instance_traits.toString(abcIndex, new Class[]{TraitSlotConst.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, new ArrayList<>());
|
||||
|
||||
//instance initializer - constructor
|
||||
if (!instanceInfo.isInterface()) {
|
||||
@@ -194,7 +194,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
writer.appendNoHilight(")").startBlock();
|
||||
if (exportMode != ScriptExportMode.AS_METHOD_STUBS) {
|
||||
if (body != null) {
|
||||
body.toString(path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
body.toString(abcIndex, path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,10 +204,10 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
//static methods
|
||||
classInfo.static_traits.toString(new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, new ArrayList<>());
|
||||
classInfo.static_traits.toString(abcIndex, new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, new ArrayList<>());
|
||||
|
||||
//instance methods
|
||||
instanceInfo.instance_traits.toString(new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, convertData.ignoreFrameScripts ? frameTraitNames : new ArrayList<>());
|
||||
instanceInfo.instance_traits.toString(abcIndex, new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, convertData.ignoreFrameScripts ? frameTraitNames : new ArrayList<>());
|
||||
|
||||
writer.endBlock(); // class
|
||||
writer.endClass();
|
||||
@@ -216,7 +216,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
|
||||
fullyQualifiedNames = new ArrayList<>();
|
||||
|
||||
@@ -244,7 +244,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
writer.mark();
|
||||
List<Traits> ts = new ArrayList<>();
|
||||
ts.add(classInfo.static_traits);
|
||||
abc.bodies.get(bodyIndex).convert(convertData, path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, true, classInfo.cinit_index, scriptIndex, class_info, abc, this, new ScopeStack(), GraphTextWriter.TRAIT_CLASS_INITIALIZER, writer, fullyQualifiedNames, ts, true, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).convert(abcIndex, convertData, path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, true, classInfo.cinit_index, scriptIndex, class_info, abc, this, new ScopeStack(), GraphTextWriter.TRAIT_CLASS_INITIALIZER, writer, fullyQualifiedNames, ts, true, new HashSet<>());
|
||||
classInitializerIsEmpty = !writer.getMark();
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
List<Traits> ts = new ArrayList<>();
|
||||
ts.add(instanceInfo.instance_traits);
|
||||
MethodBody constructorBody = abc.bodies.get(bodyIndex);
|
||||
constructorBody.convert(convertData, path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, false, instanceInfo.iinit_index, scriptIndex, class_info, abc, this, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, writer, fullyQualifiedNames, ts, true, new HashSet<>());
|
||||
constructorBody.convert(abcIndex, convertData, path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, false, instanceInfo.iinit_index, scriptIndex, class_info, abc, this, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, writer, fullyQualifiedNames, ts, true, new HashSet<>());
|
||||
|
||||
if (convertData.ignoreFrameScripts) {
|
||||
//find all addFrameScript(xx,this.method) in constructor
|
||||
@@ -310,9 +310,9 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
//static variables,constants & methods
|
||||
classInfo.static_traits.convert(this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
classInfo.static_traits.convert(abcIndex, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
instanceInfo.instance_traits.convert(this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
instanceInfo.instance_traits.convert(abcIndex, this, convertData, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
@@ -80,7 +81,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
writeImportsUsages(scriptIndex, classIndex, false, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
getMetaData(parent, convertData, abc, writer);
|
||||
writer.startMethod(method_info);
|
||||
@@ -89,7 +90,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
writer.startBlock();
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).toString(abcIndex,path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
}
|
||||
writer.endBlock();
|
||||
|
||||
@@ -99,14 +100,14 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
fullyQualifiedNames = new ArrayList<>();
|
||||
writeImportsUsages(scriptIndex, classIndex, false, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
writer.startMethod(method_info);
|
||||
convertHeader(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).convert(convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).convert(abcIndex, convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true, new HashSet<>());
|
||||
}
|
||||
writer.endMethod();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
@@ -106,7 +107,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
if (classIndex < 0) {
|
||||
writeImportsUsages(scriptIndex, classIndex, isStatic, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
}
|
||||
@@ -117,7 +118,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
if (exportMode != ScriptExportMode.AS_METHOD_STUBS) {
|
||||
if (!(classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1)) {
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).convert(convertData, path, exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).convert(abcIndex, convertData, path, exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true, new HashSet<>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +126,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
|
||||
if (classIndex < 0) {
|
||||
writeImportsUsages(scriptIndex, classIndex, isStatic, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
@@ -144,7 +145,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
convertTraitHeader(abc, writer);
|
||||
}
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).toString(path, exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).toString(abcIndex, path, exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
}
|
||||
} else {
|
||||
String retTypeRaw = abc.method_info.get(method_info).getReturnTypeRaw(abc.constants, fullyQualifiedNames);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types.traits;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.AssignedValue;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
@@ -108,7 +109,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public void getValueStr(ScriptExportMode exportMode, Trait parent, ConvertData convertData, GraphTextWriter writer, ABC abc, List<DottedChain> fullyQualifiedNames) throws InterruptedException {
|
||||
public void getValueStr(AbcIndexing abcIndex, ScriptExportMode exportMode, Trait parent, ConvertData convertData, GraphTextWriter writer, ABC abc, List<DottedChain> fullyQualifiedNames) throws InterruptedException {
|
||||
if (convertData.assignedValues.containsKey(this)) {
|
||||
|
||||
AssignedValue assignment = convertData.assignedValues.get(this);
|
||||
@@ -122,7 +123,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
writer.newLine();
|
||||
}
|
||||
if (exportMode != ScriptExportMode.AS_METHOD_STUBS) {
|
||||
assignment.value.toString(writer, LocalData.create(abc, new HashMap<>(), fullyQualifiedNames, new HashSet<>()));
|
||||
assignment.value.toString(writer, LocalData.create(abcIndex, abc, new HashMap<>(), fullyQualifiedNames, new HashSet<>()));
|
||||
}
|
||||
writer.endMethod();
|
||||
writer.endTrait();
|
||||
@@ -144,7 +145,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
getMetaData(parent, convertData, abc, writer);
|
||||
Multiname n = getName(abc);
|
||||
boolean showModifier = true;
|
||||
@@ -162,22 +163,22 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
if (convertData.assignedValues.containsKey(this)) {
|
||||
GraphTargetItem val = convertData.assignedValues.get(this).value;
|
||||
if (val instanceof NewFunctionAVM2Item) {
|
||||
return val.toString(writer, LocalData.create(abc, new HashMap<>(), fullyQualifiedNames, new HashSet<>()));
|
||||
return val.toString(writer, LocalData.create(abcIndex, abc, new HashMap<>(), fullyQualifiedNames, new HashSet<>()));
|
||||
}
|
||||
}
|
||||
getNameStr(writer, abc, fullyQualifiedNames);
|
||||
if (value_kind != 0 || convertData.assignedValues.containsKey(this)) {
|
||||
writer.appendNoHilight(" = ");
|
||||
getValueStr(exportMode, parent, convertData, writer, abc, fullyQualifiedNames);
|
||||
getValueStr(abcIndex, exportMode, parent, convertData, writer, abc, fullyQualifiedNames);
|
||||
}
|
||||
return writer.appendNoHilight(";").newLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
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) throws InterruptedException {
|
||||
getNameStr(writer, abc, fullyQualifiedNames);
|
||||
if (value_kind != 0 || convertData.assignedValues.containsKey(this)) {
|
||||
getValueStr(exportMode, parent, convertData, writer, abc, fullyQualifiedNames);
|
||||
getValueStr(abcIndex,exportMode, parent, convertData, writer, abc, fullyQualifiedNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
@@ -130,8 +131,10 @@ public class Traits implements Cloneable, Serializable {
|
||||
Trait parent;
|
||||
|
||||
ConvertData convertData;
|
||||
|
||||
AbcIndexing abcIndex;
|
||||
|
||||
public TraitConvertTask(Trait trait, Trait parent, ConvertData convertData, boolean makePackages, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, int traitIndex, boolean parallel) {
|
||||
public TraitConvertTask(AbcIndexing abcIndex, Trait trait, Trait parent, ConvertData convertData, boolean makePackages, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, int traitIndex, boolean parallel) {
|
||||
this.trait = trait;
|
||||
this.parent = parent;
|
||||
this.convertData = convertData;
|
||||
@@ -146,20 +149,21 @@ public class Traits implements Cloneable, Serializable {
|
||||
this.fullyQualifiedNames = fullyQualifiedNames;
|
||||
this.traitIndex = traitIndex;
|
||||
this.parallel = parallel;
|
||||
this.abcIndex = abcIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call() throws InterruptedException {
|
||||
if (makePackages) {
|
||||
trait.convertPackaged(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
trait.convertPackaged(abcIndex, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
} else {
|
||||
trait.convert(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
trait.convert(abcIndex, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public GraphTextWriter toString(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) 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) throws InterruptedException {
|
||||
|
||||
List<Trait> ordered = new ArrayList<>(traits);
|
||||
loopi:
|
||||
@@ -231,9 +235,9 @@ public class Traits implements Cloneable, Serializable {
|
||||
writer.startTrait(h);
|
||||
}
|
||||
if (makePackages) {
|
||||
trait.toStringPackaged(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
trait.toStringPackaged(abcIndex, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
} else {
|
||||
trait.toString(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
trait.toString(abcIndex, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
}
|
||||
if (trait instanceof TraitClass) {
|
||||
writer.endClass();
|
||||
@@ -244,10 +248,10 @@ public class Traits implements Cloneable, Serializable {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public void convert(Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
public void convert(AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
if (!parallel || traits.size() < 2) {
|
||||
for (int t = 0; t < traits.size(); t++) {
|
||||
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, convertData, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, t, parallel);
|
||||
TraitConvertTask task = new TraitConvertTask(abcIndex, traits.get(t), parent, convertData, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, t, parallel);
|
||||
task.call();
|
||||
}
|
||||
} else {
|
||||
@@ -257,7 +261,7 @@ public class Traits implements Cloneable, Serializable {
|
||||
futureResults = new ArrayList<>();
|
||||
for (int t = 0; t < traits.size(); t++) {
|
||||
// each convert task needs a separate NulWriter, because they are executed parallel
|
||||
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, convertData, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, new NulWriter(), fullyQualifiedNames, t, parallel);
|
||||
TraitConvertTask task = new TraitConvertTask(abcIndex, traits.get(t), parent, convertData, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, new NulWriter(), fullyQualifiedNames, t, parallel);
|
||||
Future<Void> future = executor.submit(task);
|
||||
futureResults.add(future);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.DeclarationAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
@@ -102,11 +103,11 @@ public class AS3ScriptExporter {
|
||||
}
|
||||
}
|
||||
|
||||
private String handleMxmlMethod(Map<String, String> namespaces, ScriptPack pack, int cindex, TraitMethodGetterSetter t) {
|
||||
private String handleMxmlMethod(AbcIndexing abcIndex, Map<String, String> namespaces, ScriptPack pack, int cindex, TraitMethodGetterSetter t) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
int method = t.method_info;
|
||||
try {
|
||||
pack.abc.findBody(method).convert(new ConvertData(), "??", ScriptExportMode.AS, false, method, pack.scriptIndex, cindex, pack.abc, t, new ScopeStack(), 0/*?*/, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
pack.abc.findBody(method).convert(abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, method, pack.scriptIndex, cindex, pack.abc, t, new ScopeStack(), 0/*?*/, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
|
||||
List<GraphTargetItem> ci = pack.abc.findBody(method).convertedItems;
|
||||
if (!ci.isEmpty()) {
|
||||
@@ -135,7 +136,7 @@ public class AS3ScriptExporter {
|
||||
int name2 = ((FullMultinameAVM2Item) cap.propertyName).multinameIndex;
|
||||
for (Trait ct : pack.abc.instance_info.get(cindex).instance_traits.traits) {
|
||||
if (ct.name_index == name2 && (ct instanceof TraitMethodGetterSetter)) {
|
||||
tagContent.append(handleMxmlMethod(namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
tagContent.append(handleMxmlMethod(abcIndex,namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,11 +176,11 @@ public class AS3ScriptExporter {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
private String handleMxmlArrMethod(Map<String, String> namespaces, ScriptPack pack, int cindex, TraitMethodGetterSetter t) {
|
||||
private String handleMxmlArrMethod(AbcIndexing abcIndex, Map<String, String> namespaces, ScriptPack pack, int cindex, TraitMethodGetterSetter t) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
int method = t.method_info;
|
||||
try {
|
||||
pack.abc.findBody(method).convert(new ConvertData(), "??", ScriptExportMode.AS, false, method, pack.scriptIndex, cindex, pack.abc, t, new ScopeStack(), 0/*?*/, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>()/*??*/);
|
||||
pack.abc.findBody(method).convert(abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, method, pack.scriptIndex, cindex, pack.abc, t, new ScopeStack(), 0/*?*/, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>()/*??*/);
|
||||
|
||||
List<GraphTargetItem> ci = pack.abc.findBody(method).convertedItems;
|
||||
if (!ci.isEmpty() && (ci.get(0) instanceof DeclarationAVM2Item)) {
|
||||
@@ -195,7 +196,7 @@ public class AS3ScriptExporter {
|
||||
int name = ((FullMultinameAVM2Item) cp.propertyName).multinameIndex;
|
||||
for (Trait ct : pack.abc.instance_info.get(cindex).instance_traits.traits) {
|
||||
if (ct.name_index == name && (ct instanceof TraitMethodGetterSetter)) {
|
||||
out.append(handleMxmlMethod(namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
out.append(handleMxmlMethod(abcIndex, namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,7 +249,7 @@ public class AS3ScriptExporter {
|
||||
return ns + ":" + parentName;
|
||||
}
|
||||
|
||||
private String generateMxml(ScriptPack pack) {
|
||||
private String generateMxml(AbcIndexing abcIndex, ScriptPack pack) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
StringBuilder tagProp = new StringBuilder();
|
||||
StringBuilder tagContent = new StringBuilder();
|
||||
@@ -270,7 +271,7 @@ public class AS3ScriptExporter {
|
||||
int iinit = pack.abc.instance_info.get(cindex).iinit_index;
|
||||
|
||||
try {
|
||||
pack.abc.findBody(iinit).convert(new ConvertData(), "??", ScriptExportMode.AS, false, iinit, pack.scriptIndex, cindex, pack.abc, t, new ScopeStack(), 0/*?*/, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
pack.abc.findBody(iinit).convert(abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, iinit, pack.scriptIndex, cindex, pack.abc, t, new ScopeStack(), 0/*?*/, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
List<GraphTargetItem> iinitBody = pack.abc.findBody(iinit).convertedItems;
|
||||
for (GraphTargetItem it : iinitBody) {
|
||||
if (it instanceof InitPropertyAVM2Item) {
|
||||
@@ -286,7 +287,7 @@ public class AS3ScriptExporter {
|
||||
int name = ((FullMultinameAVM2Item) cp.propertyName).multinameIndex;
|
||||
for (Trait ct : pack.abc.instance_info.get(cindex).instance_traits.traits) {
|
||||
if (ct.name_index == name && (ct instanceof TraitMethodGetterSetter)) {
|
||||
tagContent.append(handleMxmlMethod(namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
tagContent.append(handleMxmlMethod(abcIndex, namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
}
|
||||
}
|
||||
tagContent.append("</").append(subtagName).append(">");
|
||||
@@ -304,7 +305,7 @@ public class AS3ScriptExporter {
|
||||
int name = ((FullMultinameAVM2Item) gp.propertyName).multinameIndex;
|
||||
for (Trait ct : pack.abc.instance_info.get(cindex).instance_traits.traits) {
|
||||
if (ct.name_index == name && (ct instanceof TraitMethodGetterSetter)) {
|
||||
tagContent.append(handleMxmlArrMethod(namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
tagContent.append(handleMxmlArrMethod(abcIndex, namespaces, pack, cindex, (TraitMethodGetterSetter) ct));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,7 +369,7 @@ public class AS3ScriptExporter {
|
||||
if (flexClass != null && item.getClassPath().toRawString().equals(flexClass)) {
|
||||
File file = item.getExportFile(outdir, ".mxml");
|
||||
String filePath = file.getPath();
|
||||
String mxml = generateMxml(item);
|
||||
String mxml = generateMxml(swf.getAbcIndex(), item);
|
||||
if (mxml != null) {
|
||||
Helper.writeFile(filePath, Utf8Helper.getBytes(mxml));
|
||||
files.add(filePath.toLowerCase());
|
||||
@@ -396,7 +397,7 @@ public class AS3ScriptExporter {
|
||||
files.add(filePath.toLowerCase());
|
||||
}
|
||||
|
||||
tasks.add(new ExportPackTask(handler, cnt++, packs.size(), item.getClassPath(), item, file, exportSettings, parallel, evl));
|
||||
tasks.add(new ExportPackTask(swf.getAbcIndex(), handler, cnt++, packs.size(), item.getClassPath(), item, file, exportSettings, parallel, evl));
|
||||
}
|
||||
|
||||
if (!parallel || tasks.size() < 2) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.RetryTask;
|
||||
import com.jpexs.decompiler.flash.RunnableIOExResult;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.File;
|
||||
@@ -55,8 +56,10 @@ public class ExportPackTask implements Callable<File> {
|
||||
long stopTime;
|
||||
|
||||
EventListener eventListener;
|
||||
|
||||
AbcIndexing abcIndex;
|
||||
|
||||
public ExportPackTask(AbortRetryIgnoreHandler handler, int index, int count, ClassPath path, ScriptPack pack, File file, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) {
|
||||
public ExportPackTask(AbcIndexing abcIndex, AbortRetryIgnoreHandler handler, int index, int count, ClassPath path, ScriptPack pack, File file, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) {
|
||||
this.pack = pack;
|
||||
this.file = file;
|
||||
this.exportSettings = exportSettings;
|
||||
@@ -66,6 +69,7 @@ public class ExportPackTask implements Callable<File> {
|
||||
this.parallel = parallel;
|
||||
this.handler = handler;
|
||||
this.eventListener = evl;
|
||||
this.abcIndex = abcIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +78,7 @@ public class ExportPackTask implements Callable<File> {
|
||||
@Override
|
||||
public void run() throws IOException, InterruptedException {
|
||||
startTime = System.currentTimeMillis();
|
||||
this.result = pack.export(file, exportSettings, parallel);
|
||||
this.result = pack.export(abcIndex, file, exportSettings, parallel);
|
||||
stopTime = System.currentTimeMillis();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.exporters.script;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.action.ActionGraph;
|
||||
import com.jpexs.decompiler.flash.action.ActionList;
|
||||
@@ -85,8 +86,8 @@ public class PcodeGraphVizExporter {
|
||||
export(gr, writer);
|
||||
}
|
||||
|
||||
public void exportAs3(ABC abc, MethodBody body, GraphTextWriter writer) throws InterruptedException {
|
||||
AVM2Graph gr = new AVM2Graph(body.getCode(), abc, body, false, -1, -1, new HashMap<>(), new ScopeStack(), new HashMap<>(), new ArrayList<>(), new HashMap<>(), body.getCode().visitCode(body));
|
||||
public void exportAs3(AbcIndexing abcIndex, ABC abc, MethodBody body, GraphTextWriter writer) throws InterruptedException {
|
||||
AVM2Graph gr = new AVM2Graph(abcIndex, body.getCode(), abc, body, false, -1, -1, new HashMap<>(), new ScopeStack(), new HashMap<>(), new ArrayList<>(), new HashMap<>(), body.getCode().visitCode(body));
|
||||
export(gr, writer);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.types.ConvertData;
|
||||
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
@@ -1715,7 +1716,7 @@ public class XFLConverter {
|
||||
continue;
|
||||
}
|
||||
final ScriptPack spriteScriptPack = characterScriptPacks.containsKey(sprite.spriteId) ? characterScriptPacks.get(sprite.spriteId) : null;
|
||||
convertTimeline(sprite.spriteId, nonLibraryShapes, backgroundColor, tags, sprite.getTags(), characters, "Symbol " + symbol.getCharacterId(), flaVersion, files, symbolStr, spriteScriptPack);
|
||||
convertTimeline(swf.getAbcIndex(), sprite.spriteId, nonLibraryShapes, backgroundColor, tags, sprite.getTags(), characters, "Symbol " + symbol.getCharacterId(), flaVersion, files, symbolStr, spriteScriptPack);
|
||||
|
||||
} else if (symbol instanceof ShapeTag) {
|
||||
itemIcon = "1";
|
||||
@@ -2616,7 +2617,7 @@ public class XFLConverter {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static Map<Integer, String> getFrameScriptsFromPack(ScriptPack pack) {
|
||||
private static Map<Integer, String> getFrameScriptsFromPack(AbcIndexing abcIndex, ScriptPack pack) {
|
||||
Map<Integer, String> ret = new HashMap<>();
|
||||
int classIndex = getPackMainClassId(pack);
|
||||
if (classIndex > -1) {
|
||||
@@ -2625,7 +2626,7 @@ public class XFLConverter {
|
||||
int constructorMethodIndex = instanceInfo.iinit_index;
|
||||
MethodBody constructorBody = abc.findBody(constructorMethodIndex);
|
||||
try {
|
||||
constructorBody.convert(new ConvertData(), "??", ScriptExportMode.AS, false, constructorMethodIndex, pack.scriptIndex, classIndex, abc, null, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
constructorBody.convert(abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, constructorMethodIndex, pack.scriptIndex, classIndex, abc, null, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
|
||||
Map<Integer, Multiname> frameToTraitMultiname = new HashMap<>();
|
||||
|
||||
@@ -2691,9 +2692,9 @@ public class XFLConverter {
|
||||
MethodBody frameBody = abc.findBody(methodIndex);
|
||||
|
||||
StringBuilder scriptBuilder = new StringBuilder();
|
||||
frameBody.convert(new ConvertData(), "??", ScriptExportMode.AS, false, methodIndex, pack.scriptIndex, classIndex, abc, methodTrait, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
frameBody.convert(abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, methodIndex, pack.scriptIndex, classIndex, abc, methodTrait, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>());
|
||||
StringBuilderTextWriter writer = new StringBuilderTextWriter(Configuration.getCodeFormatting(), scriptBuilder);
|
||||
frameBody.toString("??", ScriptExportMode.AS, abc, methodTrait, writer, new ArrayList<>(), new HashSet<>());
|
||||
frameBody.toString(abcIndex, "??", ScriptExportMode.AS, abc, methodTrait, writer, new ArrayList<>(), new HashSet<>());
|
||||
|
||||
String script = scriptBuilder.toString();
|
||||
ret.put(frame, script);
|
||||
@@ -2707,7 +2708,7 @@ public class XFLConverter {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean convertActionScriptLayer(int spriteId, ReadOnlyTagList tags, ReadOnlyTagList timeLineTags, String backgroundColor, XFLXmlWriter writer, ScriptPack scriptPack) throws XMLStreamException {
|
||||
private boolean convertActionScriptLayer(AbcIndexing abcIndex, int spriteId, ReadOnlyTagList tags, ReadOnlyTagList timeLineTags, String backgroundColor, XFLXmlWriter writer, ScriptPack scriptPack) throws XMLStreamException {
|
||||
boolean hasScript = false;
|
||||
|
||||
String script = "";
|
||||
@@ -2728,7 +2729,7 @@ public class XFLConverter {
|
||||
Map<Integer, String> frameToScriptMap = new HashMap<>();
|
||||
|
||||
if (scriptPack != null) {
|
||||
frameToScriptMap = getFrameScriptsFromPack(scriptPack);
|
||||
frameToScriptMap = getFrameScriptsFromPack(abcIndex, scriptPack);
|
||||
}
|
||||
|
||||
for (Tag t : timeLineTags) {
|
||||
@@ -2943,12 +2944,12 @@ public class XFLConverter {
|
||||
return outlineColor.toHexRGB();
|
||||
}
|
||||
|
||||
private void convertTimeline(int spriteId, List<Integer> nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, ReadOnlyTagList timelineTags, HashMap<Integer, CharacterTag> characters, String name, FLAVersion flaVersion, HashMap<String, byte[]> files, XFLXmlWriter writer, ScriptPack scriptPack) throws XMLStreamException {
|
||||
private void convertTimeline(AbcIndexing abcIndex, int spriteId, List<Integer> nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, ReadOnlyTagList timelineTags, HashMap<Integer, CharacterTag> characters, String name, FLAVersion flaVersion, HashMap<String, byte[]> files, XFLXmlWriter writer, ScriptPack scriptPack) throws XMLStreamException {
|
||||
writer.writeStartElement("DOMTimeline", new String[]{"name", name});
|
||||
writer.writeStartElement("layers");
|
||||
|
||||
boolean hasLabel = convertLabelsLayer(spriteId, tags, timelineTags, backgroundColor, writer);
|
||||
boolean hasScript = convertActionScriptLayer(spriteId, tags, timelineTags, backgroundColor, writer, scriptPack);
|
||||
boolean hasScript = convertActionScriptLayer(abcIndex, spriteId, tags, timelineTags, backgroundColor, writer, scriptPack);
|
||||
|
||||
int index = 0;
|
||||
|
||||
@@ -3612,7 +3613,7 @@ public class XFLConverter {
|
||||
|
||||
domDocument.writeStartElement("timelines");
|
||||
ScriptPack documentScriptPack = characterScriptPacks.containsKey(0) ? characterScriptPacks.get(0) : null;
|
||||
convertTimeline(0, nonLibraryShapes, backgroundColor, swf.getTags(), swf.getTags(), characters, "Scene 1", flaVersion, files, domDocument, documentScriptPack);
|
||||
convertTimeline(swf.getAbcIndex(), 0, nonLibraryShapes, backgroundColor, swf.getTags(), swf.getTags(), characters, "Scene 1", flaVersion, files, domDocument, documentScriptPack);
|
||||
domDocument.writeEndElement();
|
||||
|
||||
if (hasAmfMetadata) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import java.util.HashMap;
|
||||
@@ -36,6 +37,8 @@ public class LocalData {
|
||||
public ConstantPool constants;
|
||||
|
||||
public AVM2ConstantPool constantsAvm2;
|
||||
|
||||
public AbcIndexing abcIndex;
|
||||
|
||||
public HashMap<Integer, String> localRegNames;
|
||||
|
||||
@@ -51,13 +54,14 @@ public class LocalData {
|
||||
return localData;
|
||||
}
|
||||
|
||||
public static LocalData create(ABC abc, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames, Set<Integer> seenMethods) {
|
||||
public static LocalData create(AbcIndexing abcIndex, ABC abc, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames, Set<Integer> seenMethods) {
|
||||
LocalData localData = new LocalData();
|
||||
localData.abc = abc;
|
||||
localData.constantsAvm2 = abc.constants;
|
||||
localData.localRegNames = localRegNames;
|
||||
localData.fullyQualifiedNames = fullyQualifiedNames;
|
||||
localData.seenMethods = seenMethods;
|
||||
localData.abcIndex = abcIndex;
|
||||
return localData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user