mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 21:30:46 +00:00
Fixed code style
This commit is contained in:
@@ -26,7 +26,7 @@ import java.util.Properties;
|
||||
public class ApplicationInfo {
|
||||
|
||||
public static final String APPLICATION_NAME = "JPEXS Free Flash Decompiler";
|
||||
|
||||
|
||||
public static final String CLI_APPLICATION_NAME = "@|blue JPEXS|@ @|green Free|@ @|red Flash Decompiler|@";
|
||||
|
||||
public static final String SHORT_APPLICATION_NAME = "FFDec";
|
||||
@@ -50,7 +50,7 @@ public class ApplicationInfo {
|
||||
public static boolean nightly = false;
|
||||
|
||||
public static String cliApplicationVerName;
|
||||
|
||||
|
||||
public static String applicationVerName;
|
||||
|
||||
public static String shortApplicationVerName;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DecompilerPool {
|
||||
writer.endFunction();
|
||||
|
||||
writer.finishHilights();
|
||||
|
||||
|
||||
HighlightedText result = new HighlightedText(writer);
|
||||
SWF swf = src.getSwf();
|
||||
if (swf != null) {
|
||||
|
||||
@@ -324,14 +324,13 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
@Internal
|
||||
private volatile Map<Integer, CharacterTag> characters;
|
||||
|
||||
|
||||
@Internal
|
||||
private volatile Map<Integer, CharacterTag> charactersWithImported;
|
||||
|
||||
|
||||
@Internal
|
||||
private volatile Map<CharacterIdTag, Integer> characterToId;
|
||||
|
||||
|
||||
@Internal
|
||||
private volatile Map<Integer, DefineExternalImage2> externalImages2;
|
||||
|
||||
@@ -424,10 +423,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
@Internal
|
||||
private Map<String, Integer> exportNameToCharacter = new HashMap<>();
|
||||
|
||||
|
||||
@Internal
|
||||
private Map<String, Integer> importedNameToCharacter = new HashMap<>();
|
||||
|
||||
|
||||
@Internal
|
||||
private AbcIndexing abcIndex;
|
||||
|
||||
@@ -435,17 +434,16 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
private int numAbcIndexDependencies = 0;
|
||||
|
||||
private volatile Map<String, Map<String, com.jpexs.decompiler.flash.action.as2.Trait>> uninitializedAs2ClassTraits = null;
|
||||
|
||||
|
||||
@Internal
|
||||
private ExporterInfo exporterInfo = null;
|
||||
|
||||
|
||||
@Internal
|
||||
public String debuggerPackage = null;
|
||||
|
||||
|
||||
private Map<Integer, SWF> importedCharacterSourceSwfs = new HashMap<>();
|
||||
private Map<Integer, Integer> importedCharacterIds = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
private static AbcIndexing playerGlobalAbcIndex;
|
||||
|
||||
private static AbcIndexing airGlobalAbcIndex;
|
||||
@@ -489,7 +487,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static AbcIndexing getPlayerGlobalAbcIndex() {
|
||||
return playerGlobalAbcIndex;
|
||||
}
|
||||
@@ -588,7 +586,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public void updateCharacters() {
|
||||
characters = null;
|
||||
charactersWithImported = null;
|
||||
characterToId = null;
|
||||
characterToId = null;
|
||||
characterIdTags = null;
|
||||
externalImages2 = null;
|
||||
}
|
||||
@@ -666,9 +664,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
di.getChildInfos().clear();
|
||||
}
|
||||
|
||||
public Map<Integer, CharacterTag> getCharacters(boolean withImported) {
|
||||
if (characters == null) {
|
||||
|
||||
public Map<Integer, CharacterTag> getCharacters(boolean withImported) {
|
||||
if (characters == null) {
|
||||
synchronized (this) {
|
||||
if (characters == null) {
|
||||
if (destroyed) {
|
||||
@@ -684,9 +682,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
int exportedCharacterId = importedCharacterIds.get(importedCharacterId);
|
||||
SWF importedSwf = importedCharacterSourceSwfs.get(importedCharacterId);
|
||||
charsWithImported.put(importedCharacterId, importedSwf.getCharacter(exportedCharacterId));
|
||||
charIdtags.put(importedCharacterId, importedSwf.getCharacterIdTags(exportedCharacterId));
|
||||
charIdtags.put(importedCharacterId, importedSwf.getCharacterIdTags(exportedCharacterId));
|
||||
//FIXME? eimages
|
||||
|
||||
|
||||
charsWithImported.get(importedCharacterId).setImported(true, true);
|
||||
for (CharacterIdTag chi : charIdtags.get(importedCharacterId)) {
|
||||
if (chi instanceof Tag) {
|
||||
@@ -698,15 +696,15 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
for (int id : charsWithImported.keySet()) {
|
||||
charToId.put(charsWithImported.get(id), id);
|
||||
}
|
||||
for (int id : charIdtags.keySet()) {
|
||||
for (int id : charIdtags.keySet()) {
|
||||
for (CharacterIdTag ch : charIdtags.get(id)) {
|
||||
charToId.put(ch, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
characters = Collections.unmodifiableMap(chars);
|
||||
charactersWithImported = Collections.unmodifiableMap(charsWithImported);
|
||||
characterToId = Collections.unmodifiableMap(charToId);
|
||||
characterToId = Collections.unmodifiableMap(charToId);
|
||||
characterIdTags = Collections.unmodifiableMap(charIdtags);
|
||||
externalImages2 = Collections.unmodifiableMap(eimages);
|
||||
}
|
||||
@@ -735,7 +733,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
return characterIdTags.get(characterId);
|
||||
}
|
||||
|
||||
|
||||
public CharacterIdTag getCharacterIdTag(int characterId, int tagId) {
|
||||
List<CharacterIdTag> characterIdTags = getCharacterIdTags(characterId);
|
||||
if (characterIdTags != null) {
|
||||
@@ -873,12 +871,12 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
int charId = classToCharacter.get(className);
|
||||
return getCharacter(charId);
|
||||
}
|
||||
|
||||
|
||||
public CharacterTag getCharacterByExportName(String exportName) {
|
||||
int charId;
|
||||
if (importedNameToCharacter.containsKey(exportName)) {
|
||||
charId = importedNameToCharacter.get(exportName);
|
||||
} else if (exportNameToCharacter.containsKey(exportName)){
|
||||
} else if (exportNameToCharacter.containsKey(exportName)) {
|
||||
charId = exportNameToCharacter.get(exportName);
|
||||
} else {
|
||||
return null;
|
||||
@@ -936,8 +934,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets real character id of a character tag on this SWF.
|
||||
* Normal .getCharacterId method od the CharacterTag does not work for imported characters
|
||||
* This gets real character id of a character tag on this SWF. Normal
|
||||
* .getCharacterId method od the CharacterTag does not work for imported
|
||||
* characters
|
||||
*
|
||||
* @param tag
|
||||
* @return Character id or -1 if not found
|
||||
*/
|
||||
@@ -950,7 +950,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
return characterToId.get(tag);
|
||||
}
|
||||
|
||||
|
||||
public FontTag getFont(int fontId) {
|
||||
CharacterTag characterTag = getCharacters(true).get(fontId);
|
||||
if (characterTag instanceof FontTag) {
|
||||
@@ -1286,7 +1286,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
private byte[] saveToByteArray(boolean includeImported) throws IOException {
|
||||
return saveToByteArray(gfx, includeImported);
|
||||
}
|
||||
|
||||
|
||||
private byte[] saveToByteArray(boolean gfx, boolean includeImported) throws IOException {
|
||||
byte[] data;
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); SWFOutputStream sos = new SWFOutputStream(baos, version, charset)) {
|
||||
@@ -1313,7 +1313,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
@@ -1580,25 +1580,25 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
SWF iSwf = resolver.resolveUrl(importTag.getUrl());
|
||||
if (iSwf != null) {
|
||||
|
||||
|
||||
Map<Integer, String> importedIdToNameMap = importTag.getAssets();
|
||||
|
||||
|
||||
Map<String, Integer> exportedNameToIdsMap = new HashMap<>();
|
||||
|
||||
|
||||
for (Tag t2 : iSwf.tags) {
|
||||
if (t2 instanceof ExportAssetsTag) {
|
||||
ExportAssetsTag sc = (ExportAssetsTag) t2;
|
||||
for (int i = 0; i < sc.names.size(); i++) {
|
||||
exportedNameToIdsMap.put(sc.names.get(i), sc.tags.get(i));
|
||||
}
|
||||
}
|
||||
exportedNameToIdsMap.put(sc.names.get(i), sc.tags.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int importedId : importedIdToNameMap.keySet()) {
|
||||
String importedName = importedIdToNameMap.get(importedId);
|
||||
if (exportedNameToIdsMap.containsKey(importedName)) {
|
||||
int exportedId = exportedNameToIdsMap.get(importedName);
|
||||
importedCharacterSourceSwfs.put(importedId, iSwf);
|
||||
importedCharacterSourceSwfs.put(importedId, iSwf);
|
||||
importedCharacterIds.put(importedId, exportedId);
|
||||
importedNameToCharacter.put(importedName, importedId);
|
||||
}
|
||||
@@ -1823,7 +1823,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compress SWF file
|
||||
*
|
||||
@@ -1938,12 +1938,12 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts Harman AIR encryption
|
||||
*/
|
||||
public static boolean encrypt(InputStream is, OutputStream os) throws IOException {
|
||||
public static boolean encrypt(InputStream is, OutputStream os) throws IOException {
|
||||
byte[] hdr = new byte[8];
|
||||
|
||||
// SWFheader: signature, version and fileSize
|
||||
@@ -1952,7 +1952,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
|
||||
decodeHeader(hdr);
|
||||
|
||||
|
||||
byte[] encrypted;
|
||||
try {
|
||||
encrypted = HarmanSwfEncrypt.encrypt(is, hdr);
|
||||
@@ -1962,9 +1962,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
os.write(encrypted);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrypts Harman AIR encryption
|
||||
* Decrypts Harman AIR encryption
|
||||
*/
|
||||
public static boolean decrypt(InputStream is, OutputStream os) throws IOException {
|
||||
byte[] hdr = new byte[8];
|
||||
@@ -2020,7 +2020,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
header.gfx = headerData[1] == 'F' && headerData[2] == 'X';
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
public static boolean decompress(InputStream fis, OutputStream fos) {
|
||||
try {
|
||||
decompress(fis, fos, false);
|
||||
@@ -2051,13 +2051,13 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
case 'c':
|
||||
case 'z':
|
||||
case 'f':
|
||||
header.encrypted = true;
|
||||
header.encrypted = true;
|
||||
byte[] decrypted;
|
||||
try {
|
||||
decrypted = HarmanSwfEncrypt.decrypt(is, hdr);
|
||||
} catch (IOException | NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
||||
throw new SwfOpenException(AppResources.translate("error.swf.decryptionProblem"));
|
||||
}
|
||||
}
|
||||
is = new ByteArrayInputStream(decrypted);
|
||||
break;
|
||||
|
||||
@@ -2107,9 +2107,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
// does not contain size of header (signature + version + filesize = 8 bytes)
|
||||
if (header.gfx && is.available() >= fileSize) {
|
||||
final InputStream fis = is;
|
||||
|
||||
|
||||
//pass to outputstream all we read
|
||||
InputStream copyIs = new InputStream() {
|
||||
InputStream copyIs = new InputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int value = fis.read();
|
||||
@@ -2125,7 +2125,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
int tagIDTagLength = sis.readUI16("tagIDTagLength");
|
||||
long tagLength = (tagIDTagLength & 0x003F);
|
||||
if (tagLength == 0x3f) {
|
||||
sis.readSI32("tagLength");
|
||||
sis.readSI32("tagLength");
|
||||
}
|
||||
int tagID = (tagIDTagLength) >> 6;
|
||||
if (tagID == ExporterInfo.ID) {
|
||||
@@ -2304,12 +2304,12 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
if (realItem instanceof ASMSource && (exportAll || exportNode)) {
|
||||
String pathNoExportFilenames2 = pathNoExportFilenames;
|
||||
String pathExportFilenames2 = pathExportFilenames;
|
||||
String path = exportFileNames ? pathExportFilenames : pathNoExportFilenames;
|
||||
|
||||
String path = exportFileNames ? pathExportFilenames : pathNoExportFilenames;
|
||||
|
||||
int ppos = 1;
|
||||
while (asmsToExport.containsKey(path)) {
|
||||
ppos++;
|
||||
pathNoExportFilenames2 = pathNoExportFilenames + "_" + ppos;
|
||||
pathNoExportFilenames2 = pathNoExportFilenames + "_" + ppos;
|
||||
pathExportFilenames2 = pathExportFilenames + "[" + ppos + "]";
|
||||
path = exportFileNames ? pathExportFilenames2 : pathNoExportFilenames2;
|
||||
}
|
||||
@@ -2321,24 +2321,24 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
if (treeItem instanceof TagScript) {
|
||||
TagScript tagScript = (TagScript) treeItem;
|
||||
for (TreeItem subItem : tagScript.getFrames()) {
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
);
|
||||
}
|
||||
} else if (treeItem instanceof FrameScript) {
|
||||
FrameScript frameScript = (FrameScript) treeItem;
|
||||
Frame parentFrame = frameScript.getFrame();
|
||||
for (TreeItem subItem : parentFrame.actionContainers) {
|
||||
getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
);
|
||||
}
|
||||
for (TreeItem subItem : parentFrame.actions) {
|
||||
getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
);
|
||||
}
|
||||
} else if (treeItem instanceof AS2Package) {
|
||||
@@ -2347,16 +2347,16 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
if ((subItem instanceof AS2Package) && ((AS2Package) subItem).isDefaultPackage()) {
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, pathExportFilenames, pathNoExportFilenames);
|
||||
} else {
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
);
|
||||
}
|
||||
}
|
||||
for (TreeItem subItem : as2Package.scripts.values()) {
|
||||
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
pathExportFilenames + File.separator + getASMPath(true, subItem),
|
||||
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3196,7 +3196,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
return new AffineTransform(mat.getScaleXFloat(), mat.getRotateSkew0Float(),
|
||||
mat.getRotateSkew1Float(), mat.getScaleYFloat(),
|
||||
mat.translateX, mat.translateY);
|
||||
}
|
||||
}
|
||||
|
||||
public void putToCache(String key, SerializableImage img) {
|
||||
if (Configuration.useFrameCache.get()) {
|
||||
@@ -3300,7 +3300,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
swf.as3Cache.remove(pack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isActionListCached(ASMSource src) {
|
||||
if (src != null) {
|
||||
@@ -3346,7 +3346,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public SerializableImage getFromCache(String key) {
|
||||
if (frameCache.contains(key)) {
|
||||
return frameCache.get(key);
|
||||
@@ -3360,7 +3360,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
return soundCache.get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static HighlightedText getFromCache(ScriptPack pack) {
|
||||
if (pack != null) {
|
||||
@@ -3384,7 +3384,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static ActionList getCachedActionList(ASMSource src, final List<DisassemblyListener> listeners) throws InterruptedException {
|
||||
synchronized (src) {
|
||||
SWF swf = src.getSwf();
|
||||
@@ -3561,8 +3561,6 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean removeCharacterFromTimeline(int characterId, Timeline timeline, TagRemoveListener listener) {
|
||||
Set<Integer> chars = new HashSet<>();
|
||||
chars.add(characterId);
|
||||
@@ -3800,7 +3798,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
setModified(true);
|
||||
tags.add(index, tag);
|
||||
updateCharacters();
|
||||
}
|
||||
}
|
||||
|
||||
public int indexOfTag(Tag tag) {
|
||||
return tags.indexOf(tag);
|
||||
@@ -3945,7 +3943,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
((Tag) tag).setModified(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects debugline and debugfile instructions to AS3 P-code (lines of
|
||||
@@ -3972,7 +3970,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
*
|
||||
* @param decompileDir Directory to set file information paths
|
||||
*/
|
||||
public void injectAS3DebugInfo(File decompileDir) throws InterruptedException {
|
||||
public void injectAS3DebugInfo(File decompileDir) throws InterruptedException {
|
||||
List<ScriptPack> packs = getAS3Packs();
|
||||
int i = 0;
|
||||
for (ScriptPack s : packs) {
|
||||
@@ -3981,14 +3979,14 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
i++;
|
||||
informListeners("inject_debuginfo", "" + i + "/" + packs.size() + ": " + s.getPath());
|
||||
if (s.isSimple) {
|
||||
if (s.isSimple) {
|
||||
try {
|
||||
s.injectDebugInfo(decompileDir);
|
||||
} catch (Throwable t) {
|
||||
Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Errorr injecting debug info", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4022,7 +4020,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry) throws InterruptedException {
|
||||
enableDebugging(injectAS3Code, decompileDir, telemetry, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables debugging. Adds tags to enable debugging and injects debugline
|
||||
* and debugfile instructions to AS3 code. Optionally enables Telemetry
|
||||
@@ -4506,7 +4504,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
updateCharacters();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void replaceTag(int index, Tag newTag) {
|
||||
removeTag(index);
|
||||
@@ -4610,5 +4608,5 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,9 +387,10 @@ public class SWFInputStream implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* HACK: Special constructor to handle old GFX format
|
||||
* - DO NOT USE for normal purposes - it won't read tags, etc...
|
||||
* @param is
|
||||
* HACK: Special constructor to handle old GFX format - DO NOT USE for
|
||||
* normal purposes - it won't read tags, etc...
|
||||
*
|
||||
* @param is
|
||||
*/
|
||||
public SWFInputStream(InputStream is) throws IOException {
|
||||
this.swf = null;
|
||||
@@ -398,7 +399,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
this.limit = Integer.MAX_VALUE;
|
||||
this.is = new FakeMemoryInputStream(is);
|
||||
}
|
||||
|
||||
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
@@ -825,7 +826,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
* @return ByteArrayRange object
|
||||
* @throws IOException
|
||||
*/
|
||||
public ByteArrayRange readByteRangeEx(long count, String name, DumpInfoSpecialType specialType, Object specialValue) throws IOException {
|
||||
public ByteArrayRange readByteRangeEx(long count, String name, DumpInfoSpecialType specialType, Object specialValue) throws IOException {
|
||||
if (count <= 0) {
|
||||
return ByteArrayRange.EMPTY;
|
||||
}
|
||||
@@ -2871,7 +2872,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
cer.controlDeltaX = (int) readSB(cer.numBits + 2, "controlDeltaX");
|
||||
cer.controlDeltaY = (int) readSB(cer.numBits + 2, "controlDeltaY");
|
||||
cer.anchorDeltaX = (int) readSB(cer.numBits + 2, "anchorDeltaX");
|
||||
cer.anchorDeltaY = (int) readSB(cer.numBits + 2, "anchorDeltaY");
|
||||
cer.anchorDeltaY = (int) readSB(cer.numBits + 2, "anchorDeltaY");
|
||||
ret = cer;
|
||||
}
|
||||
}
|
||||
@@ -3116,7 +3117,8 @@ public class SWFInputStream implements AutoCloseable {
|
||||
/**
|
||||
* Reads one MORPHFOCALGRADIENT value from the stream.
|
||||
*
|
||||
* <p>This is undocumented feature
|
||||
* <p>
|
||||
* This is undocumented feature
|
||||
*
|
||||
* @param name
|
||||
* @return MORPHGRADIENT value
|
||||
|
||||
@@ -151,7 +151,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
os.write(b, off, len);
|
||||
pos += len;
|
||||
}
|
||||
|
||||
|
||||
public void write(ByteArrayRange b) throws IOException {
|
||||
alignByte();
|
||||
os.write(b.getArray(), b.getPos(), b.getLength());
|
||||
@@ -419,15 +419,15 @@ public class SWFOutputStream extends OutputStream {
|
||||
if (!fitsInUB(nBits, value)) {
|
||||
throw new ValueTooLargeException("UB[" + nBits + "]", value);
|
||||
}
|
||||
writeNBInternal(nBits, value, "UB");
|
||||
writeNBInternal(nBits, value, "UB");
|
||||
}
|
||||
|
||||
|
||||
public static boolean fitsInSB(int nBits, long value) {
|
||||
long min = -1L << (nBits - 1);
|
||||
long max = (1L << (nBits - 1)) - 1;
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
||||
|
||||
public static boolean fitsInUB(int nBits, long value) {
|
||||
long min = 0;
|
||||
long max = (1L << nBits) - 1;
|
||||
@@ -454,7 +454,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
* @param value Signed value to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeSB(int nBits, long value) throws IOException {
|
||||
public void writeSB(int nBits, long value) throws IOException {
|
||||
if (!fitsInSB(nBits, value)) {
|
||||
throw new ValueTooLargeException("SB[" + nBits + "]", value);
|
||||
}
|
||||
@@ -530,7 +530,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
for (Tag tag : tags) {
|
||||
tag.writeTag(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates number of bits needed for representing signed value
|
||||
@@ -564,7 +564,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
}
|
||||
return nBits;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates number of bits needed for representing unsigned value
|
||||
*
|
||||
@@ -680,7 +680,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
|
||||
writeUB(5, nBits);
|
||||
writeFB(nBits, value.rotateSkew0);
|
||||
writeFB(nBits, value.rotateSkew1);
|
||||
writeFB(nBits, value.rotateSkew1);
|
||||
}
|
||||
int NTranslateBits = 0;
|
||||
NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX);
|
||||
@@ -1386,17 +1386,17 @@ public class SWFOutputStream extends OutputStream {
|
||||
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeSHAPE(SHAPE value, int shapeNum) throws IOException {
|
||||
public void writeSHAPE(SHAPE value, int shapeNum) throws IOException {
|
||||
calculateSHAPEFillLineBits(value);
|
||||
writeUB(4, value.numFillBits);
|
||||
writeUB(4, value.numLineBits);
|
||||
writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum);
|
||||
}
|
||||
|
||||
|
||||
private void calculateSHAPEFillLineBits(SHAPE value) {
|
||||
int numFillBits = 0;
|
||||
int numLineBits = 0;
|
||||
|
||||
|
||||
for (SHAPERECORD r : value.shapeRecords) {
|
||||
if (r instanceof StyleChangeRecord) {
|
||||
StyleChangeRecord scr = (StyleChangeRecord) r;
|
||||
@@ -1407,22 +1407,22 @@ public class SWFOutputStream extends OutputStream {
|
||||
numFillBits = Math.max(numFillBits, getNeededBitsU(scr.fillStyle1));
|
||||
}
|
||||
if (scr.stateLineStyle) {
|
||||
numLineBits = Math.max(numLineBits, getNeededBitsU(scr.lineStyle));
|
||||
numLineBits = Math.max(numLineBits, getNeededBitsU(scr.lineStyle));
|
||||
}
|
||||
if (scr.stateNewStyles) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Configuration._debugCopy.get()) {
|
||||
numFillBits = Math.max(numFillBits, value.numFillBits);
|
||||
numLineBits = Math.max(numLineBits, value.numLineBits);
|
||||
}
|
||||
|
||||
|
||||
value.numFillBits = numFillBits;
|
||||
value.numLineBits = numLineBits;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes SHAPEWITHSTYLE value to the stream
|
||||
*
|
||||
@@ -1433,7 +1433,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
public void writeSHAPEWITHSTYLE(SHAPEWITHSTYLE value, int shapeNum) throws IOException {
|
||||
writeFILLSTYLEARRAY(value.fillStyles, shapeNum);
|
||||
writeLINESTYLEARRAY(value.lineStyles, shapeNum);
|
||||
calculateSHAPEFillLineBits(value);
|
||||
calculateSHAPEFillLineBits(value);
|
||||
writeUB(4, value.numFillBits);
|
||||
writeUB(4, value.numLineBits);
|
||||
writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum);
|
||||
@@ -1715,7 +1715,8 @@ public class SWFOutputStream extends OutputStream {
|
||||
/**
|
||||
* Writes MORPHFOCALGRADIENT value to the stream.
|
||||
*
|
||||
* <p>Undocumented feature
|
||||
* <p>
|
||||
* Undocumented feature
|
||||
*
|
||||
* @param value MORPHGRADIENT value
|
||||
* @param shapeNum 1 in DefineMorphShape, 2 in DefineMorphShape2,...
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SourceGeneratorLocalData implements Serializable {
|
||||
|
||||
public List<List<Long>> catchesOpenedLoops = new ArrayList<>();
|
||||
public List<Integer> catchesTempRegs = new ArrayList<>();
|
||||
|
||||
|
||||
public String documentClass;
|
||||
|
||||
public boolean secondRun = false;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ABCOutputStream extends OutputStream {
|
||||
|
||||
private final OutputStream os;
|
||||
private long position = 0L;
|
||||
|
||||
|
||||
public ABCOutputStream(OutputStream os) {
|
||||
this.os = os;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class ABCOutputStream extends OutputStream {
|
||||
@Override
|
||||
public void write(byte[] data) throws IOException {
|
||||
os.write(data);
|
||||
position += data.length;
|
||||
position += data.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -378,14 +378,15 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
|
||||
private class Label {
|
||||
|
||||
public long addr;
|
||||
|
||||
public Label(long addr) {
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Injects debugfile, debugline instructions into the code.
|
||||
*
|
||||
@@ -445,7 +446,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
if (!bodyToFunctionName.containsKey(bodyIndex)) {
|
||||
bodyToFunctionName.put(bodyIndex, method.getProperties().localName);
|
||||
}
|
||||
|
||||
|
||||
bodyToActivationReg.put(bodyIndex, method.getProperties().activationRegIndex);
|
||||
int pos = -1;
|
||||
int regIndex = -1;
|
||||
@@ -464,7 +465,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
if (instrOffset == -1) {
|
||||
lonelyBody.add(bodyIndex);
|
||||
break blk;
|
||||
}
|
||||
}
|
||||
try {
|
||||
pos = abc.bodies.get(bodyIndex).getCode().adr2pos(instrOffset);
|
||||
} catch (ConvertException cex) {
|
||||
@@ -480,7 +481,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
//int origPos = bodyLineToPos.get(bodyIndex).containsKey(line) ? bodyLineToPos.get(bodyIndex).get(line) : -1;
|
||||
|
||||
bodyToPosToLine.get(bodyIndex).put(pos, line);
|
||||
bodyToPosToLine.get(bodyIndex).put(pos, line);
|
||||
bodyLineToPos.get(bodyIndex).put(line, pos);
|
||||
} else {
|
||||
lonelyBody.add(bodyIndex);
|
||||
@@ -520,7 +521,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
+ cls.replace(";", "{{semicolon}}")
|
||||
+ ".as";
|
||||
filename = filename.replaceAll("\\{(invalid_utf8=[0-9]+)\\}", "[$1]");
|
||||
|
||||
|
||||
//Remove debug info from lonely bodies
|
||||
for (int bodyIndex : lonelyBody) {
|
||||
if (!bodyToPosToLine.keySet().contains(bodyIndex)) {
|
||||
@@ -561,7 +562,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
}
|
||||
List<Object> code2 = new ArrayList<>();
|
||||
|
||||
|
||||
int dpos = 0;
|
||||
code2.add(new AVM2Instruction(0, AVM2Instructions.DebugFile, new int[]{abc.constants.getStringId(filename, true)}));
|
||||
dpos++;
|
||||
@@ -582,7 +583,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
activationRegName = bodyToFunctionName.get(bodyIndex) + "$0";
|
||||
}
|
||||
code2.add(new AVM2Instruction(0, AVM2Instructions.Debug, new int[]{1, abc.constants.getStringId(activationRegName, true), activationReg - 1, bodyLine}));
|
||||
}
|
||||
}
|
||||
List<Integer> pos = new ArrayList<>(bodyToPosToLine.get(bodyIndex).keySet());
|
||||
Collections.sort(pos);
|
||||
Collections.reverse(pos);
|
||||
@@ -598,9 +599,9 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
if (delIns.contains(code.get(i))) {
|
||||
continue;
|
||||
}
|
||||
code2.add(code.get(i));
|
||||
code2.add(code.get(i));
|
||||
}
|
||||
for (int i : pos) {
|
||||
for (int i : pos) {
|
||||
int line = bodyToPosToLine.get(bodyIndex).get(i);
|
||||
if (addedLines.contains(line)) {
|
||||
continue;
|
||||
@@ -624,9 +625,9 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Label lab = (Label) obj;
|
||||
mapOffsets.put(lab.addr, adr);
|
||||
}
|
||||
}
|
||||
}
|
||||
code.clear();
|
||||
|
||||
|
||||
adr = 0;
|
||||
for (int i = 0; i < code2.size(); i++) {
|
||||
Object obj = code2.get(i);
|
||||
@@ -650,13 +651,13 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
if (mapOffsets.containsKey(targetAddr)) {
|
||||
changedAddr = mapOffsets.get(targetAddr);
|
||||
changedOperand = (int) (changedAddr - adr);
|
||||
ins.operands[0] = changedOperand;
|
||||
ins.operands[0] = changedOperand;
|
||||
} else {
|
||||
logger.log(Level.WARNING, "Invalid jump target in script {0}, bodyIndex {1}", new Object[]{toString(), bodyIndex});
|
||||
}
|
||||
for (int k = 2; k < ins.operands.length; k++) {
|
||||
targetAddr = ins.getAddress() + ins.operands[k];
|
||||
if (mapOffsets.containsKey(targetAddr)) {
|
||||
if (mapOffsets.containsKey(targetAddr)) {
|
||||
changedAddr = mapOffsets.get(targetAddr);
|
||||
changedOperand = (int) (changedAddr - adr);
|
||||
ins.operands[k] = changedOperand;
|
||||
@@ -680,12 +681,12 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
ex.start = (int) lstart;
|
||||
ex.target = (int) ltarget;
|
||||
ex.end = (int) lend;
|
||||
}
|
||||
}
|
||||
b.setModified();
|
||||
}
|
||||
|
||||
((Tag) abc.parentTag).setModified(true);
|
||||
}
|
||||
|
||||
((Tag) abc.parentTag).setModified(true);
|
||||
}
|
||||
|
||||
public void injectPCodeDebugInfo(int abcIndex) {
|
||||
|
||||
@@ -718,7 +719,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Trait trait;
|
||||
int traitIndex = -10;
|
||||
if (trt != null && cls != null) {
|
||||
traitIndex = (int) trt.getProperties().index;
|
||||
traitIndex = (int) trt.getProperties().index;
|
||||
}
|
||||
bodyToIdentifier.put(bodyIndex, "abc:" + abcIndex + ",script:" + scriptIndex + ",class:" + classIndex + ",trait:" + traitIndex + ",method:" + methodIndex + ",body:" + bodyIndex);
|
||||
break;
|
||||
|
||||
@@ -2415,7 +2415,7 @@ public class AVM2Code implements Cloneable {
|
||||
}, body);
|
||||
code.remove(pos);
|
||||
//checkValidOffsets(body);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces instruction by another. Properly handles offsets. Note: If
|
||||
|
||||
@@ -871,5 +871,5 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
for (int i = 0; i < constant_multiname.size(); i++) {
|
||||
Multiname.checkTypeNameCyclic(this, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -299,7 +299,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
public int adr2pos(long adr) {
|
||||
return code.adr2pos(adr);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int adr2pos(long adr, boolean nearest) {
|
||||
return code.adr2pos(adr, nearest);
|
||||
|
||||
+2
-3
@@ -306,18 +306,17 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
public int adr2pos(long adr) {
|
||||
return code.adr2pos(adr);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int adr2pos(long adr, boolean nearest) {
|
||||
return code.adr2pos(adr, nearest);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long pos2adr(int pos) {
|
||||
return code.pos2adr(pos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<Long> getImportantAddresses() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
|
||||
@@ -58,8 +58,8 @@ public class FastAVM2List implements Collection<AVM2InstructionItem> {
|
||||
|
||||
size = code.size();
|
||||
getJumps(avm2code, actionItemMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final AVM2InstructionItem insertItemBefore(AVM2InstructionItem item, AVM2Instruction action) {
|
||||
AVM2InstructionItem newItem = new AVM2InstructionItem(action);
|
||||
return insertItemBefore(item, newItem);
|
||||
@@ -77,8 +77,8 @@ public class FastAVM2List implements Collection<AVM2InstructionItem> {
|
||||
public final AVM2InstructionItem insertItemAfter(AVM2InstructionItem item, AVM2Instruction action) {
|
||||
AVM2InstructionItem newItem = new AVM2InstructionItem(action);
|
||||
return insertItemAfter(item, newItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final AVM2InstructionItem insertItemAfter(AVM2InstructionItem item, AVM2InstructionItem newItem) {
|
||||
if (item == null && firstItem == null) {
|
||||
firstItem = newItem;
|
||||
|
||||
@@ -2051,10 +2051,10 @@ public class AVM2Graph extends Graph {
|
||||
protected void processOther(List<GraphTargetItem> list, long lastLoopId) {
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int pos = list.size() - 1;
|
||||
|
||||
|
||||
if (list.get(pos) instanceof ContinueItem) {
|
||||
if (((ContinueItem) list.get(pos)).loopId != lastLoopId) {
|
||||
return;
|
||||
@@ -2064,9 +2064,9 @@ public class AVM2Graph extends Graph {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Remove continues from all branches of try...catch block if its continue to parent loop
|
||||
if (list.get(pos) instanceof TryAVM2Item) {
|
||||
if (list.get(pos) instanceof TryAVM2Item) {
|
||||
TryAVM2Item ta = (TryAVM2Item) list.get(pos);
|
||||
for (List<GraphTargetItem> cc : ta.catchCommands) {
|
||||
if (!cc.isEmpty()) {
|
||||
@@ -2094,9 +2094,9 @@ public class AVM2Graph extends Graph {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void finalProcessAfter(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) {
|
||||
super.finalProcessAfter(list, level, localData, path);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class AVM2GraphSource extends GraphSource {
|
||||
public int adr2pos(long adr) {
|
||||
return code.adr2pos(adr);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int adr2pos(long adr, boolean nearest) {
|
||||
return code.adr2pos(adr, true);
|
||||
@@ -131,5 +131,5 @@ public class AVM2GraphSource extends GraphSource {
|
||||
@Override
|
||||
public long pos2adr(int pos) {
|
||||
return code.pos2adr(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Long> getOffsets() {
|
||||
List<Long> ret = new ArrayList<>();
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert
|
||||
|
||||
public CoerceAIns() {
|
||||
super(0x82, "coerce_a", new int[]{}, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
|
||||
+7
-6
@@ -24,13 +24,14 @@ import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
|
||||
/**
|
||||
* Store new Activation object. This exists just for the purpose of passing
|
||||
* activation register to the GraphTextWriter to correctly be read
|
||||
* by debug info injector.
|
||||
* Store new Activation object. This exists just for the purpose of passing
|
||||
* activation register to the GraphTextWriter to correctly be read by debug info
|
||||
* injector.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class StoreNewActivationAVM2Item extends AVM2Item {
|
||||
|
||||
|
||||
public int regIndex;
|
||||
|
||||
public StoreNewActivationAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, int regIndex) {
|
||||
@@ -47,7 +48,7 @@ public class StoreNewActivationAVM2Item extends AVM2Item {
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
HighlightData hd = new HighlightData();
|
||||
@@ -69,5 +70,5 @@ public class StoreNewActivationAVM2Item extends AVM2Item {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -101,7 +101,7 @@ public class ASM3Parser {
|
||||
return label + " at address " + offset;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static int checkMultinameIndex(AVM2ConstantPool constants, int index, int line) throws AVM2ParseException {
|
||||
if ((index < 0) || (index >= constants.getMultinameCount())) {
|
||||
@@ -733,7 +733,7 @@ public class ASM3Parser {
|
||||
}
|
||||
return new ValueKind(value_index, value_kind);
|
||||
}
|
||||
|
||||
|
||||
public static AVM2Code parse(ABC abc, Reader reader, Trait trait, MethodBody body, MethodInfo info) throws IOException, AVM2ParseException, InterruptedException {
|
||||
return parse(abc, reader, trait, null, body, info);
|
||||
}
|
||||
|
||||
+2958
-2740
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -23,7 +23,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.pcode;
|
||||
public class ParsedSymbol {
|
||||
|
||||
public int pos;
|
||||
|
||||
|
||||
public int type;
|
||||
|
||||
public Object value;
|
||||
|
||||
+7
-10
@@ -139,14 +139,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return currentFinId++;
|
||||
}
|
||||
|
||||
|
||||
private long uniqLast = 0;
|
||||
|
||||
public String uniqId() {
|
||||
uniqLast++;
|
||||
return "" + uniqLast;
|
||||
}
|
||||
|
||||
|
||||
public static int resolveType(SourceGeneratorLocalData localData, GraphTargetItem item, AbcIndexing abcIndex) throws CompilationException {
|
||||
int name_index = 0;
|
||||
GraphTargetItem typeItem = null;
|
||||
@@ -247,7 +246,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
ret.add(ins(AVM2Instructions.Pop));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private AVM2Instruction ins(int instructionCode, int... operands) {
|
||||
return new AVM2Instruction(0, instructionCode, operands);
|
||||
}
|
||||
@@ -1819,7 +1818,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
mbCode.add(ins(AVM2Instructions.PushScope));
|
||||
|
||||
int traitScope = 1;
|
||||
|
||||
|
||||
String documentClassStr = localData.documentClass;
|
||||
DottedChain documentClass = null;
|
||||
if (documentClassStr != null && !documentClassStr.isEmpty()) {
|
||||
@@ -1833,13 +1832,11 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
TraitClass tc = (TraitClass) t;
|
||||
DottedChain className = tc.getName(abc).getNameWithNamespace(abc.constants, true);
|
||||
|
||||
|
||||
|
||||
List<Integer> parents = new ArrayList<>();
|
||||
if (documentClass != null && documentClass.equals(className)) {
|
||||
mbCode.add(ins(AVM2Instructions.GetScopeObject, 0));
|
||||
} else {
|
||||
int[] nsset = new int[]{constants.getMultiname(tc.name_index).namespace_index};
|
||||
int[] nsset = new int[]{constants.getMultiname(tc.name_index).namespace_index};
|
||||
mbCode.add(ins(AVM2Instructions.FindPropertyStrict, constants.getMultinameId(Multiname.createMultiname(false, constants.getMultiname(tc.name_index).name_index, constants.getNamespaceSetId(nsset, true)), true)));
|
||||
}
|
||||
traitScope++;
|
||||
@@ -2035,7 +2032,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
ci = ci.parent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, FalseItem item) throws CompilationException {
|
||||
return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.PushFalse));
|
||||
@@ -2926,13 +2923,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
if (localData.isStatic && item.toString().equals(currentFullClassName)) {
|
||||
return Arrays.asList(ins(AVM2Instructions.GetLocal0));
|
||||
return Arrays.asList(ins(AVM2Instructions.GetLocal0));
|
||||
} else if (globalSlotId > 0) {
|
||||
return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.GetGlobalScope), ins(AVM2Instructions.GetSlot, globalSlotId));
|
||||
} else {
|
||||
return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.GetLex, resolveType(localData, item, abcIndex)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, PushItem item) throws CompilationException {
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public final class AbcIndexing {
|
||||
|
||||
if (builtInNs == null) {
|
||||
//we need to avoid modifying the ABC
|
||||
/* builtInIndex = abc.constants.getNamespaceId(Namespace.KIND_NAMESPACE, BUILT_IN_NS, 0, true);
|
||||
/* builtInIndex = abc.constants.getNamespaceId(Namespace.KIND_NAMESPACE, BUILT_IN_NS, 0, true);
|
||||
builtInNsPerAbc.put(abc, builtInIndex);*/
|
||||
builtInIndex = Integer.MIN_VALUE; //??
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -803,7 +803,7 @@ public class ActionScript3Parser {
|
||||
if (classNameStr == null) {
|
||||
isStatic = true;
|
||||
}
|
||||
|
||||
|
||||
s = lex();
|
||||
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
||||
namespace = new NamespaceItem((Integer) s.value);
|
||||
@@ -838,7 +838,7 @@ public class ActionScript3Parser {
|
||||
t = st;
|
||||
} else {
|
||||
t = ft;
|
||||
}
|
||||
}
|
||||
//NOTE: Looks like TraitFunction does not work in FlashPlayer - use MethodTrait instead
|
||||
/*else {
|
||||
t = function(metadata, pkg, isInterface, new Reference<Boolean>(false), importedClasses, namespace, thisType, openedNamespaces, fname, false, new ArrayList<AssignableAVM2Item>());
|
||||
@@ -1894,7 +1894,7 @@ public class ActionScript3Parser {
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*private GraphTargetItem expressionRemainder(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<NamespaceItem> openedNamespaces, GraphTargetItem expr, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, List<DottedChain> importedClasses) throws IOException, AVM2ParseException {
|
||||
GraphTargetItem ret = null;
|
||||
@@ -1949,7 +1949,7 @@ public class ActionScript3Parser {
|
||||
}
|
||||
return arrCnt;
|
||||
}
|
||||
|
||||
|
||||
private GraphTargetItem expression(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, boolean allowComma) throws IOException, AVM2ParseException, InterruptedException {
|
||||
return expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables, allowComma);
|
||||
}
|
||||
|
||||
+1151
-1081
File diff suppressed because it is too large
Load Diff
@@ -104,7 +104,7 @@ public class InstanceInfo {
|
||||
fileName = getName(abc.constants).getNameWithNamespace(abc.constants, false).toRawString();
|
||||
}
|
||||
fileName = Helper.makeFileName(fileName);
|
||||
|
||||
|
||||
if (ct instanceof DefineBinaryDataTag) {
|
||||
writer.appendNoHilight("[Embed(source=\"" + ASSETS_DIR + fileName + ".bin\", mimeType=\"application/octet-stream\")]").newLine();
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public final class MethodBody implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized AVM2Code getCode() {
|
||||
public synchronized AVM2Code getCode() {
|
||||
if (code == null) {
|
||||
AVM2Code avm2Code;
|
||||
try {
|
||||
@@ -170,7 +170,7 @@ public final class MethodBody implements Cloneable {
|
||||
|
||||
public void markOffsets() {
|
||||
getCode().markOffsets();
|
||||
}
|
||||
}
|
||||
|
||||
public int removeDeadCode(AVM2ConstantPool constants, Trait trait, MethodInfo info) throws InterruptedException {
|
||||
return getCode().removeDeadCode(this);
|
||||
@@ -205,7 +205,7 @@ public final class MethodBody implements Cloneable {
|
||||
*/
|
||||
public void replaceInstruction(int pos, AVM2Instruction instruction) {
|
||||
getCode().replaceInstruction(pos, instruction, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void insertAll(int pos, List<AVM2Instruction> list) {
|
||||
for (AVM2Instruction ins : list) {
|
||||
@@ -336,8 +336,7 @@ public final class MethodBody implements Cloneable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "";
|
||||
|
||||
@@ -87,7 +87,7 @@ public class MethodInfo {
|
||||
public void setFlagIgnore_Rest() {
|
||||
flags |= FLAG_IGNORE_REST;
|
||||
}
|
||||
|
||||
|
||||
public void setFlagIgnore_Rest(boolean val) {
|
||||
if (val) {
|
||||
setFlagIgnore_Rest();
|
||||
@@ -95,7 +95,7 @@ public class MethodInfo {
|
||||
unsetFlagIgnore_Rest();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void unsetFlagIgnore_Rest() {
|
||||
if (flagIgnore_rest()) {
|
||||
flags -= FLAG_IGNORE_REST;
|
||||
@@ -146,8 +146,6 @@ public class MethodInfo {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void unsetFlagNeed_rest() {
|
||||
if (flagNeed_rest()) {
|
||||
flags -= FLAG_NEED_REST;
|
||||
@@ -157,7 +155,7 @@ public class MethodInfo {
|
||||
public void setFlagNeed_rest() {
|
||||
flags |= FLAG_NEED_REST;
|
||||
}
|
||||
|
||||
|
||||
public void setFlagNeed_rest(boolean val) {
|
||||
if (val) {
|
||||
setFlagNeed_rest();
|
||||
@@ -166,8 +164,6 @@ public class MethodInfo {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void unsetFlagHas_optional() {
|
||||
if (flagHas_optional()) {
|
||||
flags -= FLAG_HAS_OPTIONAL;
|
||||
@@ -177,14 +173,14 @@ public class MethodInfo {
|
||||
public void setFlagHas_optional() {
|
||||
flags |= FLAG_HAS_OPTIONAL;
|
||||
}
|
||||
|
||||
|
||||
public void setFlagHas_optional(boolean val) {
|
||||
if (val) {
|
||||
setFlagHas_optional();
|
||||
} else {
|
||||
unsetFlagHas_optional();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unsetFlagHas_paramnames() {
|
||||
if (flagHas_paramnames()) {
|
||||
@@ -195,7 +191,7 @@ public class MethodInfo {
|
||||
public void setFlagHas_paramnames() {
|
||||
flags |= FLAG_HAS_PARAMNAMES;
|
||||
}
|
||||
|
||||
|
||||
public void setFlagHas_paramnames(boolean val) {
|
||||
if (val) {
|
||||
setFlagHas_paramnames();
|
||||
|
||||
@@ -276,7 +276,7 @@ public class Multiname {
|
||||
}
|
||||
}
|
||||
return kindStr;
|
||||
}
|
||||
}
|
||||
|
||||
public static String namespaceToString(AVM2ConstantPool constants, int index) {
|
||||
if (index == 0) {
|
||||
@@ -338,7 +338,7 @@ public class Multiname {
|
||||
}
|
||||
return constants.getMultiname(index).toString(constants, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String kindStr = getKindStr();
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ValueKind {
|
||||
return CONSTANT_StaticProtectedNs;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNamespace() {
|
||||
switch (value_kind) {
|
||||
|
||||
@@ -78,8 +78,6 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNs, ABC abc, List<Dependency> dependencies, DottedChain ignorePackage, List<DottedChain> fullyQualifiedNames, List<String> uses) throws InterruptedException {
|
||||
super.getDependencies(abcIndex, scriptIndex, -1, false, customNs, abc, dependencies, ignorePackage == null ? getPackage(abc) : ignorePackage, fullyQualifiedNames, uses);
|
||||
@@ -122,7 +120,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
public String toString(ABC abc, List<DottedChain> fullyQualifiedNames) {
|
||||
return "Class " + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, boolean insideInterface) throws InterruptedException {
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
@Override
|
||||
public int getSlotIndex() {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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, boolean insideInterface) {
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
|
||||
abc.constants.getMultiname(name_index).deleted = d;
|
||||
abc.method_info.get(method_info).delete(abc, d);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
@@ -128,7 +128,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
public String toString(ABC abc, List<DottedChain> fullyQualifiedNames) {
|
||||
return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " MethodGetterSetter " + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " disp_id=" + disp_id + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, boolean insideInterface) throws InterruptedException {
|
||||
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
@Override
|
||||
public int getSlotIndex() {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
public String getType(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
String typeStr = "*";
|
||||
@@ -150,7 +150,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc, List<DottedChain> fullyQualifiedNames) {
|
||||
String typeStr = "*";
|
||||
|
||||
+9
-11
@@ -45,12 +45,12 @@ import java.util.List;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class MultinameUsageDetector implements UsageDetector {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Usage> findUsages(ABC abc, int index) {
|
||||
return findMultinameUsage(abc, index, true);
|
||||
}
|
||||
|
||||
|
||||
public List<Usage> findMultinameUsage(ABC abc, int multinameIndex, boolean exactMatch) {
|
||||
List<Usage> ret = new ArrayList<>();
|
||||
if (multinameIndex == 0) {
|
||||
@@ -77,8 +77,8 @@ public class MultinameUsageDetector implements UsageDetector {
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<Usage>> findAllUsage(ABC abc) {
|
||||
List<List<Usage>> ret = new ArrayList<>();
|
||||
@@ -113,8 +113,8 @@ public class MultinameUsageDetector implements UsageDetector {
|
||||
@Override
|
||||
public String getKind() {
|
||||
return "string";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void findAllMultinameUsageInTraits(ABC abc, Traits traits, int traitsType, int scriptIndex, int classIndex, List<List<Usage>> ret, int parentTraitIndex) {
|
||||
for (int t = 0; t < traits.traits.size(); t++) {
|
||||
if (traits.traits.get(t) instanceof TraitClass) {
|
||||
@@ -148,7 +148,7 @@ public class MultinameUsageDetector implements UsageDetector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkAllMultinameUsedInMethod(ABC abc, int methodInfo, List<List<Usage>> ret, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
|
||||
boolean[] foundMultinames = new boolean[abc.constants.getMultinameCount()];
|
||||
for (int p = 0; p < abc.method_info.get(methodInfo).param_types.length; p++) {
|
||||
@@ -220,7 +220,6 @@ public class MultinameUsageDetector implements UsageDetector {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void findMultinameUsageInTraits(ABC abc, Traits traits, int multinameIndex, boolean exactMatch, int traitsType, int scriptIndex, int classIndex, List<Usage> ret, int parentTraitIndex) {
|
||||
for (int t = 0; t < traits.traits.size(); t++) {
|
||||
if (traits.traits.get(t) instanceof TraitClass) {
|
||||
@@ -239,7 +238,7 @@ public class MultinameUsageDetector implements UsageDetector {
|
||||
}
|
||||
checkMultinameUsedInMethod(abc, multinameIndex, exactMatch, abc.instance_info.get(c).iinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, true, null, -1);
|
||||
checkMultinameUsedInMethod(abc, multinameIndex, exactMatch, abc.class_info.get(c).cinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_CLASS, true, null, -1);
|
||||
findMultinameUsageInTraits(abc, abc.instance_info.get(c).instance_traits, multinameIndex, exactMatch, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, -1/*FIXME*/, c, ret, -1);
|
||||
findMultinameUsageInTraits(abc, abc.instance_info.get(c).instance_traits, multinameIndex, exactMatch, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, -1/*FIXME*/, c, ret, -1);
|
||||
findMultinameUsageInTraits(abc, abc.class_info.get(c).static_traits, multinameIndex, exactMatch, TraitMultinameUsage.TRAITS_TYPE_CLASS, -1/*FIXME*/, c, ret, -1);
|
||||
}
|
||||
if (traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
@@ -261,7 +260,6 @@ public class MultinameUsageDetector implements UsageDetector {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkMultinameUsedInMethod(ABC abc, int multinameIndex, boolean exactMatch, int methodInfo, List<Usage> ret, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
|
||||
for (int p = 0; p < abc.method_info.get(methodInfo).param_types.length; p++) {
|
||||
if (isSameName(abc, multinameIndex, abc.method_info.get(methodInfo).param_types[p], exactMatch)) {
|
||||
@@ -292,7 +290,7 @@ public class MultinameUsageDetector implements UsageDetector {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filterUsages(ABC abc, UsagesFilter filter) {
|
||||
|
||||
@@ -23,9 +23,10 @@ import com.jpexs.decompiler.flash.abc.ABC;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface Usage {
|
||||
|
||||
public ABC getAbc();
|
||||
|
||||
|
||||
public int getIndex();
|
||||
|
||||
|
||||
public String getKind();
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import java.util.List;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface UsageDetector {
|
||||
|
||||
|
||||
public void filterUsages(ABC abc, UsagesFilter filter);
|
||||
|
||||
|
||||
public List<Usage> findUsages(ABC abc, int index);
|
||||
|
||||
|
||||
public List<List<Usage>> findAllUsage(ABC abc);
|
||||
|
||||
|
||||
public String getKind();
|
||||
}
|
||||
|
||||
@@ -21,5 +21,6 @@ package com.jpexs.decompiler.flash.abc.usages;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface UsagesFilter {
|
||||
|
||||
public int filterUsage(int originalIndex);
|
||||
}
|
||||
|
||||
+1
-1
@@ -135,5 +135,5 @@ public abstract class MultinameUsage implements Usage {
|
||||
@Override
|
||||
public String getKind() {
|
||||
return "multiname";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class ABCCleaner {
|
||||
|
||||
public void clean(ABC abc) {
|
||||
public void clean(ABC abc) {
|
||||
ABCSimpleUsageDetector usageDetector = new ABCSimpleUsageDetector(abc);
|
||||
usageDetector.detect();
|
||||
Map<ABCSimpleUsageDetector.ItemKind, List<List<String>>> usages = usageDetector.getUsages();
|
||||
@@ -74,8 +74,8 @@ public class ABCCleaner {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < abc.script_info.size(); i++) {
|
||||
ScriptInfo m = abc.script_info.get(i);
|
||||
m.init_index = handleReplace(ABCSimpleUsageDetector.ItemKind.METHODINFO, m.init_index, replaceMap);
|
||||
@@ -300,7 +300,7 @@ public class ABCCleaner {
|
||||
if (abc.parentTag != null) {
|
||||
((Tag) abc.parentTag).setModified(true);
|
||||
}
|
||||
abc.fireChanged();
|
||||
abc.fireChanged();
|
||||
}
|
||||
|
||||
private int handleReplace(ABCSimpleUsageDetector.ItemKind kind, int index, Map<ABCSimpleUsageDetector.ItemKind, Map<Integer, Integer>> replaceMap) {
|
||||
@@ -376,6 +376,5 @@ public class ABCCleaner {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+72
-75
@@ -57,41 +57,41 @@ public class ABCSimpleUsageDetector {
|
||||
METHODINFO(false),
|
||||
METHODBODY(false),
|
||||
CLASS(false);
|
||||
|
||||
|
||||
private boolean reserveZeroIndex;
|
||||
|
||||
private ItemKind (boolean reserveZeroIndex) {
|
||||
|
||||
private ItemKind(boolean reserveZeroIndex) {
|
||||
this.reserveZeroIndex = reserveZeroIndex;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasReservedZeroIndex() {
|
||||
return reserveZeroIndex;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<ItemKind, List<List<String>>> usages = new HashMap<>();
|
||||
|
||||
private final Map<ItemKind, List<List<String>>> usages = new HashMap<>();
|
||||
private final Map<ItemKind, List<Integer>> zeroUsages = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
private final ABC abc;
|
||||
|
||||
public ABCSimpleUsageDetector(ABC abc) {
|
||||
this.abc = abc;
|
||||
this.abc = abc;
|
||||
}
|
||||
|
||||
|
||||
private void initUsages(ItemKind kind, int itemCount) {
|
||||
List<List<String>> list = new ArrayList<>();
|
||||
if (kind.hasReservedZeroIndex() && itemCount == 0) {
|
||||
itemCount = 1;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
list.add(new ArrayList<>());
|
||||
}
|
||||
usages.put(kind, list);
|
||||
}
|
||||
|
||||
|
||||
public void detect() {
|
||||
usages.clear();
|
||||
|
||||
|
||||
initUsages(ItemKind.INT, abc.constants.getIntCount());
|
||||
initUsages(ItemKind.UINT, abc.constants.getUIntCount());
|
||||
initUsages(ItemKind.DOUBLE, abc.constants.getDoubleCount());
|
||||
@@ -103,7 +103,7 @@ public class ABCSimpleUsageDetector {
|
||||
initUsages(ItemKind.METHODINFO, abc.method_info.size());
|
||||
initUsages(ItemKind.METHODBODY, abc.bodies.size());
|
||||
initUsages(ItemKind.CLASS, abc.class_info.size());
|
||||
|
||||
|
||||
ABCWalker walker = new ABCWalker() {
|
||||
protected void handleUsageNamespace(int index, String usageDescription) {
|
||||
if (!handleUsage(ItemKind.NAMESPACE, index, usageDescription)) {
|
||||
@@ -133,7 +133,7 @@ public class ABCSimpleUsageDetector {
|
||||
if (!handleUsage(ItemKind.MULTINAME, index, usageDescription)) {
|
||||
return;
|
||||
}
|
||||
Multiname m = abc.constants.getMultiname(index);
|
||||
Multiname m = abc.constants.getMultiname(index);
|
||||
if (m == null) {
|
||||
return;
|
||||
}
|
||||
@@ -153,15 +153,15 @@ public class ABCSimpleUsageDetector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void handleUsageMethodInfo(int index, String usageDescription) {
|
||||
if (!handleUsage(ItemKind.METHODINFO, index, usageDescription)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MethodInfo m = abc.method_info.get(index);
|
||||
|
||||
MethodInfo m = abc.method_info.get(index);
|
||||
handleUsage(ItemKind.STRING, m.name_index, usageDescription + "/name");
|
||||
|
||||
|
||||
if (m.flagHas_paramnames()) {
|
||||
for (int i = 0; i < m.paramNames.length; i++) {
|
||||
handleUsage(ItemKind.STRING, m.paramNames[i], usageDescription + "/param_names/pn" + i);
|
||||
@@ -172,31 +172,31 @@ public class ABCSimpleUsageDetector {
|
||||
handleUsageValueKind(m.optional[i].value_kind, m.optional[i].value_index, usageDescription + "/optional/op" + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < m.param_types.length; i++) {
|
||||
handleUsageMultiname(m.param_types[i], usageDescription + "/param_types/pt" + i);
|
||||
}
|
||||
|
||||
handleUsageMultiname(m.ret_type, usageDescription + "/return_type");
|
||||
|
||||
|
||||
handleUsageMultiname(m.ret_type, usageDescription + "/return_type");
|
||||
|
||||
int bodyIndex = abc.findBodyIndex(index);
|
||||
if (bodyIndex > -1) {
|
||||
handleUsageMethodBody(bodyIndex, usageDescription + "/method_body");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleUsageMethodBody(int index, String usageDescription) {
|
||||
if (!handleUsage(ItemKind.METHODBODY, index, usageDescription)) {
|
||||
return;
|
||||
}
|
||||
MethodBody body = abc.bodies.get(index);
|
||||
MethodBody body = abc.bodies.get(index);
|
||||
for (int i = 0; i < body.exceptions.length; i++) {
|
||||
handleUsageMultiname(body.exceptions[i].name_index, usageDescription + "/exceptions/ex" + i + "/name");
|
||||
handleUsageMultiname(body.exceptions[i].type_index, usageDescription + "/exceptions/ex" + i + "/type");
|
||||
}
|
||||
List<AVM2Instruction> code = body.getCode().code;
|
||||
for (int i = 0; i < code.size(); i++) {
|
||||
AVM2Instruction ins = code.get(i);
|
||||
AVM2Instruction ins = code.get(i);
|
||||
for (int operandIndex = 0; operandIndex < ins.definition.operands.length; operandIndex++) {
|
||||
int operand = ins.operands[operandIndex];
|
||||
String operandDescription = usageDescription + "/code/ins" + i + "/op" + operandIndex;
|
||||
@@ -228,10 +228,10 @@ public class ABCSimpleUsageDetector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleScript(ABC abc, int index) {
|
||||
|
||||
protected void handleScript(ABC abc, int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -243,9 +243,8 @@ public class ABCSimpleUsageDetector {
|
||||
description += "/instance_info/traits/t" + traitIndex;
|
||||
}
|
||||
description += "/metadata/md" + index;
|
||||
|
||||
|
||||
//?? classIndex
|
||||
|
||||
if (!handleUsage(ItemKind.METADATAINFO, index, description)) {
|
||||
return;
|
||||
}
|
||||
@@ -256,8 +255,8 @@ public class ABCSimpleUsageDetector {
|
||||
}
|
||||
for (int i = 0; i < md.values.length; i++) {
|
||||
handleUsage(ItemKind.STRING, md.values[i], description + "/pairs/p" + i + "/value");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTraitClass(ABC abc, TraitClass trait, int scriptIndex, int scriptTraitIndex) {
|
||||
@@ -265,7 +264,7 @@ public class ABCSimpleUsageDetector {
|
||||
if (!handleUsage(ItemKind.CLASS, trait.class_info, description)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
InstanceInfo ii = abc.instance_info.get(trait.class_info);
|
||||
if ((ii.flags & InstanceInfo.CLASS_PROTECTEDNS) != 0) {
|
||||
handleUsageNamespace(ii.protectedNS, description + "/instance_info/protected_ns");
|
||||
@@ -274,22 +273,21 @@ public class ABCSimpleUsageDetector {
|
||||
handleUsageMultiname(ii.super_index, description + "/instance_info/super");
|
||||
for (int i = 0; i < ii.interfaces.length; i++) {
|
||||
handleUsageMultiname(ii.interfaces[i], description + "/instance_info/interfaces/in" + i);
|
||||
}
|
||||
}
|
||||
/*
|
||||
handleUsageMethodInfo(abc.class_info.get(trait.class_info).cinit_index, description + "/class_info/cinit");
|
||||
handleUsageMethodInfo(abc.instance_info.get(trait.class_info).iinit_index, description + "/instance_info/iinit");
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTraitMethodGetterSetter(ABC abc, TraitMethodGetterSetter trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, ABCWalker.WalkType walkType) {
|
||||
handleTraitMethodBase(abc, trait, scriptIndex, scriptTraitIndex, classIndex, traitIndex, walkType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTraitMethodGetterSetter(ABC abc, TraitMethodGetterSetter trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, ABCWalker.WalkType walkType) {
|
||||
handleTraitMethodBase(abc, trait, scriptIndex, scriptTraitIndex, classIndex, traitIndex, walkType);
|
||||
}
|
||||
|
||||
|
||||
protected void handleTraitMethodBase(ABC abc, Trait trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, ABCWalker.WalkType walkType) {
|
||||
String description = "";
|
||||
if (scriptIndex > -1) {
|
||||
String description = "";
|
||||
if (scriptIndex > -1) {
|
||||
description += "si" + scriptIndex + "/traits/t" + scriptTraitIndex;
|
||||
if (walkType == WalkType.Class && traitIndex > -1) {
|
||||
description += "/class_info/traits/t" + traitIndex;
|
||||
@@ -303,13 +301,12 @@ public class ABCSimpleUsageDetector {
|
||||
description += "ii" + classIndex + "/instance_info/traits/t" + traitIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//description += " " + trait.getKindToStr();
|
||||
|
||||
handleUsageMultiname(trait.name_index, description + "/name");
|
||||
//handleUsageMethodInfo(trait.method_info, description + "/method_info");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleTraitFunction(ABC abc, TraitFunction trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, ABCWalker.WalkType walkType) {
|
||||
handleTraitMethodBase(abc, trait, scriptIndex, scriptTraitIndex, classIndex, traitIndex, walkType);
|
||||
@@ -336,14 +333,14 @@ public class ABCSimpleUsageDetector {
|
||||
case ValueKind.CONSTANT_ExplicitNamespace:
|
||||
case ValueKind.CONSTANT_StaticProtectedNs:
|
||||
case ValueKind.CONSTANT_PrivateNs:
|
||||
handleUsage(ItemKind.NAMESPACE, value_index, description);
|
||||
handleUsage(ItemKind.NAMESPACE, value_index, description);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleTraitSlotConst(ABC abc, TraitSlotConst trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, int bodyIndex, int bodyTraitIndex, ABCWalker.WalkType walkType, Stack<Integer> callStack) {
|
||||
|
||||
|
||||
String description = "";
|
||||
if (callStack.size() > 1) {
|
||||
if (bodyTraitIndex != -1) {
|
||||
@@ -352,13 +349,13 @@ public class ABCSimpleUsageDetector {
|
||||
}
|
||||
} else if (scriptIndex > -1) {
|
||||
description += "si" + scriptIndex + "/traits/t" + scriptTraitIndex;
|
||||
|
||||
|
||||
if (walkType == WalkType.Class && traitIndex > -1) {
|
||||
description += "/class_info/traits/t" + traitIndex;
|
||||
} else if (walkType == WalkType.Instance && traitIndex > -1) {
|
||||
description += "/instance_info/traits/t" + traitIndex;
|
||||
}
|
||||
|
||||
description += "/instance_info/traits/t" + traitIndex;
|
||||
}
|
||||
|
||||
if (bodyTraitIndex != -1) {
|
||||
description += "/method_info/method_body/traits/t" + bodyTraitIndex;
|
||||
}
|
||||
@@ -366,17 +363,17 @@ public class ABCSimpleUsageDetector {
|
||||
if (walkType == WalkType.Class && traitIndex > -1) {
|
||||
description += "ci" + classIndex + "/class_info/traits/t" + traitIndex;
|
||||
} else if (walkType == WalkType.Instance && traitIndex > -1) {
|
||||
description += "ii" + classIndex + "/instance_info/traits/t" + traitIndex;
|
||||
description += "ii" + classIndex + "/instance_info/traits/t" + traitIndex;
|
||||
} else if (bodyTraitIndex > -1) {
|
||||
description += "mb" + bodyIndex + "/traits/t" + bodyTraitIndex;
|
||||
description += "mb" + bodyIndex + "/traits/t" + bodyTraitIndex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//description += " " + trait.getKindToStr();
|
||||
handleUsageMultiname(trait.name_index, description + "/name");
|
||||
handleUsageMultiname(trait.type_index, description + "/type");
|
||||
handleUsageValueKind(trait.value_kind, trait.value_index, description + "/value_index");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMethodInfo(ABC abc, int index, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, ABCWalker.WalkType walkType, boolean initializer, Stack<Integer> callStack) {
|
||||
@@ -384,7 +381,7 @@ public class ABCSimpleUsageDetector {
|
||||
int prevMethod = callStack.get(callStack.size() - 2);
|
||||
handleUsageMethodInfo(index, "mi" + prevMethod + "/method_body/code");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (initializer) {
|
||||
switch (walkType) {
|
||||
case Class:
|
||||
@@ -404,13 +401,13 @@ public class ABCSimpleUsageDetector {
|
||||
case Script:
|
||||
handleUsageMethodInfo(index, "si" + scriptIndex + "/init");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String description = "";
|
||||
if (scriptIndex > -1) {
|
||||
|
||||
String description = "";
|
||||
if (scriptIndex > -1) {
|
||||
description += "si" + scriptIndex + "/traits/t" + scriptTraitIndex;
|
||||
if (walkType == WalkType.Class && traitIndex > -1) {
|
||||
description += "/class_info/traits/t" + traitIndex;
|
||||
@@ -426,10 +423,10 @@ public class ABCSimpleUsageDetector {
|
||||
}
|
||||
description += "/method_info";
|
||||
handleUsageMethodInfo(index, description);
|
||||
}
|
||||
}
|
||||
};
|
||||
walker.walkABC(abc, false);
|
||||
|
||||
|
||||
zeroUsages.clear();
|
||||
for (ItemKind kind : usages.keySet()) {
|
||||
zeroUsages.put(kind, new ArrayList<>());
|
||||
@@ -440,9 +437,9 @@ public class ABCSimpleUsageDetector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param kind
|
||||
* @param index
|
||||
* @param usageDescription
|
||||
@@ -452,18 +449,18 @@ public class ABCSimpleUsageDetector {
|
||||
|
||||
List<String> kindList = usages.get(kind).get(index);
|
||||
kindList.add(usageDescription);
|
||||
|
||||
|
||||
return kindList.size() == 1;
|
||||
}
|
||||
|
||||
public Map<ItemKind, List<List<String>>> getUsages() {
|
||||
return Collections.unmodifiableMap(usages);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getUsages(ItemKind kind, int index) {
|
||||
return Collections.unmodifiableList(usages.get(kind).get(index));
|
||||
}
|
||||
|
||||
|
||||
public List<List<String>> getUsages(ItemKind kind) {
|
||||
return Collections.unmodifiableList(usages.get(kind));
|
||||
}
|
||||
@@ -471,11 +468,11 @@ public class ABCSimpleUsageDetector {
|
||||
public Map<ItemKind, List<Integer>> getZeroUsages() {
|
||||
return Collections.unmodifiableMap(zeroUsages);
|
||||
}
|
||||
|
||||
|
||||
public List<Integer> getZeroUsages(ItemKind kind) {
|
||||
return zeroUsages.get(kind);
|
||||
}
|
||||
|
||||
|
||||
public int getZeroUsagesCount() {
|
||||
int cnt = 0;
|
||||
for (ItemKind kind : zeroUsages.keySet()) {
|
||||
@@ -483,7 +480,7 @@ public class ABCSimpleUsageDetector {
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
public int getZeroUsagesCount(ItemKind kind) {
|
||||
return zeroUsages.get(kind).size();
|
||||
}
|
||||
|
||||
@@ -35,27 +35,27 @@ import java.util.Stack;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class ABCWalker {
|
||||
|
||||
public abstract class ABCWalker {
|
||||
|
||||
public static enum WalkType {
|
||||
Orphan,
|
||||
Script,
|
||||
Class,
|
||||
Instance
|
||||
}
|
||||
|
||||
public final void walkABC(ABC abc, boolean walkOrphanItems) {
|
||||
|
||||
public final void walkABC(ABC abc, boolean walkOrphanItems) {
|
||||
Set<Integer> handledClasses = new HashSet<>();
|
||||
Set<Integer> handledMethodInfos = new HashSet<>();
|
||||
Set<Integer> handledMethodBodies = new HashSet<>();
|
||||
|
||||
|
||||
for (int i = 0; i < abc.script_info.size(); i++) {
|
||||
handleScript(abc, i);
|
||||
ScriptInfo si = abc.script_info.get(i);
|
||||
optionalHandleMethodInfo(handledMethodBodies, handledMethodInfos, abc, si.init_index, i, -1, -1, -1, WalkType.Script, true, new Stack<>());
|
||||
walkTraits(abc, si.traits, i, -1, -1, -1, -1, handledMethodBodies, handledMethodInfos, handledClasses, WalkType.Script, new Stack<>());
|
||||
}
|
||||
|
||||
|
||||
if (walkOrphanItems) {
|
||||
for (int i = 0; i < abc.method_info.size(); i++) {
|
||||
optionalHandleMethodInfo(handledMethodBodies, handledMethodInfos, abc, i, -1, -1, -1, -1, WalkType.Orphan, false, new Stack<>());
|
||||
@@ -64,31 +64,31 @@ public abstract class ABCWalker {
|
||||
for (int i = 0; i < abc.bodies.size(); i++) {
|
||||
optionalHandleMethodBody(handledMethodBodies, handledMethodInfos, abc, i, -1, -1, -1, -1, WalkType.Orphan, false, new Stack<>());
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < abc.class_info.size(); i++) {
|
||||
optionalHandleClass(handledClasses, handledMethodBodies, handledMethodInfos, abc, i, -1, -1, -1, WalkType.Orphan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean optionalHandleClass(Set<Integer> handledClasses, Set<Integer> handledMethodBodies, Set<Integer> handledMethodInfos, ABC abc, int index, int scriptIndex, int scriptTraitIndex, int traitIndex, WalkType walkType) {
|
||||
if (handledClasses.contains(index)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
handleClass(abc, index, scriptIndex, traitIndex, walkType);
|
||||
|
||||
|
||||
optionalHandleMethodInfo(handledMethodBodies, handledMethodInfos, abc, abc.instance_info.get(index).iinit_index, scriptIndex, scriptTraitIndex, index, -1, WalkType.Instance, true, new Stack<>());
|
||||
walkTraits(abc, abc.instance_info.get(index).instance_traits, scriptIndex, scriptTraitIndex, index, -1, -1, handledMethodBodies, handledMethodInfos, handledClasses, WalkType.Instance, new Stack<>());
|
||||
optionalHandleMethodInfo(handledMethodBodies, handledMethodInfos, abc, abc.class_info.get(index).cinit_index, scriptIndex, scriptTraitIndex, index, -1, WalkType.Class, true, new Stack<>());
|
||||
walkTraits(abc, abc.class_info.get(index).static_traits, scriptIndex, scriptTraitIndex, index, -1, -1, handledMethodBodies, handledMethodInfos, handledClasses, WalkType.Class, new Stack<>());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void optionalHandleMethodInfo(Set<Integer> handledMethodBodies, Set<Integer> handledMethodInfos, ABC abc, int index, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, WalkType walkType, boolean initializer, Stack<Integer> callStack) {
|
||||
if (handledMethodInfos.contains(index)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
handledMethodInfos.add(index);
|
||||
if (callStack != null) {
|
||||
if (callStack.contains(index)) {
|
||||
@@ -105,7 +105,7 @@ public abstract class ABCWalker {
|
||||
callStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void optionalHandleMethodBody(Set<Integer> handledMethodBodies, Set<Integer> handledMethodInfos, ABC abc, int index, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, WalkType walkType, boolean initializer, Stack<Integer> callStack) {
|
||||
if (handledMethodBodies.contains(index)) {
|
||||
return;
|
||||
@@ -122,10 +122,11 @@ public abstract class ABCWalker {
|
||||
}
|
||||
walkTraits(abc, abc.bodies.get(index).traits, scriptIndex, scriptTraitIndex, classIndex, traitIndex, index, handledMethodBodies, handledMethodInfos, handledMethodInfos, walkType, callStack);
|
||||
}
|
||||
|
||||
private void walkTraits(ABC abc, Traits traits, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, int bodyIndex, Set<Integer> handledMethodBodies, Set<Integer> handledMethodInfos, Set<Integer> handledClasses, WalkType walkType, Stack<Integer> callStack) {
|
||||
|
||||
|
||||
int bodyTraitIndex = -1;
|
||||
|
||||
|
||||
for (int i = 0; i < traits.traits.size(); i++) {
|
||||
if (classIndex == -1) {
|
||||
scriptTraitIndex = i;
|
||||
@@ -136,8 +137,8 @@ public abstract class ABCWalker {
|
||||
if (bodyIndex != -1) {
|
||||
bodyTraitIndex = i;
|
||||
}
|
||||
Trait t = traits.traits.get(i);
|
||||
if ((t.kindFlags & Trait.ATTR_Metadata) > 0) {
|
||||
Trait t = traits.traits.get(i);
|
||||
if ((t.kindFlags & Trait.ATTR_Metadata) > 0) {
|
||||
for (int m = 0; m < t.metadata.length; m++) {
|
||||
handleMetadataInfo(abc, t.metadata[m], t, scriptIndex, scriptTraitIndex, classIndex, i, m, walkType);
|
||||
}
|
||||
@@ -164,40 +165,40 @@ public abstract class ABCWalker {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void handleMethodInfo(ABC abc, int index, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, WalkType walkType, boolean initializer, Stack<Integer> callStack) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void handleMethodBody(ABC abc, int index, int scriptIndex, int classIndex, int traitIndex, WalkType walkType, boolean initializer) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void handleClass(ABC abc, int index, int scriptIndex, int traitIndex, WalkType walkType) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void handleScript(ABC abc, int index) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void handleTraitSlotConst(ABC abc, TraitSlotConst trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, int bodyIndex, int bodyTraitIndex, WalkType walkType, Stack<Integer> callStack) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void handleTraitMethodGetterSetter(ABC abc, TraitMethodGetterSetter trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, WalkType walkType) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void handleTraitFunction(ABC abc, TraitFunction trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, WalkType walkType) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void handleTraitClass(ABC abc, TraitClass trait, int scriptIndex, int scriptTraitIndex) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void handleMetadataInfo(ABC abc, int index, Trait trait, int scriptIndex, int scriptTraitIndex, int classIndex, int traitIndex, int traitMetadataIndex, WalkType walkType) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,10 +330,10 @@ public abstract class Action implements GraphSourceItem {
|
||||
ASMParsedSymbol symb = lex.lex();
|
||||
if (symb.type != ASMParsedSymbol.TYPE_BOOLEAN) {
|
||||
throw new ActionParseException("Boolean expected", lex.yyline());
|
||||
}
|
||||
}
|
||||
return (Boolean) symb.value;
|
||||
}
|
||||
|
||||
|
||||
protected void lexOptionalComma(FlasmLexer lex) throws IOException, ActionParseException {
|
||||
ASMParsedSymbol symb = lex.lex();
|
||||
if (symb.type != ASMParsedSymbol.TYPE_COMMA) {
|
||||
|
||||
@@ -364,7 +364,7 @@ public class ActionGraph extends Graph {
|
||||
checkedLoop = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EnumerateActionItem enumerateItem = null;
|
||||
BinaryOpItem comparisonOp = null;
|
||||
//for..in inside switch before break
|
||||
@@ -379,7 +379,7 @@ public class ActionGraph extends Graph {
|
||||
EqActionItem eq = (EqActionItem) checkedCondition;
|
||||
if (eq.rightSide instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) eq.rightSide;
|
||||
if (dv.value == Null.INSTANCE) {
|
||||
if (dv.value == Null.INSTANCE) {
|
||||
GraphTargetItem en = list.get(t - 1);
|
||||
if (en instanceof EnumerateActionItem) {
|
||||
enumerateItem = (EnumerateActionItem) en;
|
||||
@@ -406,13 +406,13 @@ public class ActionGraph extends Graph {
|
||||
enumerateItem = (EnumerateActionItem) en;
|
||||
if (ne.leftSide instanceof StoreRegisterActionItem) {
|
||||
comparisonOp = ne;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (comparisonOp != null) {
|
||||
|
||||
|
||||
if (checkedBody != null && (!checkedBody.isEmpty()) && (checkedBody.get(0) instanceof SetTypeActionItem)) {
|
||||
SetTypeActionItem sti = (SetTypeActionItem) checkedBody.get(0);
|
||||
|
||||
|
||||
+4
-4
@@ -622,7 +622,7 @@ public class ActionScript2ClassDetector {
|
||||
func.isSetter = true;
|
||||
|
||||
if (FunctionActionItem.DECOMPILE_GET_SET) {
|
||||
|
||||
|
||||
AbstractGraphTargetVisitor visitor = new AbstractGraphTargetVisitor() {
|
||||
@Override
|
||||
public void visit(GraphTargetItem item) {
|
||||
@@ -640,7 +640,7 @@ public class ActionScript2ClassDetector {
|
||||
for (GraphTargetItem ti : func.actions) {
|
||||
ti.visitRecursively(visitor);
|
||||
}
|
||||
|
||||
|
||||
//There is return getter added at the end of every setter, gotta remove it, since it won't compile
|
||||
//as setter must not return a value
|
||||
if (!func.actions.isEmpty()) {
|
||||
@@ -734,7 +734,7 @@ public class ActionScript2ClassDetector {
|
||||
DirectValueActionItem classBaseName = new DirectValueActionItem(classNamePath.get(classNamePath.size() - 1));
|
||||
((FunctionActionItem) constructor).calculatedFunctionName = classBaseName;
|
||||
traits.add(0, new MyEntry<>(classBaseName, constructor));
|
||||
|
||||
|
||||
AbstractGraphTargetVisitor visitor = new AbstractGraphTargetVisitor() {
|
||||
@Override
|
||||
public void visit(GraphTargetItem item) {
|
||||
@@ -751,7 +751,7 @@ public class ActionScript2ClassDetector {
|
||||
};
|
||||
for (GraphTargetItem ti : ((FunctionActionItem) constructor).actions) {
|
||||
ti.visitRecursively(visitor);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//throw new AssertException("No constructor found");
|
||||
}
|
||||
|
||||
+2
-3
@@ -322,8 +322,7 @@ public class UninitializedClassFieldsDetector {
|
||||
|| (item instanceof CallMethodActionItem)
|
||||
|| (item instanceof NewMethodActionItem)
|
||||
|| (item instanceof DeleteActionItem)
|
||||
|| (item instanceof GetMemberActionItem)
|
||||
) {
|
||||
|| (item instanceof GetMemberActionItem)) {
|
||||
List<String> path = getFullPath(item);
|
||||
if (path != null) {
|
||||
List<String> parent = new ArrayList<>(path);
|
||||
@@ -336,7 +335,7 @@ public class UninitializedClassFieldsDetector {
|
||||
if (!containsTrait(classTraits, classInheritance, className, name) && (!result.containsKey(className) || !result.get(className).containsKey(name))) {
|
||||
if (!result.containsKey(className)) {
|
||||
result.put(className, new LinkedHashMap<>());
|
||||
}
|
||||
}
|
||||
Variable v = new Variable(true, name, null, className);
|
||||
result.get(className).put(name, v);
|
||||
}
|
||||
|
||||
+3
-3
@@ -63,13 +63,13 @@ public class FastActionList implements Collection<ActionItem> {
|
||||
|
||||
public String getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final ActionItem insertItemBefore(ActionItem item, Action action) {
|
||||
ActionItem newItem = new ActionItem(action);
|
||||
return insertItemBefore(item, newItem);
|
||||
}
|
||||
|
||||
|
||||
public final ActionItem insertItemBefore(ActionItem item, ActionItem newItem) {
|
||||
insertItemAfter(item.prev, newItem);
|
||||
if (item == firstItem) {
|
||||
|
||||
+2
-4
@@ -126,10 +126,8 @@ public class CallMethodActionItem extends ActionItem {
|
||||
} else {
|
||||
scriptObject.toString(writer, localData);
|
||||
}
|
||||
if (
|
||||
!(((DirectValueActionItem) methodName).value instanceof RegisterNumber)
|
||||
&& IdentifiersDeobfuscation.isValidName(false, methodName.toStringNoQuotes(localData))
|
||||
) {
|
||||
if (!(((DirectValueActionItem) methodName).value instanceof RegisterNumber)
|
||||
&& IdentifiersDeobfuscation.isValidName(false, methodName.toStringNoQuotes(localData))) {
|
||||
writer.append(".");
|
||||
methodName.toStringNoQuotes(writer, localData);
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class FSCommandActionItem extends ActionItem {
|
||||
writer.append("(");
|
||||
command.appendTry(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
|
||||
@@ -83,12 +83,12 @@ public class GetURL2ActionItem extends ActionItem {
|
||||
ret.addAll(targetString.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -84,13 +84,13 @@ public class GotoFrame2ActionItem extends ActionItem {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(frame.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -72,13 +72,13 @@ public class LoadMovieActionItem extends ActionItem {
|
||||
writer.append(",");
|
||||
targetString.toString(writer, localData);
|
||||
return writer.append(methodStr).append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -73,7 +73,7 @@ public class LoadMovieNumActionItem extends ActionItem {
|
||||
writer.append(",");
|
||||
num.toString(writer, localData);
|
||||
return writer.append(methodStr).append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
@@ -84,7 +84,7 @@ public class LoadMovieNumActionItem extends ActionItem {
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
}
|
||||
|
||||
|
||||
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
String charset = asGenerator.getCharset();
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ public class LoadVariablesActionItem extends ActionItem {
|
||||
writer.append(",");
|
||||
targetString.toString(writer, localData);
|
||||
return writer.append(methodStr).append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
@@ -83,7 +83,7 @@ public class LoadVariablesActionItem extends ActionItem {
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
}
|
||||
|
||||
|
||||
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
String charset = asGenerator.getCharset();
|
||||
|
||||
+2
-2
@@ -73,13 +73,13 @@ public class LoadVariablesNumActionItem extends ActionItem {
|
||||
writer.append(",");
|
||||
num.toString(writer, localData);
|
||||
return writer.append(methodStr).append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -43,13 +43,13 @@ public class NextFrameActionItem extends ActionItem {
|
||||
|
||||
public NextFrameActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
@@ -43,13 +43,13 @@ public class PlayActionItem extends ActionItem {
|
||||
|
||||
public PlayActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -43,13 +43,13 @@ public class PrevFrameActionItem extends ActionItem {
|
||||
|
||||
public PrevFrameActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
@@ -64,12 +64,12 @@ public class PrintActionItem extends ActionItem {
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -63,13 +63,13 @@ public class PrintAsBitmapActionItem extends ActionItem {
|
||||
writer.append(",");
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -63,13 +63,13 @@ public class PrintAsBitmapNumActionItem extends ActionItem {
|
||||
writer.append(",");
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ public class PrintNumActionItem extends ActionItem {
|
||||
writer.append(",");
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
@@ -74,7 +74,7 @@ public class PrintNumActionItem extends ActionItem {
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
}
|
||||
|
||||
|
||||
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
String charset = asGenerator.getCharset();
|
||||
|
||||
+2
-2
@@ -55,13 +55,13 @@ public class RemoveSpriteActionItem extends ActionItem {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -101,13 +101,13 @@ public class StartDragActionItem extends ActionItem {
|
||||
ret.addAll(y1.getNeededSources());
|
||||
ret.addAll(y2.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
@@ -44,12 +44,12 @@ public class StopActionItem extends ActionItem {
|
||||
public StopActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+2
-2
@@ -43,13 +43,13 @@ public class StopAllSoundsActionItem extends ActionItem {
|
||||
|
||||
public StopAllSoundsActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class StopDragActionItem extends ActionItem {
|
||||
|
||||
public StopDragActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
|
||||
+2
-2
@@ -48,13 +48,13 @@ public class ToggleHighQualityActionItem extends ActionItem {
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
@@ -55,13 +55,13 @@ public class TraceActionItem extends ActionItem {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class UnLoadMovieActionItem extends ActionItem {
|
||||
targetString.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class UnLoadMovieNumActionItem extends ActionItem {
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ package com.jpexs.decompiler.flash.action.parser.pcode;
|
||||
public class ASMParsedSymbol {
|
||||
|
||||
public int pos;
|
||||
|
||||
|
||||
public int type;
|
||||
|
||||
public Object value;
|
||||
@@ -61,7 +61,7 @@ public class ASMParsedSymbol {
|
||||
public static final int TYPE_EOL = 16;
|
||||
|
||||
public static final int TYPE_CONSTANT_LITERAL = 17;
|
||||
|
||||
|
||||
public static final int TYPE_COMMA = 18;
|
||||
|
||||
public ASMParsedSymbol(int pos, int type, Object value) {
|
||||
@@ -78,5 +78,5 @@ public class ASMParsedSymbol {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "symbol[type=" + type + ", value=" + value + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class ASMParser {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ASMParser.class.getName());
|
||||
private static final Logger logger = Logger.getLogger(ASMParser.class.getName());
|
||||
|
||||
private static Action parseAction(String instructionName, FlasmLexer lexer, List<String> constantPool, int version, String charset) throws IOException, ActionParseException {
|
||||
Action a = null;
|
||||
|
||||
+1155
-1049
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -175,8 +175,8 @@ import java.util.Map;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionScript2Parser {
|
||||
|
||||
public class ActionScript2Parser {
|
||||
|
||||
public static final List<String> BUILTIN_CASTS = Arrays.asList(new String[]{
|
||||
"flash.display.BitmapData",
|
||||
"flash.external.ExternalInterface",
|
||||
|
||||
+8
-16
@@ -89,10 +89,8 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
|
||||
private String charset;
|
||||
|
||||
|
||||
private long uniqLast = 0;
|
||||
|
||||
|
||||
public ActionSourceGenerator(int swfVersion, List<String> constantPool, String charset) {
|
||||
this.constantPool = constantPool;
|
||||
this.swfVersion = swfVersion;
|
||||
@@ -103,13 +101,11 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
uniqLast++;
|
||||
return "" + uniqLast;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<Action> generateToActionList(SourceGeneratorLocalData localData, List<GraphTargetItem> commands) throws CompilationException {
|
||||
return toActionList(generate(localData, commands));
|
||||
}
|
||||
@@ -117,7 +113,7 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
private List<Action> generateToActionList(SourceGeneratorLocalData localData, GraphTargetItem command) throws CompilationException {
|
||||
return toActionList(command.toSource(localData, this));
|
||||
}
|
||||
|
||||
|
||||
public List<Action> toActionList(List<GraphSourceItem> items) {
|
||||
List<Action> ret = new ArrayList<>();
|
||||
for (GraphSourceItem s : items) {
|
||||
@@ -185,8 +181,7 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void fixLoop(List<Action> code, int breakOffset) {
|
||||
fixLoop(code, breakOffset, Integer.MAX_VALUE);
|
||||
}
|
||||
@@ -208,8 +203,7 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public HashMap<String, Integer> getRegisterVars(SourceGeneratorLocalData localData) {
|
||||
return localData.registerVars;
|
||||
}
|
||||
@@ -363,7 +357,7 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
|
||||
public int getSwfVersion() {
|
||||
return swfVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getConstantPool() {
|
||||
return constantPool;
|
||||
@@ -386,8 +380,7 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
}
|
||||
return new ActionPush(new ConstantIndex(index), charset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = item.toSource(localData, this);
|
||||
@@ -605,7 +598,7 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
ret.add(new ActionPop());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, FalseItem item) throws CompilationException {
|
||||
return GraphTargetItem.toSourceMerge(localData, this, new ActionPush(Boolean.FALSE, charset));
|
||||
@@ -889,7 +882,6 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, List<GraphTargetItem> commands) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
|
||||
@@ -100,8 +100,8 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
public ActionWaitForFrame(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
|
||||
super(0x8A, -1, charset);
|
||||
frame = (int) lexLong(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
skipCount = (int) lexLong(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
skipCount = (int) lexLong(lexer);
|
||||
skipped = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,24 +110,24 @@ public class ActionGetURL2 extends Action {
|
||||
|
||||
public ActionGetURL2(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
|
||||
super(0x9A, -1, charset);
|
||||
|
||||
|
||||
ASMParsedSymbol symb = lexer.lex();
|
||||
boolean sendVarsMethodLast = false;
|
||||
if (symb.type == ASMParsedSymbol.TYPE_BOOLEAN) { //backwards compatibility. In 19.1.0 up to 20.0.0 sendVarsMethod is first
|
||||
sendVarsMethodLast = true;
|
||||
sendVarsMethodLast = true;
|
||||
}
|
||||
lexer.pushback(symb);
|
||||
if (!sendVarsMethodLast) {
|
||||
sendVarsMethod = (int) lexLong(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
}
|
||||
loadVariablesFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
loadTargetFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
loadTargetFlag = lexBoolean(lexer);
|
||||
if (sendVarsMethodLast) {
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
sendVarsMethod = (int) lexLong(lexer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -104,10 +104,10 @@ public class ActionGotoFrame2 extends Action {
|
||||
public ActionGotoFrame2(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
|
||||
super(0x9F, -1, charset);
|
||||
sceneBiasFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
playFlag = lexBoolean(lexer);
|
||||
if (sceneBiasFlag) {
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
sceneBias = (int) lexLong(lexer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class ActionPush extends Action {
|
||||
super(0x96, 0, charset);
|
||||
this.constantPool = constantPool;
|
||||
values = new ArrayList<>();
|
||||
int count = 0;
|
||||
int count = 0;
|
||||
loop:
|
||||
while (true) {
|
||||
boolean valueExpected = false;
|
||||
@@ -346,14 +346,14 @@ public class ActionPush extends Action {
|
||||
ret = value.toString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public GraphTextWriter paramsToString(GraphTextWriter writer) {
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
if (i > 0) {
|
||||
writer.appendNoHilight(", ");
|
||||
}
|
||||
writer.append(toString(i), getAddress() + i + 1, getFileOffset());
|
||||
writer.append(toString(i), getAddress() + i + 1, getFileOffset());
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
@@ -374,10 +374,10 @@ public class ActionPush extends Action {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
toString(writer);
|
||||
writer.finishHilights();
|
||||
return writer.toString();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ActionConstantPool extends Action {
|
||||
super(0x88, 0, charset);
|
||||
boolean first = true;
|
||||
while (true) {
|
||||
boolean valueRequired = false;
|
||||
boolean valueRequired = false;
|
||||
ASMParsedSymbol symb = lexer.lex();
|
||||
if (!first && symb.type == ASMParsedSymbol.TYPE_COMMA) {
|
||||
symb = lexer.lex();
|
||||
@@ -78,7 +78,7 @@ public class ActionConstantPool extends Action {
|
||||
}
|
||||
lexer.pushback(symb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
lexOptionalComma(lexer);
|
||||
int numParams = (int) lexLong(lexer);
|
||||
for (int i = 0; i < numParams; i++) {
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
paramNames.add(lexString(lexer));
|
||||
}
|
||||
lexBlockOpen(lexer);
|
||||
|
||||
+13
-13
@@ -145,32 +145,32 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
public ActionDefineFunction2(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
|
||||
super(0x8E, -1, charset);
|
||||
functionName = lexString(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
int numParams = (int) lexLong(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
registerCount = (int) lexLong(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
preloadParentFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
preloadRootFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
suppressSuperFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
preloadSuperFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
suppressArgumentsFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
preloadArgumentsFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
suppressThisFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
preloadThisFlag = lexBoolean(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
preloadGlobalFlag = lexBoolean(lexer);
|
||||
for (int i = 0; i < numParams; i++) {
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
paramRegisters.add((int) lexLong(lexer));
|
||||
lexOptionalComma(lexer);
|
||||
lexOptionalComma(lexer);
|
||||
paramNames.add(lexString(lexer));
|
||||
}
|
||||
lexBlockOpen(lexer);
|
||||
|
||||
@@ -193,8 +193,8 @@ public class Amf3OutputStream extends OutputStream {
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
os.write(b, off, len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void writeArray(ArrayType val, Map<String, ObjectTypeSerializeHandler> serializers, List<String> stringTable, List<Traits> traitsTable, List<Object> objectTable) throws IOException, NoSerializerExistsException {
|
||||
int objectIndex = objectTable.indexOf(val);
|
||||
if (objectIndex == -1) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class Configuration {
|
||||
public static final Level logLevel;
|
||||
|
||||
public static boolean showStat;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> openMultipleFiles = null;
|
||||
@@ -930,85 +930,85 @@ public final class Configuration {
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> displayAs12PCodeDocsPanel = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultDouble(0.85)
|
||||
@ConfigurationName("gui.action.splitPane.docs.dividerLocationPercent")
|
||||
@ConfigurationInternal
|
||||
public static ConfigurationItem<Double> guiActionDocsSplitPaneDividerLocationPercent = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> rememberLastScreen = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultInt(-1)
|
||||
@ConfigurationInternal
|
||||
public static ConfigurationItem<Integer> lastMainWindowScreenIndex = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultInt(-1)
|
||||
@ConfigurationInternal
|
||||
public static ConfigurationItem<Integer> lastMainWindowScreenX = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultInt(-1)
|
||||
@ConfigurationInternal
|
||||
public static ConfigurationItem<Integer> lastMainWindowScreenY = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultInt(-1)
|
||||
@ConfigurationInternal
|
||||
public static ConfigurationItem<Integer> lastMainWindowScreenWidth = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultInt(-1)
|
||||
@ConfigurationInternal
|
||||
public static ConfigurationItem<Integer> lastMainWindowScreenHeight = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> displayAs12PCodePanel = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> displayAs3PCodePanel = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("export")
|
||||
public static ConfigurationItem<Boolean> flaExportUseMappedFontLayout = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultInt(3)
|
||||
@ConfigurationName("formatting.tab.size")
|
||||
@ConfigurationCategory("format")
|
||||
public static ConfigurationItem<Integer> tabSize = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultInt(1000)
|
||||
@ConfigurationCategory("limit")
|
||||
public static ConfigurationItem<Integer> boxBlurPixelsLimit = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("export")
|
||||
public static ConfigurationItem<Boolean> as3ExportNamesUseClassNamesOnly = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultString("")
|
||||
@ConfigurationDirectory
|
||||
public static ConfigurationItem<String> jnaTempDirectory = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("export")
|
||||
public static ConfigurationItem<Boolean> flaExportFixShapes = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("export")
|
||||
public static ConfigurationItem<Boolean> lastExportResampleWav = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("display")
|
||||
public static ConfigurationItem<Boolean> previewResampleSound = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("export")
|
||||
public static ConfigurationItem<Boolean> lastExportTransparentBackground = null;
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("script")
|
||||
public static ConfigurationItem<Boolean> warningAbcClean = null;
|
||||
|
||||
|
||||
private enum OSId {
|
||||
WINDOWS, OSX, UNIX
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class ConfigurationItem<T> {
|
||||
hasValue = true;
|
||||
this.defaultValue = defaultValue;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T get() {
|
||||
if (!hasValue) {
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ package com.jpexs.decompiler.flash.configuration;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class CustomConfigurationKeys {
|
||||
|
||||
public class CustomConfigurationKeys {
|
||||
|
||||
public static final String KEY_LAST_SELECTED_PATH_RESOURCES = "lastSelectedPath.resources";
|
||||
public static final String KEY_LAST_SELECTED_PATH_TAGLIST = "lastSelectedPath.taglist";
|
||||
public static final String KEY_CHARSET = "charset";
|
||||
|
||||
+3
-4
@@ -32,9 +32,8 @@ public class SwfSpecificCustomConfiguration implements Serializable {
|
||||
private static final long serialVersionUID = 0x2acb421da57f5eb4L;
|
||||
|
||||
private Map<String, String> customData = new HashMap<>();
|
||||
|
||||
public static final String LIST_SEPARATOR = "{*sep*}";
|
||||
|
||||
public static final String LIST_SEPARATOR = "{*sep*}";
|
||||
|
||||
public List<String> getCustomDataAsList(String key) {
|
||||
String data = getCustomData(key, "");
|
||||
@@ -47,7 +46,7 @@ public class SwfSpecificCustomConfiguration implements Serializable {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String getCustomData(String key, String defaultValue) {
|
||||
if (customData.containsKey(key)) {
|
||||
return customData.get(key);
|
||||
@@ -59,7 +58,7 @@ public class SwfSpecificCustomConfiguration implements Serializable {
|
||||
public void setCustomData(String key, String value) {
|
||||
customData.put(key, value);
|
||||
}
|
||||
|
||||
|
||||
public void setCustomData(String key, Iterable<? extends CharSequence> value) {
|
||||
customData.put(key, String.join(LIST_SEPARATOR, value));
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AbstractDocs {
|
||||
protected static String meta(String name, String content) {
|
||||
return "\t\t<meta name=\"" + name + "\" content=\"" + content + "\">" + As3PCodeOtherDocs.NEWLINE;
|
||||
}
|
||||
|
||||
|
||||
protected static String meta(String name, Date content) {
|
||||
return "\t\t<meta name=\"" + name + "\" content=\"" + getISO8601StringForDate(content) + "\">" + As3PCodeOtherDocs.NEWLINE;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class AbstractDocs {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
|
||||
protected static String hilightArgument(String docs, int argumentIndex) {
|
||||
if (argumentIndex < 0) {
|
||||
return docs;
|
||||
@@ -100,7 +100,7 @@ public class AbstractDocs {
|
||||
symb = lexer.lex();
|
||||
if (symb.type == ParsedSymbol.TYPE_BRACKET_OPEN) {
|
||||
while (symb.type != ParsedSymbol.TYPE_BRACKET_CLOSE && symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
symb = lexer.lex();
|
||||
symb = lexer.lex();
|
||||
}
|
||||
endPos = lexer.yychar() + 1;
|
||||
break;
|
||||
|
||||
@@ -164,7 +164,7 @@ public class As12PCodeDocs extends AbstractDocs {
|
||||
}
|
||||
}
|
||||
return identName.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDocsForIns(String insName, boolean ui, boolean standalone, boolean nightMode, int argumentToHilight) {
|
||||
insName = insName.toLowerCase();
|
||||
|
||||
@@ -122,7 +122,7 @@ public class As3PCodeDocs extends AbstractDocs {
|
||||
|
||||
String stack = def.hasFlag(AVM2InstructionFlag.UNKNOWN_STACK) ? getProperty("ui.unknown") : stackBefore + "<span class=\"stack-to\">" + getProperty("ui.stack.to") + "</span>" + stackAfter;
|
||||
String operandsDoc = def.hasFlag(AVM2InstructionFlag.UNKNOWN_OPERANDS) ? getProperty("ui.unknown") : getProperty("instruction." + insName + ".operands");
|
||||
|
||||
|
||||
if (standalone) {
|
||||
sb.append("<body class=\"");
|
||||
if (nightMode) {
|
||||
@@ -146,7 +146,7 @@ public class As3PCodeDocs extends AbstractDocs {
|
||||
sb.append(" ").append(getProperty("ui.unknown")).append(NEWLINE);
|
||||
} else if (ui && insName.equals("lookupswitch")) {
|
||||
sb.append(" ");
|
||||
sb.append("<span class=\"instruction-operands\">");
|
||||
sb.append("<span class=\"instruction-operands\">");
|
||||
sb.append(getProperty("instruction.lookupswitch.operands.ui"));
|
||||
sb.append("</span>");
|
||||
} else {
|
||||
@@ -155,7 +155,7 @@ public class As3PCodeDocs extends AbstractDocs {
|
||||
if (def.operands.length > 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append("<span class=\"instruction-operands\">");
|
||||
sb.append("<span class=\"instruction-operands\">");
|
||||
for (int i = 0; i < def.operands.length; i++) {
|
||||
int op = def.operands[i];
|
||||
String opDoc = operandsDocs[i];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,5 +21,5 @@ package com.jpexs.decompiler.flash.docs;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DocsParseException extends Exception {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.jpexs.decompiler.flash.docs;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ParsedSymbol {
|
||||
|
||||
public static int TYPE_EOF = 0;
|
||||
public static int TYPE_IDENTIFIER = 1;
|
||||
public static int TYPE_COLON = 2;
|
||||
@@ -30,7 +31,7 @@ public class ParsedSymbol {
|
||||
public static int TYPE_COMMA = 6;
|
||||
public static int TYPE_PIPE = 7;
|
||||
public static int TYPE_STAR = 8;
|
||||
|
||||
|
||||
public final int type;
|
||||
public final String value;
|
||||
|
||||
@@ -42,5 +43,5 @@ public class ParsedSymbol {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "symbol[type=" + type + ", value=" + value + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class EcmaScript {
|
||||
return object_defaultValue((ObjectType) o, prefferedType);
|
||||
}
|
||||
return Undefined.INSTANCE; //??
|
||||
}
|
||||
}
|
||||
|
||||
public static Object object_get(ObjectType o, String p) {
|
||||
//TODO: isDataDesciptor, etc. ECMA 8.12.3
|
||||
@@ -281,12 +281,12 @@ public class EcmaScript {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean strictEquals(Object x, Object y) {
|
||||
return strictEquals(false, x, y);
|
||||
}
|
||||
|
||||
|
||||
public static boolean strictEquals(boolean as2, Object x, Object y) {
|
||||
if (type(x) != type(y)) {
|
||||
return false;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ObjectType implements Callable {
|
||||
|
||||
public Object toPrimitive() {
|
||||
return toString();
|
||||
}
|
||||
}
|
||||
|
||||
public Object valueOf() {
|
||||
return EcmaScript.toNumber(toString());
|
||||
|
||||
@@ -53,7 +53,7 @@ public class BinaryDataExporter {
|
||||
}
|
||||
return exportBinaryData(handler, outdir, binaryDatas, settings, evl);
|
||||
}
|
||||
|
||||
|
||||
public List<File> exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, List<BinaryDataInterface> binaryDatas, BinaryDataExportSettings settings, EventListener evl) throws IOException, InterruptedException {
|
||||
List<File> ret = new ArrayList<>();
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
@@ -75,8 +75,8 @@ public class BinaryDataExporter {
|
||||
|
||||
int currentIndex = 1;
|
||||
for (final BinaryDataInterface t : binaryDatas) {
|
||||
if (evl != null) {
|
||||
evl.handleExportingEvent("binarydata", currentIndex, count, t.getName());
|
||||
if (evl != null) {
|
||||
evl.handleExportingEvent("binarydata", currentIndex, count, t.getName());
|
||||
}
|
||||
|
||||
String ext = t.getInnerSwf() == null ? ".bin" : ".swf";
|
||||
@@ -86,10 +86,10 @@ public class BinaryDataExporter {
|
||||
fos.write(t.getDataBytes().getRangeData());
|
||||
}
|
||||
}, handler).run();
|
||||
|
||||
|
||||
DefineBinaryDataTag bdt = (DefineBinaryDataTag) t.getTopLevelBinaryData();
|
||||
|
||||
Set<String> classNames = bdt.getClassNames();
|
||||
Set<String> classNames = bdt.getClassNames();
|
||||
if (Configuration.as3ExportNamesUseClassNamesOnly.get() && !classNames.isEmpty()) {
|
||||
for (String className : classNames) {
|
||||
File classFile = new File(outdir + File.separator + Helper.makeFileName(t.getClassExportFileName(className) + ext));
|
||||
@@ -99,7 +99,7 @@ public class BinaryDataExporter {
|
||||
ret.add(classFile);
|
||||
}
|
||||
file.delete();
|
||||
} else {
|
||||
} else {
|
||||
ret.add(file);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class BinaryDataExporter {
|
||||
evl.handleExportedEvent("binarydata", currentIndex, count, t.getName());
|
||||
}
|
||||
|
||||
currentIndex++;
|
||||
currentIndex++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -133,7 +133,7 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable, G
|
||||
boolean ok2 = pdfGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
|
||||
return ok1 && ok2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
|
||||
imageGraphics.drawRenderedImage(img, xform);
|
||||
@@ -383,7 +383,7 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable, G
|
||||
public void clipRect(int x, int y, int width, int height) {
|
||||
imageGraphics.clearRect(x, y, width, height);
|
||||
pdfGraphics.clipRect(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shape getClip() {
|
||||
@@ -395,7 +395,7 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable, G
|
||||
imageGraphics.setClip(x, y, width, height);
|
||||
pdfGraphics.setClip(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setClip(Shape clip) {
|
||||
imageGraphics.setClip(clip);
|
||||
@@ -478,7 +478,7 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable, G
|
||||
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
|
||||
imageGraphics.fillPolygon(xPoints, yPoints, nPoints);
|
||||
pdfGraphics.fillPolygon(xPoints, yPoints, nPoints);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
@@ -609,8 +609,8 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable, G
|
||||
int spacing = entry.glyphAdvance - calcAdvance;
|
||||
char ch = font.glyphToChar(entry.glyphIndex);
|
||||
if (spacing != 0) {
|
||||
text.append(currentChar);
|
||||
drawText(swf, x, y, trans, textColor, existingFonts, font, text.toString(), textHeight, pdfGraphics);
|
||||
text.append(currentChar);
|
||||
drawText(swf, x, y, trans, textColor, existingFonts, font, text.toString(), textHeight, pdfGraphics);
|
||||
text = new StringBuilder();
|
||||
x = x + deltaX + entry.glyphAdvance;
|
||||
deltaX = 0;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Font4Exporter {
|
||||
exportFont(st, settings.mode, file);
|
||||
}, handler).run();
|
||||
|
||||
Set<String> classNames = st.getClassNames();
|
||||
Set<String> classNames = st.getClassNames();
|
||||
if (Configuration.as3ExportNamesUseClassNamesOnly.get() && !classNames.isEmpty()) {
|
||||
for (String className : classNames) {
|
||||
File classFile = new File(outdir + File.separator + Helper.makeFileName(className + ext));
|
||||
@@ -98,7 +98,7 @@ public class Font4Exporter {
|
||||
ret.add(classFile);
|
||||
}
|
||||
file.delete();
|
||||
} else {
|
||||
} else {
|
||||
ret.add(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,8 +102,8 @@ public class FontExporter {
|
||||
new RetryTask(() -> {
|
||||
exportFont(st, settings.mode, file);
|
||||
}, handler).run();
|
||||
|
||||
Set<String> classNames = st.getClassNames();
|
||||
|
||||
Set<String> classNames = st.getClassNames();
|
||||
if (Configuration.as3ExportNamesUseClassNamesOnly.get() && !classNames.isEmpty()) {
|
||||
for (String className : classNames) {
|
||||
File classFile = new File(outdir + File.separator + Helper.makeFileName(className + ext));
|
||||
@@ -113,10 +113,10 @@ public class FontExporter {
|
||||
ret.add(classFile);
|
||||
}
|
||||
file.delete();
|
||||
} else {
|
||||
} else {
|
||||
ret.add(file);
|
||||
}
|
||||
|
||||
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
break;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class FontExporter {
|
||||
currentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class FontExporter {
|
||||
final double divider = t.getDivider();
|
||||
|
||||
File ttfFile = file;
|
||||
|
||||
|
||||
if (mode == FontExportMode.WOFF) {
|
||||
ttfFile = File.createTempFile("ffdec_export", ".ttf");
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class FontExporter {
|
||||
if (fontName.length() == 0) {
|
||||
fontName = "noname";
|
||||
}
|
||||
|
||||
|
||||
Fontastic f = new Fontastic(fontName, ttfFile);
|
||||
String cop = t.getCopyright();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user