mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 20:38:08 +00:00
#1308 Search by all P-code files
This commit is contained in:
@@ -20,7 +20,6 @@ import SevenZip.Compression.LZMA.Decoder;
|
||||
import SevenZip.Compression.LZMA.Encoder;
|
||||
import com.jpexs.debugger.flash.SWD;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.CachedDecompilation;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.RenameType;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
@@ -46,7 +45,6 @@ import com.jpexs.decompiler.flash.action.ActionGraphSource;
|
||||
import com.jpexs.decompiler.flash.action.ActionList;
|
||||
import com.jpexs.decompiler.flash.action.ActionListReader;
|
||||
import com.jpexs.decompiler.flash.action.ActionLocalData;
|
||||
import com.jpexs.decompiler.flash.action.CachedScript;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
|
||||
@@ -343,10 +341,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
private final Cache<ASMSource, ActionList> as2PcodeCache = Cache.getInstance(true, true, "as2pcode");
|
||||
|
||||
@Internal
|
||||
private final Cache<ASMSource, CachedScript> as2Cache = Cache.getInstance(true, false, "as2");
|
||||
private final Cache<ASMSource, HighlightedText> as2Cache = Cache.getInstance(true, false, "as2");
|
||||
|
||||
@Internal
|
||||
private final Cache<ScriptPack, CachedDecompilation> as3Cache = Cache.getInstance(true, false, "as3");
|
||||
private final Cache<ScriptPack, HighlightedText> as3Cache = Cache.getInstance(true, false, "as3");
|
||||
|
||||
public static List<String> swfSignatures = Arrays.asList(
|
||||
"FWS", // Uncompressed Flash
|
||||
@@ -2640,7 +2638,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
public static CachedScript getFromCache(ASMSource src) {
|
||||
public static HighlightedText getFromCache(ASMSource src) {
|
||||
SWF swf = src.getSwf();
|
||||
if (swf.as2Cache.contains(src)) {
|
||||
return swf.as2Cache.get(src);
|
||||
@@ -2649,32 +2647,23 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CachedScript getCached(ASMSource src, ActionList actions) throws InterruptedException {
|
||||
public static HighlightedText getCached(ASMSource src, ActionList actions) throws InterruptedException {
|
||||
SWF swf = src.getSwf();
|
||||
if (swf.as2Cache.contains(src)) {
|
||||
return swf.as2Cache.get(src);
|
||||
}
|
||||
|
||||
if (actions == null) {
|
||||
actions = src.getActions();
|
||||
}
|
||||
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
writer.startFunction("!script");
|
||||
Action.actionsToSource(src, actions, src.toString()/*FIXME?*/, writer);
|
||||
src.getActionScriptSource(writer, actions);
|
||||
writer.endFunction();
|
||||
List<Highlighting> hilights = writer.instructionHilights;
|
||||
List<Highlighting> methodHilights = writer.methodHilights;
|
||||
List<Highlighting> classHilights = writer.classHilights;
|
||||
List<Highlighting> specialHilights = writer.specialHilights;
|
||||
|
||||
String srcNoHex = writer.toString();
|
||||
CachedScript res = new CachedScript(srcNoHex, hilights, methodHilights, classHilights, specialHilights);
|
||||
HighlightedText res = new HighlightedText(writer);
|
||||
swf.as2Cache.put(src, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static CachedDecompilation getCached(ScriptPack pack) throws InterruptedException {
|
||||
public static HighlightedText getCached(ScriptPack pack) throws InterruptedException {
|
||||
SWF swf = pack.getSwf();
|
||||
if (swf.as3Cache.contains(pack)) {
|
||||
return swf.as3Cache.get(pack);
|
||||
@@ -2688,8 +2677,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
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);
|
||||
HighlightedText hilightedCode = new HighlightedText(writer);
|
||||
CachedDecompilation res = new CachedDecompilation(hilightedCode);
|
||||
HighlightedText res = new HighlightedText(writer);
|
||||
swf.as3Cache.put(pack, res);
|
||||
|
||||
return res;
|
||||
@@ -2910,8 +2898,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
timelined.setModified(true);
|
||||
timelined.resetTimeline();
|
||||
} else // timeline should be always the swf here
|
||||
{
|
||||
if (removeDependencies) {
|
||||
if (removeDependencies) {
|
||||
removeTagWithDependenciesFromTimeline(tag, timelined.getTimeline());
|
||||
timelined.setModified(true);
|
||||
} else {
|
||||
@@ -2920,7 +2907,6 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
timelined.setModified(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3333,7 +3319,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
try {
|
||||
asms.get(name).getASMSource(ScriptExportMode.PCODE, writer, asms.get(name).getActions());
|
||||
asms.get(name).getASMSource(ScriptExportMode.PCODE, writer, null);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -3399,9 +3385,9 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
for (String name : names) {
|
||||
List<SWD.DebugRegisters> regitems = new ArrayList<>();
|
||||
moduleId++;
|
||||
CachedScript cs;
|
||||
HighlightedText cs;
|
||||
try {
|
||||
cs = SWF.getCached(asms.get(name), asms.get(name).getActions());
|
||||
cs = SWF.getCached(asms.get(name), null);
|
||||
} catch (InterruptedException ex) {
|
||||
return false;
|
||||
}
|
||||
@@ -3411,7 +3397,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
Map<Integer, String> regNames = new HashMap<>();
|
||||
|
||||
for (int pos = 0; pos < txt.length(); pos++) {
|
||||
Highlighting h = Highlighting.searchPos(cs.hilights, pos);
|
||||
Highlighting h = Highlighting.searchPos(cs.getInstructionHighlights(), pos);
|
||||
if (h != null) {
|
||||
|
||||
int firstLineOffset = (int) h.getProperties().firstLineOffset;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2016 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class CachedDecompilation implements Serializable {
|
||||
|
||||
public String text;
|
||||
|
||||
public List<Highlighting> traitHilights;
|
||||
|
||||
public List<Highlighting> classHilights;
|
||||
|
||||
public List<Highlighting> methodHilights;
|
||||
|
||||
public List<Highlighting> instructionHilights;
|
||||
|
||||
public List<Highlighting> specialHilights;
|
||||
|
||||
public List<Highlighting> getInstructionHighlights() {
|
||||
return instructionHilights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getTraitHighlights() {
|
||||
return traitHilights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getMethodHighlights() {
|
||||
return methodHilights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getClassHighlights() {
|
||||
return classHilights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getSpecialHighligths() {
|
||||
return specialHilights;
|
||||
}
|
||||
|
||||
public CachedDecompilation(HighlightedText highlightedText) {
|
||||
this.text = highlightedText.text;
|
||||
this.traitHilights = highlightedText.traitHilights;
|
||||
this.classHilights = highlightedText.classHilights;
|
||||
this.methodHilights = highlightedText.methodHilights;
|
||||
this.instructionHilights = highlightedText.instructionHilights;
|
||||
this.specialHilights = highlightedText.specialHilights;
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
@@ -337,7 +338,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
|
||||
Set<Integer> lonelyBody = new HashSet<>();
|
||||
try {
|
||||
CachedDecompilation decompiled = SWF.getCached(this);
|
||||
HighlightedText decompiled = SWF.getCached(this);
|
||||
int line = 1;
|
||||
String txt = decompiled.text;
|
||||
txt = txt.replace("\r", "");
|
||||
@@ -345,21 +346,21 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
for (int i = 0; i < txt.length(); i++) {
|
||||
blk:
|
||||
{
|
||||
Highlighting sh = Highlighting.searchPos(decompiled.specialHilights, i);
|
||||
Highlighting sh = Highlighting.searchPos(decompiled.getSpecialHighlights(), i);
|
||||
|
||||
Highlighting cls = Highlighting.searchPos(decompiled.classHilights, i);
|
||||
Highlighting cls = Highlighting.searchPos(decompiled.getClassHighlights(), i);
|
||||
/*if (cls == null) {
|
||||
continue;
|
||||
}*/
|
||||
Highlighting trt = Highlighting.searchPos(decompiled.traitHilights, i);
|
||||
Highlighting trt = Highlighting.searchPos(decompiled.getTraitHighlights(), i);
|
||||
/*if (trt == null) {
|
||||
continue;
|
||||
}*/
|
||||
Highlighting method = Highlighting.searchPos(decompiled.methodHilights, i);
|
||||
Highlighting method = Highlighting.searchPos(decompiled.getMethodHighlights(), i);
|
||||
if (method == null) {
|
||||
break blk;
|
||||
}
|
||||
Highlighting instr = Highlighting.searchPos(decompiled.instructionHilights, i); //h
|
||||
Highlighting instr = Highlighting.searchPos(decompiled.getInstructionHighlights(), i); //h
|
||||
/*if (instr == null) {
|
||||
continue;
|
||||
}*/
|
||||
@@ -531,18 +532,18 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Map<Integer, String> bodyToIdentifier = new HashMap<>();
|
||||
|
||||
try {
|
||||
CachedDecompilation decompiled = SWF.getCached(this);
|
||||
HighlightedText decompiled = SWF.getCached(this);
|
||||
String txt = decompiled.text;
|
||||
txt = txt.replace("\r", "");
|
||||
|
||||
for (int i = 0; i < txt.length(); i++) {
|
||||
blk:
|
||||
{
|
||||
Highlighting sh = Highlighting.searchPos(decompiled.specialHilights, i);
|
||||
Highlighting sh = Highlighting.searchPos(decompiled.getSpecialHighlights(), i);
|
||||
|
||||
Highlighting cls = Highlighting.searchPos(decompiled.classHilights, i);
|
||||
Highlighting trt = Highlighting.searchPos(decompiled.traitHilights, i);
|
||||
Highlighting method = Highlighting.searchPos(decompiled.methodHilights, i);
|
||||
Highlighting cls = Highlighting.searchPos(decompiled.getClassHighlights(), i);
|
||||
Highlighting trt = Highlighting.searchPos(decompiled.getTraitHighlights(), i);
|
||||
Highlighting method = Highlighting.searchPos(decompiled.getMethodHighlights(), i);
|
||||
if (method == null) {
|
||||
break blk;
|
||||
}
|
||||
|
||||
@@ -62,9 +62,7 @@ import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.CodeFormatting;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
@@ -475,23 +473,6 @@ public abstract class Action implements GraphSourceItem {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts list of actions to ASM source
|
||||
*
|
||||
* @param listeners
|
||||
* @param address
|
||||
* @param list List of actions
|
||||
* @param version SWF version
|
||||
* @param exportMode PCode or hex?
|
||||
* @return source ASM
|
||||
*
|
||||
*/
|
||||
public static String actionsToString(List<DisassemblyListener> listeners, long address, ActionList list, int version, ScriptExportMode exportMode) {
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
|
||||
actionsToString(listeners, address, list, version, exportMode, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
private static void informListeners(List<DisassemblyListener> listeners, int pos, int count) {
|
||||
if (pos % INFORM_LISTENER_RESOLUTION == 0) {
|
||||
DisassemblyListener[] listenersArray = listeners.toArray(new DisassemblyListener[listeners.size()]);
|
||||
@@ -855,21 +836,6 @@ public abstract class Action implements GraphSourceItem {
|
||||
return actionsToTree(new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts list of actions to ActionScript source code
|
||||
*
|
||||
* @param asm
|
||||
* @param actions List of actions
|
||||
* @param path
|
||||
* @return source
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public static String actionsToSource(final ASMSource asm, final List<Action> actions, final String path) throws InterruptedException {
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
|
||||
actionsToSource(asm, actions, path, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts list of actions to ActionScript source code
|
||||
*
|
||||
@@ -877,9 +843,10 @@ public abstract class Action implements GraphSourceItem {
|
||||
* @param actions List of actions
|
||||
* @param path
|
||||
* @param writer
|
||||
* @return
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public static void actionsToSource(final ASMSource asm, final List<Action> actions, final String path, GraphTextWriter writer) throws InterruptedException {
|
||||
public static GraphTextWriter actionsToSource(final ASMSource asm, final List<Action> actions, final String path, GraphTextWriter writer) throws InterruptedException {
|
||||
writer.suspendMeasure();
|
||||
List<GraphTargetItem> tree = null;
|
||||
Throwable convertException = null;
|
||||
@@ -932,6 +899,8 @@ public abstract class Action implements GraphSourceItem {
|
||||
if (asm != null) {
|
||||
asm.getActionSourceSuffix(writer);
|
||||
}
|
||||
|
||||
return writer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import static com.jpexs.decompiler.flash.action.Action.actionsToSource;
|
||||
import static com.jpexs.decompiler.flash.action.Action.actionsToString;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionNop;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionStore;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
@@ -26,7 +28,9 @@ import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.CodeFormatting;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -97,7 +101,6 @@ public class ActionList extends ArrayList<Action> {
|
||||
|
||||
public Iterator<Action> getReferencesFor(final Action target) {
|
||||
return new Iterator<Action>() {
|
||||
|
||||
private final Iterator<Action> iterator = ActionList.this.iterator();
|
||||
|
||||
private Action action = getNext();
|
||||
@@ -160,7 +163,6 @@ public class ActionList extends ArrayList<Action> {
|
||||
|
||||
public Iterable<ActionConstantPool> getConstantPools() {
|
||||
return () -> new Iterator<ActionConstantPool>() {
|
||||
|
||||
private final Iterator<Action> iterator = ActionList.this.iterator();
|
||||
|
||||
private ActionConstantPool action = getNext();
|
||||
@@ -197,7 +199,6 @@ public class ActionList extends ArrayList<Action> {
|
||||
|
||||
public Iterable<ActionPush> getPushes() {
|
||||
return () -> new Iterator<ActionPush>() {
|
||||
|
||||
private final Iterator<Action> iterator = ActionList.this.iterator();
|
||||
|
||||
private ActionPush action = getNext();
|
||||
@@ -547,12 +548,16 @@ public class ActionList extends ArrayList<Action> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Action.actionsToString(new ArrayList<>(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
|
||||
actionsToString(new ArrayList<>(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public String toSource() {
|
||||
try {
|
||||
return Action.actionsToSource(null, this, "");
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
|
||||
actionsToSource(null, this, "", writer);
|
||||
return writer.toString();
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ActionList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2016 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class CachedScript implements Serializable {
|
||||
|
||||
public String text;
|
||||
|
||||
public List<Highlighting> hilights;
|
||||
|
||||
public List<Highlighting> methodHilights;
|
||||
|
||||
public List<Highlighting> classHilights;
|
||||
|
||||
public List<Highlighting> specialHilights;
|
||||
|
||||
public CachedScript(String text, List<Highlighting> hilights, List<Highlighting> methodHilights, List<Highlighting> classHilights, List<Highlighting> specialHilights) {
|
||||
this.text = text;
|
||||
this.hilights = hilights;
|
||||
this.methodHilights = methodHilights;
|
||||
this.classHilights = classHilights;
|
||||
this.specialHilights = specialHilights;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.RetryTask;
|
||||
import com.jpexs.decompiler.flash.RunnableIOExResult;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionList;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
@@ -32,7 +33,6 @@ import com.jpexs.helpers.stat.Statistics;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -104,14 +104,15 @@ public class ExportScriptTask implements Callable<File> {
|
||||
asm.getASMSource(exportMode, writer2, null);
|
||||
asm.getActionSourceSuffix(writer2);
|
||||
} else {
|
||||
List<Action> as;
|
||||
ActionList as;
|
||||
try (Statistics s = new Statistics("ASMSource.getActions")) {
|
||||
as = asm.getActions();
|
||||
}
|
||||
|
||||
Action.setActionsAddresses(as, 0);
|
||||
|
||||
try (Statistics s = new Statistics("Action.actionsToSource")) {
|
||||
Action.actionsToSource(asm, as, asm.toString()/*FIXME?*/, writer2);
|
||||
asm.getActionScriptSource(writer2, as);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,47 +30,55 @@ public class HighlightedText implements Serializable {
|
||||
|
||||
public String text;
|
||||
|
||||
public List<Highlighting> traitHilights;
|
||||
private final List<Highlighting> traitHighlights;
|
||||
|
||||
public List<Highlighting> classHilights;
|
||||
private final List<Highlighting> classHighlights;
|
||||
|
||||
public List<Highlighting> methodHilights;
|
||||
private final List<Highlighting> methodHighlights;
|
||||
|
||||
public List<Highlighting> instructionHilights;
|
||||
private final List<Highlighting> instructionHighlights;
|
||||
|
||||
public List<Highlighting> specialHilights;
|
||||
private final List<Highlighting> specialHighlights;
|
||||
|
||||
public List<Highlighting> getTraitHighlights() {
|
||||
return traitHilights;
|
||||
return traitHighlights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getMethodHighlights() {
|
||||
return methodHilights;
|
||||
return methodHighlights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getClassHighlights() {
|
||||
return classHilights;
|
||||
return classHighlights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getSpecialHighligths() {
|
||||
return specialHilights;
|
||||
public List<Highlighting> getInstructionHighlights() {
|
||||
return instructionHighlights;
|
||||
}
|
||||
|
||||
public List<Highlighting> getSpecialHighlights() {
|
||||
return specialHighlights;
|
||||
}
|
||||
|
||||
public HighlightedText(HighlightedTextWriter writer) {
|
||||
this.text = writer.toString();
|
||||
this.traitHilights = writer.traitHilights;
|
||||
this.classHilights = writer.classHilights;
|
||||
this.methodHilights = writer.methodHilights;
|
||||
this.instructionHilights = writer.instructionHilights;
|
||||
this.specialHilights = writer.specialHilights;
|
||||
this.traitHighlights = writer.traitHilights;
|
||||
this.classHighlights = writer.classHilights;
|
||||
this.methodHighlights = writer.methodHilights;
|
||||
this.instructionHighlights = writer.instructionHilights;
|
||||
this.specialHighlights = writer.specialHilights;
|
||||
}
|
||||
|
||||
public HighlightedText() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public HighlightedText(String text) {
|
||||
this.text = text;
|
||||
this.traitHilights = new ArrayList<>();
|
||||
this.classHilights = new ArrayList<>();
|
||||
this.methodHilights = new ArrayList<>();
|
||||
this.instructionHilights = new ArrayList<>();
|
||||
this.specialHilights = new ArrayList<>();
|
||||
this.traitHighlights = new ArrayList<>();
|
||||
this.classHighlights = new ArrayList<>();
|
||||
this.methodHighlights = new ArrayList<>();
|
||||
this.instructionHighlights = new ArrayList<>();
|
||||
this.specialHighlights = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,15 @@ public class DoActionTag extends Tag implements ASMSource {
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getActionScriptSource(GraphTextWriter writer, ActionList actions) throws InterruptedException {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
|
||||
return Action.actionsToSource(this, actions, toString()/*FIXME?*/, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this object contains ASM source
|
||||
*
|
||||
|
||||
@@ -143,6 +143,15 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource {
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getActionScriptSource(GraphTextWriter writer, ActionList actions) throws InterruptedException {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
|
||||
return Action.actionsToSource(this, actions, toString()/*FIXME?*/, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionList getActions() throws InterruptedException {
|
||||
return SWF.getCachedActionList(this, listeners);
|
||||
|
||||
@@ -44,6 +44,16 @@ public interface ASMSource extends Exportable {
|
||||
*/
|
||||
public GraphTextWriter getASMSource(ScriptExportMode exportMode, GraphTextWriter writer, ActionList actions) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Converts actions to ActionScript source
|
||||
*
|
||||
* @param writer
|
||||
* @param actions
|
||||
* @return ASM source
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public GraphTextWriter getActionScriptSource(GraphTextWriter writer, ActionList actions) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Whether or not this object contains ASM source
|
||||
*
|
||||
|
||||
@@ -65,6 +65,15 @@ public class ButtonAction implements ASMSource {
|
||||
return Action.actionsToString(listeners, 0, actions, getSwf().version, exportMode, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getActionScriptSource(GraphTextWriter writer, ActionList actions) throws InterruptedException {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
|
||||
return Action.actionsToSource(this, actions, toString()/*FIXME?*/, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this object contains ASM source
|
||||
*
|
||||
|
||||
@@ -190,6 +190,15 @@ public class BUTTONCONDACTION implements ASMSource, Serializable {
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getActionScriptSource(GraphTextWriter writer, ActionList actions) throws InterruptedException {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
|
||||
return Action.actionsToSource(this, actions, toString()/*FIXME?*/, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this object contains ASM source
|
||||
*
|
||||
|
||||
@@ -192,6 +192,15 @@ public class CLIPACTIONRECORD implements ASMSource, Serializable {
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getActionScriptSource(GraphTextWriter writer, ActionList actions) throws InterruptedException {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
|
||||
return Action.actionsToSource(this, actions, toString()/*FIXME?*/, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this object contains ASM source
|
||||
*
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.amf.amf3.Amf3Value;
|
||||
import com.jpexs.decompiler.flash.amf.amf3.types.ObjectType;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
@@ -1434,7 +1433,7 @@ public class XFLConverter {
|
||||
private static String convertActionScript12(ASMSource as) {
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
try {
|
||||
Action.actionsToSource(as, as.getActions(), as.toString()/*FIXME?*/, writer);
|
||||
as.getActionScriptSource(writer, null);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user