java source code formatting

This commit is contained in:
honfika
2014-06-22 09:52:54 +02:00
parent 38335ec2e4
commit 6e7e92ddf2
63 changed files with 3160 additions and 3196 deletions

View File

@@ -236,8 +236,8 @@ public final class SWF implements TreeItem, Timelined {
*/
public int version;
/**
* Uncompressed size of the file
*/
* Uncompressed size of the file
*/
public long fileSize;
/**
* Used compression mode
@@ -270,7 +270,7 @@ public final class SWF implements TreeItem, Timelined {
public static final double unitDivisor = 20;
private Timeline timeline;
public DumpInfo dumpInfo;
public void updateCharacters() {
@@ -368,7 +368,7 @@ public final class SWF implements TreeItem, Timelined {
public void saveTo(OutputStream os) throws IOException {
saveTo(os, compression);
}
/**
* Saves this SWF into new file
*
@@ -691,7 +691,7 @@ public final class SWF implements TreeItem, Timelined {
return false;
}
}
private static SWFHeader decompress(InputStream is, OutputStream os, boolean allowUncompressed) throws IOException {
byte[] hdr = new byte[8];
@@ -735,7 +735,7 @@ public final class SWF implements TreeItem, Timelined {
}
case 'Z': { // ZWS
sis.readUI32("LZMAsize"); // compressed LZMA data size = compressed SWF - 17 byte,
// where 17 = 8 byte header + this 4 byte + 5 bytes decoder properties
// where 17 = 8 byte header + this 4 byte + 5 bytes decoder properties
int propertiesSize = 5;
byte[] lzmaProperties = sis.readBytes(propertiesSize, "lzmaproperties");
if (lzmaProperties.length != propertiesSize) {
@@ -760,7 +760,7 @@ public final class SWF implements TreeItem, Timelined {
}
}
}
return header;
}
}
@@ -789,13 +789,13 @@ public final class SWF implements TreeItem, Timelined {
abcTags.add(cnt);
}
}
boolean exported = false;
for (int i = 0; i < abcTags.size(); i++) {
ABC abc = abcTags.get(i).getABC();
List<ScriptPack> scrs = abc.findScriptPacksByPath(className);
for(ScriptPack scr:scrs) {
for (ScriptPack scr : scrs) {
String cnt = "";
if (abc.script_info.size() > 1) {
cnt = "script " + (i + 1) + "/" + abc.script_info.size() + " ";
@@ -804,11 +804,11 @@ public final class SWF implements TreeItem, Timelined {
informListeners("exporting", exStr);
scr.export(outdir, abcTags, exportMode, parallel);
exStr = "Exported " + "tag " + (i + 1) + "/" + abcTags.size() + " " + cnt + scr.getPath() + " ...";
informListeners("exported", exStr);
informListeners("exported", exStr);
exported = true;
}
}
}
return exported;
return exported;
}
private List<MyEntry<ClassPath, ScriptPack>> uniqueAS3Packs(List<MyEntry<ClassPath, ScriptPack>> packs) {
@@ -1281,10 +1281,10 @@ public final class SWF implements TreeItem, Timelined {
return;
}
try (ImageOutputStream output = new FileImageOutputStream(file)) {
BufferedImage img0=images.next();
BufferedImage img0 = images.next();
GifSequenceWriter writer = new GifSequenceWriter(output, img0.getType(), 1000 / frameRate, true);
writer.writeToSequence(img0);
while (images.hasNext()) {
writer.writeToSequence(images.next());
}
@@ -1521,24 +1521,24 @@ public final class SWF implements TreeItem, Timelined {
return ret;
}
final Timeline ftim=tim;
final Color fbackgroundColor=backgroundColor;
final Timeline ftim = tim;
final Color fbackgroundColor = backgroundColor;
final Iterator<BufferedImage> frameImages = new Iterator<BufferedImage>() {
private final int pos=0;
private final int pos = 0;
@Override
public boolean hasNext() {
return fframes.size()>pos;
return fframes.size() > pos;
}
@Override
public BufferedImage next() {
if(!hasNext()){
if (!hasNext()) {
return null;
}
return frameToImageGet(ftim, fframes.get(pos), 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor,false).getBufferedImage();
return frameToImageGet(ftim, fframes.get(pos), 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor, false).getBufferedImage();
}
};
@@ -2519,7 +2519,7 @@ public final class SWF implements TreeItem, Timelined {
public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor, boolean useCache) {
String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode();
SerializableImage image;
if(useCache){
if (useCache) {
image = getFromCache(key);
if (image != null) {
return image;
@@ -2882,8 +2882,8 @@ public final class SWF implements TreeItem, Timelined {
i--;
continue;
}
if (toRemove instanceof CharacterTag){
if (toRemove instanceof CharacterTag) {
if (t.removeCharacter(characterId)) {
modified = true;
i = -1;
@@ -2902,7 +2902,7 @@ public final class SWF implements TreeItem, Timelined {
}
return modified;
}
public void removeTag(Tag t, boolean removeDependencies) {
Timelined timelined = t.getTimelined();
if (t instanceof ShowFrameTag || ShowFrameTag.isNestedTagType(t.getId())) {
@@ -2926,4 +2926,4 @@ public final class SWF implements TreeItem, Timelined {
updateCharacters();
clearImageCache();
}
}
}

View File

@@ -21,6 +21,6 @@ package com.jpexs.decompiler.flash;
* @author JPEXS
*/
public enum SWFCompression {
NONE, ZLIB, LZMA
}

View File

@@ -21,12 +21,12 @@ package com.jpexs.decompiler.flash;
* @author JPEXS
*/
public class SWFHeader {
/**
* Version of SWF
*/
public int version;
/**
* Uncompressed size of the file
*/

View File

@@ -370,11 +370,11 @@ public class SWFInputStream implements AutoCloseable {
dumpInfo = di;
}
}
private void endDumpLevel() {
endDumpLevel(null);
}
private void endDumpLevel(Object value) {
if (dumpInfo != null) {
if (dumpInfo.startBit == 0 && bitPos == 0) {
@@ -386,7 +386,7 @@ public class SWFInputStream implements AutoCloseable {
dumpInfo = dumpInfo.parent;
}
}
/**
* Reads one byte from the stream
*
@@ -401,7 +401,7 @@ public class SWFInputStream implements AutoCloseable {
private void alignByte() {
bitPos = 0;
}
private int lastPercent = -1;
private int readNoBitReset() throws IOException, EndOfStreamException {
@@ -695,6 +695,7 @@ public class SWFInputStream implements AutoCloseable {
}
return ret;
}
/**
* Skip bytes from the stream
*
@@ -806,7 +807,7 @@ public class SWFInputStream implements AutoCloseable {
endDumpLevel(ret);
return ret;
}
/**
* Reads UB[nBits] (Unsigned-bit value) value from the stream
*
@@ -850,7 +851,7 @@ public class SWFInputStream implements AutoCloseable {
endDumpLevel(ret);
return ret;
}
/**
* Reads SB[nBits] (Signed-bit value) value from the stream
*
@@ -1086,13 +1087,13 @@ public class SWFInputStream implements AutoCloseable {
if (!(tag instanceof TagStub)) {
return tag;
}
long pos = tag.getPos();
int length = tag.getOriginalLength();
SWF swf = tag.getSwf();
TagStub tagStub = (TagStub) tag;
SWFInputStream sis = tagStub.getDataStream();
try {
switch (tag.getId()) {
case 0:
@@ -3238,7 +3239,7 @@ public class SWFInputStream implements AutoCloseable {
}
return available() * 8;
}
public MemoryInputStream getBaseStream() throws IOException {
int pos = (int) is.getPos();
return new MemoryInputStream(is.getAllRead(), pos, pos + is.available());

View File

@@ -427,7 +427,7 @@ public class SWFOutputStream extends OutputStream {
tagPositions.put(tag, pos);
tagLengths.put(tag, length);
}
// todo: honfika: update tag position and lengths. Currently the 2nd save fails
}

View File

@@ -803,22 +803,22 @@ public class ABC {
}
}
private void checkMultinameUsedInMethod(List<ABCContainerTag> abcTags,int multinameIndex, int methodInfo, List<MultinameUsage> ret, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
private void checkMultinameUsedInMethod(List<ABCContainerTag> abcTags, int multinameIndex, int methodInfo, List<MultinameUsage> ret, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
for (int p = 0; p < method_info.get(methodInfo).param_types.length; p++) {
if (method_info.get(methodInfo).param_types[p] == multinameIndex) {
ret.add(new MethodParamsMultinameUsage(abcTags,this,multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
ret.add(new MethodParamsMultinameUsage(abcTags, this, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
break;
}
}
if (method_info.get(methodInfo).ret_type == multinameIndex) {
ret.add(new MethodReturnTypeMultinameUsage(abcTags,this,multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
ret.add(new MethodReturnTypeMultinameUsage(abcTags, this, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
}
MethodBody body = findBody(methodInfo);
if (body != null) {
findMultinameUsageInTraits(abcTags,body.traits, multinameIndex, isStatic, classIndex, ret, traitIndex);
findMultinameUsageInTraits(abcTags, body.traits, multinameIndex, isStatic, classIndex, ret, traitIndex);
for (ABCException e : body.exceptions) {
if ((e.name_index == multinameIndex) || (e.type_index == multinameIndex)) {
ret.add(new MethodBodyMultinameUsage(abcTags,this,multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
ret.add(new MethodBodyMultinameUsage(abcTags, this, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
return;
}
}
@@ -826,7 +826,7 @@ public class ABC {
for (int o = 0; o < ins.definition.operands.length; o++) {
if (ins.definition.operands[o] == AVM2Code.DAT_MULTINAME_INDEX) {
if (ins.operands[o] == multinameIndex) {
ret.add(new MethodBodyMultinameUsage(abcTags,this,multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
ret.add(new MethodBodyMultinameUsage(abcTags, this, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex));
return;
}
}
@@ -835,70 +835,70 @@ public class ABC {
}
}
private void findMultinameUsageInTraits(List<ABCContainerTag> abcTags,Traits traits, int multinameIndex, boolean isStatic, int classIndex, List<MultinameUsage> ret, int parentTraitIndex) {
private void findMultinameUsageInTraits(List<ABCContainerTag> abcTags, Traits traits, int multinameIndex, boolean isStatic, int classIndex, List<MultinameUsage> ret, int parentTraitIndex) {
for (int t = 0; t < traits.traits.size(); t++) {
if (traits.traits.get(t) instanceof TraitSlotConst) {
TraitSlotConst tsc = (TraitSlotConst) traits.traits.get(t);
if (tsc.name_index == multinameIndex) {
ret.add(new ConstVarNameMultinameUsage(abcTags,this,multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex));
ret.add(new ConstVarNameMultinameUsage(abcTags, this, multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex));
}
if (tsc.type_index == multinameIndex) {
ret.add(new ConstVarTypeMultinameUsage(abcTags,this,multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex));
ret.add(new ConstVarTypeMultinameUsage(abcTags, this, multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex));
}
}
if (traits.traits.get(t) instanceof TraitMethodGetterSetter) {
TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) traits.traits.get(t);
if (tmgs.name_index == multinameIndex) {
ret.add(new MethodNameMultinameUsage(abcTags,this,multinameIndex, classIndex, t, isStatic, false, traits, parentTraitIndex));
ret.add(new MethodNameMultinameUsage(abcTags, this, multinameIndex, classIndex, t, isStatic, false, traits, parentTraitIndex));
}
checkMultinameUsedInMethod(abcTags,multinameIndex, tmgs.method_info, ret, classIndex, t, isStatic, false, traits, parentTraitIndex);
checkMultinameUsedInMethod(abcTags, multinameIndex, tmgs.method_info, ret, classIndex, t, isStatic, false, traits, parentTraitIndex);
}
}
}
public List<MultinameUsage> findMultinameDefinition(List<ABCContainerTag> abcTags,int multinameIndex){
List<MultinameUsage> usages = findMultinameUsage(abcTags,multinameIndex);
public List<MultinameUsage> findMultinameDefinition(List<ABCContainerTag> abcTags, int multinameIndex) {
List<MultinameUsage> usages = findMultinameUsage(abcTags, multinameIndex);
List<MultinameUsage> ret = new ArrayList<>();
for(MultinameUsage u:usages){
if(u instanceof DefinitionUsage){
for (MultinameUsage u : usages) {
if (u instanceof DefinitionUsage) {
ret.add(u);
}
}
return ret;
}
public List<MultinameUsage> findMultinameUsage(List<ABCContainerTag> abcTags,int multinameIndex) {
public List<MultinameUsage> findMultinameUsage(List<ABCContainerTag> abcTags, int multinameIndex) {
List<MultinameUsage> ret = new ArrayList<>();
if (multinameIndex == 0) {
return ret;
}
for (int c = 0; c < instance_info.size(); c++) {
if (instance_info.get(c).name_index == multinameIndex) {
ret.add(new ClassNameMultinameUsage(abcTags,this,multinameIndex, c));
ret.add(new ClassNameMultinameUsage(abcTags, this, multinameIndex, c));
}
if (instance_info.get(c).super_index == multinameIndex) {
ret.add(new ExtendsMultinameUsage(abcTags,this,multinameIndex, c));
ret.add(new ExtendsMultinameUsage(abcTags, this, multinameIndex, c));
}
for (int i = 0; i < instance_info.get(c).interfaces.length; i++) {
if (instance_info.get(c).interfaces[i] == multinameIndex) {
ret.add(new ImplementsMultinameUsage(abcTags,this,multinameIndex, c));
ret.add(new ImplementsMultinameUsage(abcTags, this, multinameIndex, c));
}
}
checkMultinameUsedInMethod(abcTags,multinameIndex, instance_info.get(c).iinit_index, ret, c, 0, false, true, null, -1);
checkMultinameUsedInMethod(abcTags,multinameIndex, class_info.get(c).cinit_index, ret, c, 0, true, true, null, -1);
findMultinameUsageInTraits(abcTags,instance_info.get(c).instance_traits, multinameIndex, false, c, ret, -1);
findMultinameUsageInTraits(abcTags,class_info.get(c).static_traits, multinameIndex, true, c, ret, -1);
checkMultinameUsedInMethod(abcTags, multinameIndex, instance_info.get(c).iinit_index, ret, c, 0, false, true, null, -1);
checkMultinameUsedInMethod(abcTags, multinameIndex, class_info.get(c).cinit_index, ret, c, 0, true, true, null, -1);
findMultinameUsageInTraits(abcTags, instance_info.get(c).instance_traits, multinameIndex, false, c, ret, -1);
findMultinameUsageInTraits(abcTags, class_info.get(c).static_traits, multinameIndex, true, c, ret, -1);
}
loopm:
for (int m = 1; m < constants.getMultinameCount(); m++) {
if (constants.getMultiname(m).kind == Multiname.TYPENAME) {
if (constants.getMultiname(m).qname_index == multinameIndex) {
ret.add(new TypeNameMultinameUsage(abcTags,this,m));
ret.add(new TypeNameMultinameUsage(abcTags, this, m));
continue;
}
for (int mp : constants.getMultiname(m).params) {
if (mp == multinameIndex) {
ret.add(new TypeNameMultinameUsage(abcTags,this,m));
ret.add(new TypeNameMultinameUsage(abcTags, this, m));
continue loopm;
}
}
@@ -947,36 +947,36 @@ public class ABC {
}
return -1;
}
public List<ScriptPack> findScriptPacksByPath(String name) {
List<ScriptPack> ret = new ArrayList<>();
List<MyEntry<ClassPath, ScriptPack>> allPacks = getScriptPacks();
if(name.endsWith(".**")||name.equals("**")||name.endsWith(".++") || name.equals("++")){
name = name.substring(0,name.length()-2);
if (name.endsWith(".**") || name.equals("**") || name.endsWith(".++") || name.equals("++")) {
name = name.substring(0, name.length() - 2);
for (MyEntry<ClassPath, ScriptPack> en : allPacks) {
if (en.key.toString().startsWith(name)) {
ret.add(en.value);
}
}
} else if(name.endsWith(".*")||name.equals("*")||name.endsWith(".+")||name.equals("+")){
name = name.substring(0,name.length()-1);
} else if (name.endsWith(".*") || name.equals("*") || name.endsWith(".+") || name.equals("+")) {
name = name.substring(0, name.length() - 1);
for (MyEntry<ClassPath, ScriptPack> en : allPacks) {
if (en.key.toString().startsWith(name)) {
String rem = name.isEmpty()?en.key.toString():en.key.toString().substring(name.length());
if(!rem.contains(".")){
String rem = name.isEmpty() ? en.key.toString() : en.key.toString().substring(name.length());
if (!rem.contains(".")) {
ret.add(en.value);
}
}
}
} else {
ScriptPack p = findScriptPackByPath(name);
if(p!=null){
if (p != null) {
ret.add(p);
}
}
}
return ret;
}
public ScriptPack findScriptPackByPath(String name) {

View File

@@ -1,74 +1,74 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.CallAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallMethodAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallStaticAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class PopIns extends InstructionDefinition {
public PopIns() {
super(0x29, "pop", new int[]{});
}
@Override
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
lda.operandStack.pop();
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
if (stack.size() > 0) {
GraphTargetItem top = stack.pop();
//TODO: handle all values (#585) - beware collision with return inside finally block
if (top instanceof CallPropertyAVM2Item) {
output.add(top);
} else if (top instanceof CallSuperAVM2Item) {
output.add(top);
} else if (top instanceof CallStaticAVM2Item) {
output.add(top);
} else if (top instanceof CallMethodAVM2Item) {
output.add(top);
} else if (top instanceof CallAVM2Item) {
output.add(top);
} else if (top instanceof AssignmentAVM2Item) {
output.add(top);
}
}
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.CallAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallMethodAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallStaticAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class PopIns extends InstructionDefinition {
public PopIns() {
super(0x29, "pop", new int[]{});
}
@Override
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
lda.operandStack.pop();
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
if (stack.size() > 0) {
GraphTargetItem top = stack.pop();
//TODO: handle all values (#585) - beware collision with return inside finally block
if (top instanceof CallPropertyAVM2Item) {
output.add(top);
} else if (top instanceof CallSuperAVM2Item) {
output.add(top);
} else if (top instanceof CallStaticAVM2Item) {
output.add(top);
} else if (top instanceof CallMethodAVM2Item) {
output.add(top);
} else if (top instanceof CallAVM2Item) {
output.add(top);
} else if (top instanceof AssignmentAVM2Item) {
output.add(top);
}
}
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}

View File

@@ -2424,10 +2424,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
@Override
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException {
List<GraphSourceItem> ret=item.toSource(localData, this);
List<GraphSourceItem> ret = item.toSource(localData, this);
ret.add(ins(new PopIns()));
return ret;
}
}

View File

@@ -1,37 +1,37 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ClassNameMultinameUsage extends InsideClassMultinameUsage implements DefinitionUsage {
public ClassNameMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex) {
super(abcTags,abc,multinameIndex, classIndex);
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants);
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ClassNameMultinameUsage extends InsideClassMultinameUsage implements DefinitionUsage {
public ClassNameMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex) {
super(abcTags, abc, multinameIndex, classIndex);
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants);
}
}

View File

@@ -35,7 +35,7 @@ import java.util.List;
public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
public ConstVarMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
}
@Override
@@ -66,7 +66,7 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
try {
((TraitSlotConst) traits.traits.get(traitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} catch (InterruptedException ex) {
//ignore
//ignore
}
return writer.toString();
}

View File

@@ -1,38 +1,38 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage implements DefinitionUsage {
public ConstVarNameMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " name";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage implements DefinitionUsage {
public ConstVarNameMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " name";
}
}

View File

@@ -1,38 +1,38 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage {
public ConstVarTypeMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " type";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage {
public ConstVarTypeMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " type";
}
}

View File

@@ -1,26 +1,25 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
/**
*
* @author JPEXS
*/
public interface DefinitionUsage {
}
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
/**
*
* @author JPEXS
*/
public interface DefinitionUsage {
}

View File

@@ -1,37 +1,37 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ExtendsMultinameUsage extends InsideClassMultinameUsage {
public ExtendsMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex) {
super(abcTags,abc,multinameIndex, classIndex);
}
@Override
public String toString() {
return super.toString() + " extends";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ExtendsMultinameUsage extends InsideClassMultinameUsage {
public ExtendsMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex) {
super(abcTags, abc, multinameIndex, classIndex);
}
@Override
public String toString() {
return super.toString() + " extends";
}
}

View File

@@ -1,37 +1,37 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ImplementsMultinameUsage extends InsideClassMultinameUsage {
public ImplementsMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex) {
super(abcTags,abc,multinameIndex, classIndex);
}
@Override
public String toString() {
return super.toString() + " implements";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ImplementsMultinameUsage extends InsideClassMultinameUsage {
public ImplementsMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex) {
super(abcTags, abc, multinameIndex, classIndex);
}
@Override
public String toString() {
return super.toString() + " implements";
}
}

View File

@@ -1,50 +1,50 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class InsideClassMultinameUsage extends MultinameUsage {
public int multinameIndex;
public int classIndex;
public InsideClassMultinameUsage(List<ABCContainerTag> abcTags, ABC abc,int multinameIndex, int classIndex) {
super(abcTags, abc);
this.multinameIndex = multinameIndex;
this.classIndex = classIndex;
}
@Override
public String toString(){
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants);
}
public int getMultinameIndex() {
return multinameIndex;
}
public int getClassIndex() {
return classIndex;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class InsideClassMultinameUsage extends MultinameUsage {
public int multinameIndex;
public int classIndex;
public InsideClassMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex) {
super(abcTags, abc);
this.multinameIndex = multinameIndex;
this.classIndex = classIndex;
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants);
}
public int getMultinameIndex() {
return multinameIndex;
}
public int getClassIndex() {
return classIndex;
}
}

View File

@@ -1,38 +1,38 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodBodyMultinameUsage extends MethodMultinameUsage {
public MethodBodyMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " body";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodBodyMultinameUsage extends MethodMultinameUsage {
public MethodBodyMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " body";
}
}

View File

@@ -1,91 +1,91 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class MethodMultinameUsage extends TraitMultinameUsage {
public boolean isInitializer;
public MethodMultinameUsage(List<ABCContainerTag> abcTags, ABC abc,int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
this.isInitializer = isInitializer;
}
public boolean isInitializer() {
return isInitializer;
}
@Override
public String toString() {
NulWriter nulWriter = new NulWriter();
if (!isInitializer) {
if (parentTraitIndex > -1) {
if (isStatic) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
}
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
}
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString());
writer.appendNoHilight(" ");
if (isInitializer) {
if (isStatic) {
writer.appendNoHilight("class initializer");
} else {
writer.appendNoHilight("instance initializer");
}
} else {
if (parentTraitIndex > -1) {
if (isStatic) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
writer.appendNoHilight(" ");
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
return writer.toString();
}
public int getTraitIndex() {
return traitIndex;
}
public boolean isStatic() {
return isStatic;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class MethodMultinameUsage extends TraitMultinameUsage {
public boolean isInitializer;
public MethodMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex);
this.isInitializer = isInitializer;
}
public boolean isInitializer() {
return isInitializer;
}
@Override
public String toString() {
NulWriter nulWriter = new NulWriter();
if (!isInitializer) {
if (parentTraitIndex > -1) {
if (isStatic) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
}
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
}
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString());
writer.appendNoHilight(" ");
if (isInitializer) {
if (isStatic) {
writer.appendNoHilight("class initializer");
} else {
writer.appendNoHilight("instance initializer");
}
} else {
if (parentTraitIndex > -1) {
if (isStatic) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
writer.appendNoHilight(" ");
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
return writer.toString();
}
public int getTraitIndex() {
return traitIndex;
}
public boolean isStatic() {
return isStatic;
}
}

View File

@@ -1,38 +1,38 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodNameMultinameUsage extends MethodMultinameUsage implements DefinitionUsage {
public MethodNameMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags,abc, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " name";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodNameMultinameUsage extends MethodMultinameUsage implements DefinitionUsage {
public MethodNameMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " name";
}
}

View File

@@ -1,38 +1,38 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodParamsMultinameUsage extends MethodMultinameUsage {
public MethodParamsMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " params";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodParamsMultinameUsage extends MethodMultinameUsage {
public MethodParamsMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " params";
}
}

View File

@@ -1,38 +1,38 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage {
public MethodReturnTypeMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " return type";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage {
public MethodReturnTypeMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex);
}
@Override
public String toString() {
return super.toString() + " return type";
}
}

View File

@@ -1,36 +1,37 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class MultinameUsage {
public List<ABCContainerTag> abcTags;
public ABC abc;
public MultinameUsage(List<ABCContainerTag> abcTags, ABC abc) {
this.abcTags = abcTags;
this.abc = abc;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class MultinameUsage {
public List<ABCContainerTag> abcTags;
public ABC abc;
public MultinameUsage(List<ABCContainerTag> abcTags, ABC abc) {
this.abcTags = abcTags;
this.abc = abc;
}
}

View File

@@ -1,42 +1,42 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class TraitMultinameUsage extends InsideClassMultinameUsage {
public int traitIndex;
public boolean isStatic;
public Traits traits;
public int parentTraitIndex;
public TraitMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) {
super(abcTags,abc,multinameIndex, classIndex);
this.traitIndex = traitIndex;
this.isStatic = isStatic;
this.traits = traits;
this.parentTraitIndex = parentTraitIndex;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class TraitMultinameUsage extends InsideClassMultinameUsage {
public int traitIndex;
public boolean isStatic;
public Traits traits;
public int parentTraitIndex;
public TraitMultinameUsage(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) {
super(abcTags, abc, multinameIndex, classIndex);
this.traitIndex = traitIndex;
this.isStatic = isStatic;
this.traits = traits;
this.parentTraitIndex = parentTraitIndex;
}
}

View File

@@ -84,7 +84,7 @@ public class TellTargetActionItem extends ActionItem {
public boolean needsSemicolon() {
return false;
}
@Override
public boolean hasReturnValue() {
return false;

View File

@@ -779,11 +779,9 @@ public class ActionSourceGenerator implements SourceGenerator {
@Override
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException {
List<GraphSourceItem> ret=item.toSource(localData, this);
List<GraphSourceItem> ret = item.toSource(localData, this);
ret.add(new ActionPop());
return ret;
}
}

View File

@@ -384,16 +384,16 @@ public class Configuration {
String path = "." + applicationId + "/";
directory = new File(userHome, path);
}
}else{
} else {
//no home, then use application directory
directory = new File(".");
}
}
if (!directory.exists()) {
if (!directory.mkdirs()) {
if (!directory.exists()) {
directory = new File("."); //fallback to current directory
}
if (!directory.exists()) {
directory = new File("."); //fallback to current directory
}
}
}
String ret = directory.getAbsolutePath();
@@ -520,7 +520,7 @@ public class Configuration {
@SuppressWarnings("unchecked")
HashMap<String, Object> cfg = (HashMap<String, Object>) ois.readObject();
config = cfg;
config = cfg;
} catch (ClassNotFoundException | IOException ex) {
//ignore
}

View File

@@ -33,17 +33,17 @@ public class DumpInfo {
public long startByte;
public int startBit;
public long lengthBytes;
public int lengthBits;
public DumpInfo parent;
public List<DumpInfo> childInfos = new ArrayList<>();
public DumpInfo(String name, String type, Object value, long startByte, int lengthBytes) {
this.name = name;
this.type = type;
this.previewValue = value;
@@ -52,7 +52,7 @@ public class DumpInfo {
}
public DumpInfo(String name, String type, Object value, long startByte, int startBit, long lengthBytes, int lengthBits) {
this.name = name;
this.type = type;
this.previewValue = value;

View File

@@ -1,57 +1,56 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.AppStrings;
import com.jpexs.decompiler.flash.configuration.Configuration;
import java.awt.Window;
import java.util.ResourceBundle;
import javax.swing.JDialog;
import javax.swing.JRootPane;
/**
*
* @author JPEXS
*/
public abstract class AppDialog extends JDialog {
private ResourceBundle resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
public AppDialog() {
View.installEscapeCloseOperation(this);
if (Configuration.useRibbonInterface.get()) {
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
}
}
public AppDialog(Window owner) {
super(owner);
View.installEscapeCloseOperation(this);
if (Configuration.useRibbonInterface.get()) {
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
}
}
public String translate(String key) {
return resourceBundle.getString(key);
}
public void updateLanguage() {
resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.AppStrings;
import com.jpexs.decompiler.flash.configuration.Configuration;
import java.awt.Window;
import java.util.ResourceBundle;
import javax.swing.JDialog;
import javax.swing.JRootPane;
/**
*
* @author JPEXS
*/
public abstract class AppDialog extends JDialog {
private ResourceBundle resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
public AppDialog() {
View.installEscapeCloseOperation(this);
if (Configuration.useRibbonInterface.get()) {
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
}
}
public AppDialog(Window owner) {
super(owner);
View.installEscapeCloseOperation(this);
if (Configuration.useRibbonInterface.get()) {
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
}
}
public String translate(String key) {
return resourceBundle.getString(key);
}
public void updateLanguage() {
resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
}
}

View File

@@ -31,7 +31,7 @@ import javax.swing.tree.TreeModel;
* @author JPEXS
*/
public class DumpTree extends JTree {
public class DumpTreeCellRenderer extends DefaultTreeCellRenderer {
@Override
@@ -50,7 +50,6 @@ public class DumpTree extends JTree {
hasFocus);
//DumpInfo dumpInfo = (DumpInfo) value;
setUI(new BasicLabelUI());
setOpaque(false);
setBackgroundNonSelectionColor(Color.white);
@@ -83,7 +82,5 @@ public class DumpTree extends JTree {
}
}
}
}

View File

@@ -31,7 +31,7 @@ import javax.swing.tree.TreePath;
public class DumpTreeModel implements TreeModel {
private final DumpInfo root;
public DumpTreeModel(List<SWFList> swfs) {
DumpInfo root = new DumpInfo("root", "", null, 0, 0);
for (SWFList swfList : swfs) {
@@ -42,7 +42,7 @@ public class DumpTreeModel implements TreeModel {
}
this.root = root;
}
@Override
public Object getRoot() {
return root;
@@ -80,5 +80,5 @@ public class DumpTreeModel implements TreeModel {
@Override
public void removeTreeModelListener(TreeModelListener tl) {
}
}

View File

@@ -34,19 +34,19 @@ import javax.swing.table.TableColumnModel;
* @author JPEXS
*/
public class DumpViewPanel extends JPanel {
private final int bytesInRow = 16;
private final JLabel dumpViewLabel;
private final JTable dumpViewHexTable;
private byte[] data;
public DumpViewPanel() {
super(new BorderLayout());
dumpViewLabel = new JLabel();
dumpViewLabel.setMinimumSize(new Dimension(100, 20));
add(dumpViewLabel, BorderLayout.SOUTH);
dumpViewHexTable = new JTable();
dumpViewHexTable.setBackground(Color.white);
dumpViewHexTable.setFont(new Font("Monospaced", Font.PLAIN, 12));
@@ -81,7 +81,7 @@ public class DumpViewPanel extends JPanel {
@Override
public int getColumnCount() {
return 2*bytesInRow + 1;
return 2 * bytesInRow + 1;
}
@Override
@@ -93,7 +93,7 @@ public class DumpViewPanel extends JPanel {
}
return "";
}
@Override
public Object getValueAt(int row, int column) {
if (column == 0) {
@@ -107,7 +107,7 @@ public class DumpViewPanel extends JPanel {
} else {
int pos = row * bytesInRow + column - bytesInRow - 1;
if (pos < data.length) {
return (char)data[pos];
return (char) data[pos];
}
return null;
}
@@ -115,11 +115,11 @@ public class DumpViewPanel extends JPanel {
});
add(new JScrollPane(dumpViewHexTable), BorderLayout.CENTER);
}
public void setData(byte[] data) {
this.data = data;
}
public void setLabelText(String text) {
dumpViewLabel.setText(text);
}

View File

@@ -1,336 +1,336 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphPart;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Window;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author JPEXS
*/
public class GraphDialog extends AppDialog {
private class GraphPanel extends JPanel {
private static final int SPACE_VERTICAL = 16;
private static final int SPACE_HORIZONTAL = 10;
private static final int SPACE_BACKLINKS = 5;
private static final int BLOCK_WIDTH = 200;
private static final int BLOCK_HEIGHT = 20;
private final HashMap<GraphPart, Point> partPos = new HashMap<>();
private final Point size;
private int backLinksLeft = 0;
private int backLinksRight = 0;
private final GraphPart head;
public GraphPanel(Graph graph) throws InterruptedException {
graph.init(null);
size = getPartPositions(head = graph.heads.get(0), SPACE_VERTICAL + SPACE_VERTICAL + BLOCK_HEIGHT / 2, getPartWidth(graph.heads.get(0), new HashSet<GraphPart>()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2 - SPACE_HORIZONTAL, partPos, true);
backLinksLeft = 1;
backLinksRight = 1;
for (GraphPart part : partPos.keySet()) {
Point p = partPos.get(part);
for (GraphPart n : part.nextParts) {
Point npos = partPos.get(n);
if (npos.y < p.y) {
if (p.x > size.x / 2) {
backLinksRight++;
} else {
backLinksLeft++;
}
}
}
}
size.x += 2 * SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS + backLinksRight * SPACE_BACKLINKS;
setPreferredSize(new Dimension(size.x, size.y));
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
/*g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);*/
g2.setColor(Color.black);
int startX = SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS;
int blLeft = 0;
int blRight = 0;
for (GraphPart part : partPos.keySet()) {
Point p = partPos.get(part);
g2.setColor(Color.white);
g2.fillRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
g2.setColor(Color.black);
g2.drawRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
g2.drawString(part.toString(), startX + p.x - g2.getFontMetrics().stringWidth(part.toString()) / 2, p.y + g2.getFontMetrics().getHeight() / 2);
}
Point hp = partPos.get(head);
drawArrow(g2, startX + hp.x, hp.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL, startX + hp.x, hp.y - BLOCK_HEIGHT / 2);
for (GraphPart part : partPos.keySet()) {
Point p = partPos.get(part);
for (int n = 0; n < part.nextParts.size(); n++) {
boolean isIf = part.nextParts.size() == 2;
if (isIf) {
if (n == 0) {
g2.setColor(new Color(0, 0x80, 0));
} else {
g2.setColor(Color.red);
}
} else {
g2.setColor(Color.black);
}
Point npos = partPos.get(part.nextParts.get(n));
if (npos.y < p.y) {
int sidex = startX;
if (p.x > size.x / 2) {
blRight++;
sidex = size.x - backLinksRight * SPACE_BACKLINKS;
sidex += SPACE_BACKLINKS + SPACE_BACKLINKS * blRight;
} else {
blLeft++;
sidex -= SPACE_BACKLINKS + SPACE_BACKLINKS * blLeft;
}
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
g2.drawLine(sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
drawArrow(g2, sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
} else {
drawArrow(g2, startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
}
}
}
}
private Point getPartSubPositions(Point ret, int totalWidth, GraphPart part, int y, int x, HashMap<GraphPart, Point> used) {
if (used.containsKey(part)) {
Point p = used.get(part);
return new Point(x, y);
}
used.put(part, new Point(x, y));
if (part.nextParts.size() > 0) {
int cx = x - totalWidth / 2;
for (int p = 0; p < part.nextParts.size(); p++) {
HashSet<GraphPart> k = new HashSet<>();
k.addAll(used.keySet());
int partWidth = getPartWidth(part.nextParts.get(p), k);
int cellWidth = partWidth * (BLOCK_WIDTH + SPACE_HORIZONTAL);
Point pt = getPartPositions(part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used, false);
if (pt.x > ret.x) {
ret.x = pt.x;
}
if (pt.y > ret.y) {
ret.y = pt.y;
}
cx += cellWidth;
}
cx = x - totalWidth / 2;
for (int p = 0; p < part.nextParts.size(); p++) {
HashSet<GraphPart> k = new HashSet<>();
k.addAll(used.keySet());
int cellWidth = getPartWidth(part.nextParts.get(p), k) * (BLOCK_WIDTH + SPACE_HORIZONTAL);
HashSet<GraphPart> hs = new HashSet<>();
hs.addAll(used.keySet());
int totalWidthParts2 = getPartWidth(part.nextParts.get(p), hs);
int totalWidth2 = totalWidthParts2 * (BLOCK_WIDTH + SPACE_HORIZONTAL);
Point pt = getPartSubPositions(ret, totalWidth2, part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used);
if (pt.x > ret.x) {
ret.x = pt.x;
}
if (pt.y > ret.y) {
ret.y = pt.y;
}
cx += cellWidth;
}
}
return ret;
}
private Point getPartPositions(GraphPart part, int y, int x, HashMap<GraphPart, Point> used, boolean goSub) {
HashMap<GraphPart, Point> l = new HashMap<>();
l.putAll(used);
HashSet<GraphPart> hs = new HashSet<>();
hs.addAll(l.keySet());
int totalWidthParts = getPartWidth(part, hs);
int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL);
if (used.containsKey(part)) {
Point p = used.get(part);
return new Point(x, y);
}
Point ret = new Point(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2 + BLOCK_WIDTH, y + BLOCK_HEIGHT);
if (goSub) {
Point p2 = getPartSubPositions(ret, totalWidth, part, y, x, used);
if (p2.x > ret.x) {
ret.x = p2.x;
}
if (p2.y > ret.y) {
ret.y = p2.y;
}
}
return ret;
}
private int getPartHeight(GraphPart part, List<GraphPart> used) {
if (used.contains(part)) {
return 1;
}
used.add(part);
int maxH = 0;
for (int p = 0; p < part.nextParts.size(); p++) {
int h = getPartHeight(part.nextParts.get(p), used);
if (h > maxH) {
maxH = h;
}
}
return 1 + maxH;
}
private int getPartWidth(GraphPart part, HashSet<GraphPart> used) {
if (used.contains(part)) {
return 1;
}
used.add(part);
if (part.nextParts.isEmpty()) {
return 1;
}
int w = 0;
for (GraphPart subpart : part.nextParts) {
w += getPartWidth(subpart, used);
}
return w;
}
}
GraphPanel gp;
int scrollBarWidth;
int scrollBarHeight;
int frameWidthDiff;
int frameHeightDiff;
public GraphDialog(Window owner,Graph graph, String name) throws InterruptedException {
super(owner);
setSize(500, 500);
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
gp = new GraphPanel(graph);
setTitle(translate("graph") + " " + name);
JScrollPane scrollPane = new JScrollPane(gp);
scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height;
cnt.add(scrollPane, BorderLayout.CENTER);
pack();
Dimension size = getSize();
Dimension innerSize = getContentPane().getSize();
frameWidthDiff = size.width - innerSize.width;
frameHeightDiff = size.height - innerSize.height;
View.setWindowIcon(this);
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
Dimension screen = getToolkit().getScreenSize();
Dimension dim = new Dimension(0, 0);
Dimension panDim = gp.getPreferredSize();
// add some magic constants
panDim = new Dimension(panDim.width + 3, panDim.height + 2);
boolean tooHigh = false;
boolean tooWide = false;
if (panDim.width + frameWidthDiff < screen.width) {
dim.width = panDim.width;
} else {
dim.width = screen.width;
tooWide = true;
}
if (panDim.height + frameHeightDiff < screen.height) {
dim.height = panDim.height;
} else {
dim.height = screen.height;
tooHigh = true;
}
if (tooWide) {
dim.height += scrollBarHeight;
dim.height = Math.min(dim.height, screen.height);
}
if (tooHigh) {
dim.width += scrollBarWidth;
dim.width = Math.min(dim.width, screen.width);
}
setVisibleSize(dim);
View.centerScreen(this);
}
private void setVisibleSize(Dimension dim) {
setSize(new Dimension(dim.width + frameWidthDiff, dim.height + frameHeightDiff));
}
private void drawArrow(Graphics g, int x1, int y1, int x2, int y2) {
Polygon arrowHead = new Polygon();
arrowHead.addPoint(0, 0);
arrowHead.addPoint(-3, -8);
arrowHead.addPoint(3, -8);
Line2D.Double line = new Line2D.Double(x1, y1, x2, y2);
AffineTransform tx = new AffineTransform();
tx.setToIdentity();
double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
tx.translate(line.x2, line.y2);
tx.rotate((angle - Math.PI / 2d));
Graphics2D g2d = (Graphics2D) g;
AffineTransform oldTransform = g2d.getTransform();
g2d.draw(line);
tx.preConcatenate(oldTransform);
g2d.setTransform(tx);
g2d.fill(arrowHead);
g2d.setTransform(oldTransform);
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphPart;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Window;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author JPEXS
*/
public class GraphDialog extends AppDialog {
private class GraphPanel extends JPanel {
private static final int SPACE_VERTICAL = 16;
private static final int SPACE_HORIZONTAL = 10;
private static final int SPACE_BACKLINKS = 5;
private static final int BLOCK_WIDTH = 200;
private static final int BLOCK_HEIGHT = 20;
private final HashMap<GraphPart, Point> partPos = new HashMap<>();
private final Point size;
private int backLinksLeft = 0;
private int backLinksRight = 0;
private final GraphPart head;
public GraphPanel(Graph graph) throws InterruptedException {
graph.init(null);
size = getPartPositions(head = graph.heads.get(0), SPACE_VERTICAL + SPACE_VERTICAL + BLOCK_HEIGHT / 2, getPartWidth(graph.heads.get(0), new HashSet<GraphPart>()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2 - SPACE_HORIZONTAL, partPos, true);
backLinksLeft = 1;
backLinksRight = 1;
for (GraphPart part : partPos.keySet()) {
Point p = partPos.get(part);
for (GraphPart n : part.nextParts) {
Point npos = partPos.get(n);
if (npos.y < p.y) {
if (p.x > size.x / 2) {
backLinksRight++;
} else {
backLinksLeft++;
}
}
}
}
size.x += 2 * SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS + backLinksRight * SPACE_BACKLINKS;
setPreferredSize(new Dimension(size.x, size.y));
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
/*g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);*/
g2.setColor(Color.black);
int startX = SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS;
int blLeft = 0;
int blRight = 0;
for (GraphPart part : partPos.keySet()) {
Point p = partPos.get(part);
g2.setColor(Color.white);
g2.fillRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
g2.setColor(Color.black);
g2.drawRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
g2.drawString(part.toString(), startX + p.x - g2.getFontMetrics().stringWidth(part.toString()) / 2, p.y + g2.getFontMetrics().getHeight() / 2);
}
Point hp = partPos.get(head);
drawArrow(g2, startX + hp.x, hp.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL, startX + hp.x, hp.y - BLOCK_HEIGHT / 2);
for (GraphPart part : partPos.keySet()) {
Point p = partPos.get(part);
for (int n = 0; n < part.nextParts.size(); n++) {
boolean isIf = part.nextParts.size() == 2;
if (isIf) {
if (n == 0) {
g2.setColor(new Color(0, 0x80, 0));
} else {
g2.setColor(Color.red);
}
} else {
g2.setColor(Color.black);
}
Point npos = partPos.get(part.nextParts.get(n));
if (npos.y < p.y) {
int sidex = startX;
if (p.x > size.x / 2) {
blRight++;
sidex = size.x - backLinksRight * SPACE_BACKLINKS;
sidex += SPACE_BACKLINKS + SPACE_BACKLINKS * blRight;
} else {
blLeft++;
sidex -= SPACE_BACKLINKS + SPACE_BACKLINKS * blLeft;
}
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
g2.drawLine(sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
drawArrow(g2, sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
} else {
drawArrow(g2, startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
}
}
}
}
private Point getPartSubPositions(Point ret, int totalWidth, GraphPart part, int y, int x, HashMap<GraphPart, Point> used) {
if (used.containsKey(part)) {
Point p = used.get(part);
return new Point(x, y);
}
used.put(part, new Point(x, y));
if (part.nextParts.size() > 0) {
int cx = x - totalWidth / 2;
for (int p = 0; p < part.nextParts.size(); p++) {
HashSet<GraphPart> k = new HashSet<>();
k.addAll(used.keySet());
int partWidth = getPartWidth(part.nextParts.get(p), k);
int cellWidth = partWidth * (BLOCK_WIDTH + SPACE_HORIZONTAL);
Point pt = getPartPositions(part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used, false);
if (pt.x > ret.x) {
ret.x = pt.x;
}
if (pt.y > ret.y) {
ret.y = pt.y;
}
cx += cellWidth;
}
cx = x - totalWidth / 2;
for (int p = 0; p < part.nextParts.size(); p++) {
HashSet<GraphPart> k = new HashSet<>();
k.addAll(used.keySet());
int cellWidth = getPartWidth(part.nextParts.get(p), k) * (BLOCK_WIDTH + SPACE_HORIZONTAL);
HashSet<GraphPart> hs = new HashSet<>();
hs.addAll(used.keySet());
int totalWidthParts2 = getPartWidth(part.nextParts.get(p), hs);
int totalWidth2 = totalWidthParts2 * (BLOCK_WIDTH + SPACE_HORIZONTAL);
Point pt = getPartSubPositions(ret, totalWidth2, part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used);
if (pt.x > ret.x) {
ret.x = pt.x;
}
if (pt.y > ret.y) {
ret.y = pt.y;
}
cx += cellWidth;
}
}
return ret;
}
private Point getPartPositions(GraphPart part, int y, int x, HashMap<GraphPart, Point> used, boolean goSub) {
HashMap<GraphPart, Point> l = new HashMap<>();
l.putAll(used);
HashSet<GraphPart> hs = new HashSet<>();
hs.addAll(l.keySet());
int totalWidthParts = getPartWidth(part, hs);
int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL);
if (used.containsKey(part)) {
Point p = used.get(part);
return new Point(x, y);
}
Point ret = new Point(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2 + BLOCK_WIDTH, y + BLOCK_HEIGHT);
if (goSub) {
Point p2 = getPartSubPositions(ret, totalWidth, part, y, x, used);
if (p2.x > ret.x) {
ret.x = p2.x;
}
if (p2.y > ret.y) {
ret.y = p2.y;
}
}
return ret;
}
private int getPartHeight(GraphPart part, List<GraphPart> used) {
if (used.contains(part)) {
return 1;
}
used.add(part);
int maxH = 0;
for (int p = 0; p < part.nextParts.size(); p++) {
int h = getPartHeight(part.nextParts.get(p), used);
if (h > maxH) {
maxH = h;
}
}
return 1 + maxH;
}
private int getPartWidth(GraphPart part, HashSet<GraphPart> used) {
if (used.contains(part)) {
return 1;
}
used.add(part);
if (part.nextParts.isEmpty()) {
return 1;
}
int w = 0;
for (GraphPart subpart : part.nextParts) {
w += getPartWidth(subpart, used);
}
return w;
}
}
GraphPanel gp;
int scrollBarWidth;
int scrollBarHeight;
int frameWidthDiff;
int frameHeightDiff;
public GraphDialog(Window owner, Graph graph, String name) throws InterruptedException {
super(owner);
setSize(500, 500);
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
gp = new GraphPanel(graph);
setTitle(translate("graph") + " " + name);
JScrollPane scrollPane = new JScrollPane(gp);
scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height;
cnt.add(scrollPane, BorderLayout.CENTER);
pack();
Dimension size = getSize();
Dimension innerSize = getContentPane().getSize();
frameWidthDiff = size.width - innerSize.width;
frameHeightDiff = size.height - innerSize.height;
View.setWindowIcon(this);
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
Dimension screen = getToolkit().getScreenSize();
Dimension dim = new Dimension(0, 0);
Dimension panDim = gp.getPreferredSize();
// add some magic constants
panDim = new Dimension(panDim.width + 3, panDim.height + 2);
boolean tooHigh = false;
boolean tooWide = false;
if (panDim.width + frameWidthDiff < screen.width) {
dim.width = panDim.width;
} else {
dim.width = screen.width;
tooWide = true;
}
if (panDim.height + frameHeightDiff < screen.height) {
dim.height = panDim.height;
} else {
dim.height = screen.height;
tooHigh = true;
}
if (tooWide) {
dim.height += scrollBarHeight;
dim.height = Math.min(dim.height, screen.height);
}
if (tooHigh) {
dim.width += scrollBarWidth;
dim.width = Math.min(dim.width, screen.width);
}
setVisibleSize(dim);
View.centerScreen(this);
}
private void setVisibleSize(Dimension dim) {
setSize(new Dimension(dim.width + frameWidthDiff, dim.height + frameHeightDiff));
}
private void drawArrow(Graphics g, int x1, int y1, int x2, int y2) {
Polygon arrowHead = new Polygon();
arrowHead.addPoint(0, 0);
arrowHead.addPoint(-3, -8);
arrowHead.addPoint(3, -8);
Line2D.Double line = new Line2D.Double(x1, y1, x2, y2);
AffineTransform tx = new AffineTransform();
tx.setToIdentity();
double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
tx.translate(line.x2, line.y2);
tx.rotate((angle - Math.PI / 2d));
Graphics2D g2d = (Graphics2D) g;
AffineTransform oldTransform = g2d.getTransform();
g2d.draw(line);
tx.preConcatenate(oldTransform);
g2d.setTransform(tx);
g2d.fill(arrowHead);
g2d.setTransform(oldTransform);
}
}

View File

@@ -1051,7 +1051,7 @@ public class Main {
// sometimes during development the version information is not available
return false;
}
List<String> accepted = new ArrayList<>();
if (Configuration.checkForUpdatesStable.get()) {
accepted.add("stable");

View File

@@ -1,38 +1,38 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import java.awt.Window;
/**
*
* @author JPEXS
*/
public interface MainFrame {
public void setTitle(String string);
public String translate(String key);
public MainPanel getPanel();
public boolean isVisible();
public void setVisible(boolean b);
public Window getWindow();
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import java.awt.Window;
/**
*
* @author JPEXS
*/
public interface MainFrame {
public void setTitle(String string);
public String translate(String key);
public MainPanel getPanel();
public boolean isVisible();
public void setVisible(boolean b);
public Window getWindow();
}

View File

@@ -124,6 +124,5 @@ public final class MainFrameClassic extends AppFrame implements MainFrame {
public Window getWindow() {
return this;
}
}

View File

@@ -116,8 +116,7 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame {
});
View.centerScreen(this);
}
private static void getApplicationMenuButtons(Component comp, List<JRibbonApplicationMenuButton> ret) {
@@ -220,9 +219,8 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame {
}
@Override
public Window getWindow() {
public Window getWindow() {
return this;
}
}

View File

@@ -283,8 +283,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
public MainFrame getMainFrame() {
return mainFrame;
}
static {
try {
@@ -441,7 +439,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
expandRecursiveMenuItem.setVisible(model.getChildCount(treeNode) > 0);
jumpToCharacterMenuItem.setVisible(item instanceof CharacterIdTag && !(item instanceof CharacterTag));
rawEditMenuItem.setVisible(item instanceof Tag);
}
@@ -2281,7 +2279,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (item == null) {
return;
}
showCard(CARDPREVIEWPANEL);
previewPanel.showGenericTagPanel((Tag) item);
}
@@ -2291,7 +2289,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (item == null || !(item instanceof CharacterIdTag)) {
return;
}
CharacterIdTag characterIdTag = (CharacterIdTag) item;
setTreeItem(item.getSwf().characters.get(characterIdTag.getCharacterId()));
}
@@ -2385,10 +2383,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
DumpInfo dumpInfo = (DumpInfo) e.getPath().getLastPathComponent();
if (dumpInfo.lengthBytes != 0 || dumpInfo.lengthBits != 0) {
// todo
dumpViewPanel.setLabelText("startByte: " + dumpInfo.startByte +
" startBit: " + dumpInfo.startBit +
" lengthBytes: " + dumpInfo.lengthBytes +
" lengthBits: " + dumpInfo.lengthBits);
dumpViewPanel.setLabelText("startByte: " + dumpInfo.startByte
+ " startBit: " + dumpInfo.startBit
+ " lengthBytes: " + dumpInfo.lengthBytes
+ " lengthBits: " + dumpInfo.lengthBits);
}
// todo honfika: support multiple swf
@@ -2396,7 +2394,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
dumpViewPanel.revalidate();
showCard(CARDDUMPVIEW);
}
@Override
public void valueChanged(TreeSelectionEvent e) {
Object source = e.getSource();

View File

@@ -93,7 +93,7 @@ public class PreviewImage extends JPanel {
@Override
public void actionPerformed(ActionEvent e) {
Tag tag = (Tag) treeItem;
Tag tag = (Tag) treeItem;
tag.getSwf().removeTag(tag, false);
mainPanel.refreshTree();
}
@@ -104,7 +104,7 @@ public class PreviewImage extends JPanel {
@Override
public void actionPerformed(ActionEvent e) {
Tag tag = (Tag) treeItem;
Tag tag = (Tag) treeItem;
tag.getSwf().removeTag(tag, true);
mainPanel.refreshTree();
}

View File

@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import java.awt.Color;
@@ -46,30 +45,29 @@ import jsyntaxpane.components.Markers;
* @author JPEXS
*/
public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpane.actions.QuickFindHandler {
public JTextField findTextField;
public JButton prevButton,nextButton;
public JCheckBox ignoreCaseCheckbox,regExpCheckbox,wrapCheckbox;
public JButton prevButton, nextButton;
public JCheckBox ignoreCaseCheckbox, regExpCheckbox, wrapCheckbox;
public JLabel statusLabel;
private final Markers.SimpleMarker marker = new Markers.SimpleMarker(Color.PINK);
private WeakReference<JTextComponent> target;
private WeakReference<DocumentSearchData> dsd;
private int oldCaretPosition;
public QuickFindPanel(){
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
private WeakReference<JTextComponent> target;
private WeakReference<DocumentSearchData> dsd;
private int oldCaretPosition;
public QuickFindPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
JPanel pan1 = new JPanel(new WrapLayout());
JPanel pan2 = new JPanel(new WrapLayout());
pan1.setAlignmentX(0);
pan2.setAlignmentX(0);
pan1.setAlignmentY(0);
pan2.setAlignmentY(0);
JLabel jLabel1 = new javax.swing.JLabel();
findTextField = new javax.swing.JTextField();
prevButton = new javax.swing.JButton();
@@ -78,21 +76,20 @@ public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpan
regExpCheckbox = new javax.swing.JCheckBox();
wrapCheckbox = new javax.swing.JCheckBox();
statusLabel = new javax.swing.JLabel();
setName("QuickFindDialog"); // NOI18N
jLabel1.setLabelFor(findTextField);
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N
jLabel1.setText(bundle.getString("QuickFindDialog.jLabel1.text")); // NOI18N
pan1.add(jLabel1);
findTextField.setColumns(30);
findTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
findTextField.setMaximumSize(new java.awt.Dimension(200, 24));
findTextField.setMinimumSize(new java.awt.Dimension(60, 24));
pan1.add(findTextField);
prevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-up.png"))); // NOI18N
prevButton.setFocusable(false);
prevButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@@ -136,124 +133,117 @@ public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpan
pan2.add(wrapCheckbox);
wrapCheckbox.addActionListener(this);
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize()-2));
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize() - 2));
statusLabel.setForeground(java.awt.Color.red);
pan2.add(statusLabel);
add(pan1);
add(pan2);
setPreferredSize(getMinimumSize());
setVisible(false);
setVisible(false);
}
@Override
public void actionPerformed(ActionEvent e) {
switch(e.getActionCommand()){
switch (e.getActionCommand()) {
case "PREVIOUS":
if (dsd.get().doFindPrev(target.get())) {
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
break;
case "NEXT":
if (dsd.get().doFindNext(target.get())) {
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
break;
}
}
@Override
public void showQuickFind(final JTextComponent t,DocumentSearchData ds) {
public void showQuickFind(final JTextComponent t, DocumentSearchData ds) {
dsd = new WeakReference<DocumentSearchData>(ds);
oldCaretPosition = t.getCaretPosition();
Container view = t.getParent();
Dimension wd = getSize();
wd.width = t.getVisibleRect().width;
Point loc = new Point(0, view.getHeight());
setSize(wd);
SwingUtilities.convertPointToScreen(loc, view);
setLocation(loc);
findTextField.setFont(t.getFont());
final DocumentListener dl;
findTextField.getDocument().addDocumentListener(dl = new DocumentListener() {
Container view = t.getParent();
Dimension wd = getSize();
wd.width = t.getVisibleRect().width;
Point loc = new Point(0, view.getHeight());
setSize(wd);
SwingUtilities.convertPointToScreen(loc, view);
setLocation(loc);
findTextField.setFont(t.getFont());
final DocumentListener dl;
findTextField.getDocument().addDocumentListener(dl = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updateFind();
}
public void insertUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateFind();
}
private void updateFind() {
JTextComponent t = target.get();
DocumentSearchData d = dsd.get();
String toFind = findTextField.getText();
if (toFind == null || toFind.isEmpty()) {
statusLabel.setText(null);
return;
}
try {
d.setWrap(wrapCheckbox.isSelected());
d.setPattern(toFind,
regExpCheckbox.isSelected(),
ignoreCaseCheckbox.isSelected());
// The dsd doFindNext will always find from current pos,
// so we need to relocate to our saved pos before we call doFindNext
statusLabel.setText(null);
t.setCaretPosition(oldCaretPosition);
if (!d.doFindNext(t)) {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
} else {
statusLabel.setText(null);
}
} catch (PatternSyntaxException e) {
statusLabel.setText(e.getDescription());
}
private void updateFind() {
JTextComponent t = target.get();
DocumentSearchData d = dsd.get();
String toFind = findTextField.getText();
if (toFind == null || toFind.isEmpty()) {
statusLabel.setText(null);
return;
}
try {
d.setWrap(wrapCheckbox.isSelected());
d.setPattern(toFind,
regExpCheckbox.isSelected(),
ignoreCaseCheckbox.isSelected());
// The dsd doFindNext will always find from current pos,
// so we need to relocate to our saved pos before we call doFindNext
statusLabel.setText(null);
t.setCaretPosition(oldCaretPosition);
if (!d.doFindNext(t)) {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
} else {
statusLabel.setText(null);
}
} catch (PatternSyntaxException e) {
statusLabel.setText(e.getDescription());
}
}
});
this.target = new WeakReference<>(t);
Pattern p = dsd.get().getPattern();
if (p != null) {
findTextField.setText(p.pattern());
}
});
this.target = new WeakReference<>(t);
Pattern p = dsd.get().getPattern();
if (p != null) {
findTextField.setText(p.pattern());
}
wrapCheckbox.setSelected(dsd.get().isWrap());
setVisible(true);
wrapCheckbox.setSelected(dsd.get().isWrap());
setVisible(true);
getParent().revalidate();
getParent().repaint();
getParent().repaint();
findTextField.requestFocusInWindow();
}
/*
@Override
public void focusGained(FocusEvent e) {
/*
@Override
public void focusGained(FocusEvent e) {
}
}
@Override
public void focusLost(FocusEvent e) {
removeFocusListener(this);
setVisible(false);
getParent().revalidate();
getParent().repaint();
}*/
@Override
public void focusLost(FocusEvent e) {
removeFocusListener(this);
setVisible(false);
getParent().revalidate();
getParent().repaint();
}*/
}

View File

@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import java.awt.BorderLayout;
@@ -39,25 +38,26 @@ import javax.swing.SwingUtilities;
* @author JPEXS
* @param <E>
*/
public class SearchResultsDialog<E> extends AppDialog implements ActionListener{
public class SearchResultsDialog<E> extends AppDialog implements ActionListener {
private final JList<E> resultsList;
private final DefaultListModel<E> model;
private final SearchListener<E> listener;
static final String ACTION_GOTO = "GOTO";
static final String ACTION_CANCEL = "CLOSE";
private final JButton gotoButton = new JButton(translate("button.goto"));
private final JButton closeButton = new JButton(translate("button.close"));
public SearchResultsDialog(Window owner,String text,SearchListener<E> listener) {
public SearchResultsDialog(Window owner, String text, SearchListener<E> listener) {
super(owner);
setTitle(translate("dialog.title").replace("%text%", text));
Container cnt=getContentPane();
Container cnt = getContentPane();
model = new DefaultListModel<>();
resultsList = new JList<>(model);
resultsList = new JList<>(model);
this.listener = listener;
gotoButton.setActionCommand(ACTION_GOTO);
gotoButton.addActionListener(this);
closeButton.setActionCommand(ACTION_CANCEL);
@@ -74,24 +74,24 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener{
gotoElement();
}
}
});
});
cnt.setLayout(new BorderLayout());
JScrollPane sp = new JScrollPane(resultsList);
sp.setPreferredSize(new Dimension(300,300));
cnt.add(sp,BorderLayout.CENTER);
cnt.add(buttonsPanel,BorderLayout.SOUTH);
sp.setPreferredSize(new Dimension(300, 300));
cnt.add(sp, BorderLayout.CENTER);
cnt.add(buttonsPanel, BorderLayout.SOUTH);
pack();
View.centerScreen(this);
View.setWindowIcon(this);
}
public void setResults(List<E> results){
public void setResults(List<E> results) {
model.clear();
for(E e:results){
for (E e : results) {
model.addElement(e);
}
}
}
@Override
@@ -106,18 +106,18 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener{
break;
}
}
private void gotoElement(){
private void gotoElement() {
if (resultsList.getSelectedIndex() != -1) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
public void run() {
listener.updateSearchPos(resultsList.getSelectedValue());
}
});
}
}
}

View File

@@ -1,139 +1,139 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author JPEXS
*/
public class TextPanel extends JPanel implements ActionListener {
private static final String ACTION_EDIT_TEXT = "EDITTEXT";
private static final String ACTION_CANCEL_TEXT = "CANCELTEXT";
private static final String ACTION_SAVE_TEXT = "SAVETEXT";
private final MainPanel mainPanel;
private final SearchPanel<TextTag> textSearchPanel;
private final LineMarkedEditorPane textValue;
private final JButton textSaveButton;
private final JButton textEditButton;
private final JButton textCancelButton;
public TextPanel(MainPanel mainPanel) {
super(new BorderLayout());
this.mainPanel = mainPanel;
textSearchPanel = new SearchPanel<>(new FlowLayout(), mainPanel);
add(textSearchPanel, BorderLayout.NORTH);
textValue = new LineMarkedEditorPane();
add(new JScrollPane(textValue), BorderLayout.CENTER);
textValue.setEditable(false);
JPanel textButtonsPanel = new JPanel();
textButtonsPanel.setLayout(new FlowLayout());
textSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
textSaveButton.setMargin(new Insets(3, 3, 3, 10));
textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
textSaveButton.addActionListener(this);
textEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
textEditButton.setMargin(new Insets(3, 3, 3, 10));
textEditButton.setActionCommand(ACTION_EDIT_TEXT);
textEditButton.addActionListener(this);
textCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
textCancelButton.setMargin(new Insets(3, 3, 3, 10));
textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
textCancelButton.addActionListener(this);
textButtonsPanel.add(textEditButton);
textButtonsPanel.add(textSaveButton);
textButtonsPanel.add(textCancelButton);
textSaveButton.setVisible(false);
textCancelButton.setVisible(false);
add(textButtonsPanel, BorderLayout.SOUTH);
}
public SearchPanel<TextTag> getSearchPanel() {
return textSearchPanel;
}
public void setText(String text) {
textValue.setContentType("text/swf_text");
// textValue.setFont(new Font("Monospaced", Font.PLAIN, 13));
textValue.setText(text);
textValue.setCaretPosition(0);
}
public void setEditText(boolean edit) {
textValue.setEditable(edit);
textSaveButton.setVisible(edit);
textEditButton.setVisible(!edit);
textCancelButton.setVisible(edit);
}
public void updateSearchPos() {
textValue.setCaretPosition(0);
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
textSearchPanel.showQuickFindDialog(textValue);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_EDIT_TEXT:
setEditText(true);
break;
case ACTION_CANCEL_TEXT:
setEditText(false);
mainPanel.reload(true);
break;
case ACTION_SAVE_TEXT:
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
if (item instanceof TextTag) {
TextTag textTag = (TextTag) item;
if (mainPanel.saveText(textTag, textValue.getText(), null)) {
setEditText(false);
mainPanel.reload(true);
}
SWF.clearImageCache();
}
break;
}
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author JPEXS
*/
public class TextPanel extends JPanel implements ActionListener {
private static final String ACTION_EDIT_TEXT = "EDITTEXT";
private static final String ACTION_CANCEL_TEXT = "CANCELTEXT";
private static final String ACTION_SAVE_TEXT = "SAVETEXT";
private final MainPanel mainPanel;
private final SearchPanel<TextTag> textSearchPanel;
private final LineMarkedEditorPane textValue;
private final JButton textSaveButton;
private final JButton textEditButton;
private final JButton textCancelButton;
public TextPanel(MainPanel mainPanel) {
super(new BorderLayout());
this.mainPanel = mainPanel;
textSearchPanel = new SearchPanel<>(new FlowLayout(), mainPanel);
add(textSearchPanel, BorderLayout.NORTH);
textValue = new LineMarkedEditorPane();
add(new JScrollPane(textValue), BorderLayout.CENTER);
textValue.setEditable(false);
JPanel textButtonsPanel = new JPanel();
textButtonsPanel.setLayout(new FlowLayout());
textSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
textSaveButton.setMargin(new Insets(3, 3, 3, 10));
textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
textSaveButton.addActionListener(this);
textEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
textEditButton.setMargin(new Insets(3, 3, 3, 10));
textEditButton.setActionCommand(ACTION_EDIT_TEXT);
textEditButton.addActionListener(this);
textCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
textCancelButton.setMargin(new Insets(3, 3, 3, 10));
textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
textCancelButton.addActionListener(this);
textButtonsPanel.add(textEditButton);
textButtonsPanel.add(textSaveButton);
textButtonsPanel.add(textCancelButton);
textSaveButton.setVisible(false);
textCancelButton.setVisible(false);
add(textButtonsPanel, BorderLayout.SOUTH);
}
public SearchPanel<TextTag> getSearchPanel() {
return textSearchPanel;
}
public void setText(String text) {
textValue.setContentType("text/swf_text");
// textValue.setFont(new Font("Monospaced", Font.PLAIN, 13));
textValue.setText(text);
textValue.setCaretPosition(0);
}
public void setEditText(boolean edit) {
textValue.setEditable(edit);
textSaveButton.setVisible(edit);
textEditButton.setVisible(!edit);
textCancelButton.setVisible(edit);
}
public void updateSearchPos() {
textValue.setCaretPosition(0);
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
textSearchPanel.showQuickFindDialog(textValue);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_EDIT_TEXT:
setEditText(true);
break;
case ACTION_CANCEL_TEXT:
setEditText(false);
mainPanel.reload(true);
break;
case ACTION_SAVE_TEXT:
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
if (item instanceof TextTag) {
TextTag textTag = (TextTag) item;
if (mainPanel.saveText(textTag, textValue.getText(), null)) {
setEditText(false);
mainPanel.reload(true);
}
SWF.clearImageCache();
}
break;
}
}
}

View File

@@ -504,18 +504,18 @@ public class View {
tree.collapsePath(parent);
}
}
public static void addEditorAction(JEditorPane editor,AbstractAction a,String key, String name, String keyStroke){
public static void addEditorAction(JEditorPane editor, AbstractAction a, String key, String name, String keyStroke) {
KeyStroke ks = KeyStroke.getKeyStroke(keyStroke);
a.putValue(Action.ACCELERATOR_KEY, ks);
a.putValue(Action.NAME, name);
String actionName = key;
ActionMap amap = editor.getActionMap();
InputMap imap = editor.getInputMap(JTextComponent.WHEN_FOCUSED);
imap.put(ks, actionName);
amap.put(actionName, a);
JPopupMenu pmenu = editor.getComponentPopupMenu();
JMenuItem findUsagesMenu = new JMenuItem(a);
pmenu.add(findUsagesMenu);

View File

@@ -136,7 +136,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
public DetailPanel detailPanel;
public JPanel navPanel;
public JTabbedPane tabbedPane;
public SearchPanel<ABCPanelSearchResult> searchPanel;
public SearchPanel<ABCPanelSearchResult> searchPanel;
private NewTraitDialog newTraitDialog;
public JLabel scriptNameLabel;
@@ -155,9 +155,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
return mainPanel;
}
public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
if ((txt != null) && (!txt.isEmpty())) {
searchPanel.setOptions(ignoreCase, regexp);
@@ -207,23 +204,21 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
System.gc();
Main.stopWork();
searchPanel.setSearchText(txt);
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
SearchResultsDialog<ABCPanelSearchResult> sr=new SearchResultsDialog<>(ABCPanel.this.mainPanel.getMainFrame().getWindow(),txt,ABCPanel.this);
SearchResultsDialog<ABCPanelSearchResult> sr = new SearchResultsDialog<>(ABCPanel.this.mainPanel.getMainFrame().getWindow(), txt, ABCPanel.this);
sr.setResults(found);
sr.setVisible(true);
sr.setVisible(true);
}
});
return true;
//return searchPanel.setResults(found);
}
return false;
@@ -410,7 +405,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
iconDecPanel.add(scriptNameLabel);
iconDecPanel.add(iconsPanel);
iconDecPanel.add(decompiledScrollPane);
JPanel decButtonsPan = new JPanel(new FlowLayout());
decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED));
decButtonsPan.add(editDecompiledButton);
@@ -459,32 +454,30 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
});
decompiledTextArea.setContentType("text/actionscript");
decompiledTextArea.setFont(new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize()));
View.addEditorAction(decompiledTextArea, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int multinameIndex = decompiledTextArea.getMultinameUnderCursor();
if(multinameIndex>-1){
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this,false);
int multinameIndex = decompiledTextArea.getMultinameUnderCursor();
if (multinameIndex > -1) {
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, false);
usageFrame.setVisible(true);
}
}
}, "find-usages", AppStrings.translate("abc.action.find-usages"), "control U");
View.addEditorAction(decompiledTextArea, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
gotoDeclaration();
gotoDeclaration();
}
}, "find-declaration", AppStrings.translate("abc.action.find-declaration"), "control B");
}, "find-declaration", AppStrings.translate("abc.action.find-declaration"), "control B");
CtrlClickHandler cch = new CtrlClickHandler();
decompiledTextArea.addKeyListener(cch);
decompiledTextArea.addMouseListener(cch);
decompiledTextArea.addMouseMotionListener(cch);
JPanel pan2 = new JPanel();
pan2.setLayout(new BorderLayout());
pan2.add((abcComboBox = new JComboBox<>(new ABCComboBoxModel(new ArrayList<ABCContainerTag>()))), BorderLayout.NORTH);
@@ -508,7 +501,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
});
Main.startWork(AppStrings.translate("work.buildingscripttree") + "...");
tabbedPane = new JTabbedPane();
tabbedPane.addTab(AppStrings.translate("traits"), navPanel);
abcComboBox.addItemListener(this);
@@ -548,45 +541,44 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER);
tabbedPane.addTab(AppStrings.translate("constants"), panConstants);
}
private void gotoDeclaration(){
private void gotoDeclaration() {
int multinameIndex = decompiledTextArea.getMultinameUnderCursor();
if(multinameIndex>-1){
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.abcList,multinameIndex);
if (multinameIndex > -1) {
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.abcList, multinameIndex);
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
//search other ABC tags if this is not private multiname
if(m.namespace_index>0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE)
{
for(ABCContainerTag at:swf.abcList){
if (m.namespace_index > 0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE) {
for (ABCContainerTag at : swf.abcList) {
ABC a = at.getABC();
if(a == abc){
if (a == abc) {
continue;
}
int mid=a.constants.getMultinameId(m,false);
if(mid>0){
}
int mid = a.constants.getMultinameId(m, false);
if (mid > 0) {
usages.addAll(a.findMultinameDefinition(swf.abcList, mid));
}
}
}
//more than one? display list
if(usages.size()>1){
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this,true);
if (usages.size() > 1) {
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, true);
usageFrame.setVisible(true);
}else if(!usages.isEmpty()){ //one
} else if (!usages.isEmpty()) { //one
UsageFrame.gotoUsage(ABCPanel.this, usages.get(0));
}
}
}
private class CtrlClickHandler extends KeyAdapter implements MouseListener, MouseMotionListener {
private boolean ctrlDown = false;
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == 17 && !decompiledTextArea.isEditable()){
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == 17 && !decompiledTextArea.isEditable()) {
ctrlDown = true;
decompiledTextArea.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
@@ -594,24 +586,24 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
@Override
public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == 17){
if (e.getKeyCode() == 17) {
ctrlDown = false;
decompiledTextArea.setCursor(Cursor.getDefaultCursor());
}
}
@Override
public void mouseClicked(MouseEvent e) {
if(ctrlDown && e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1 && !decompiledTextArea.isEditable()){
if (ctrlDown && e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1 && !decompiledTextArea.isEditable()) {
ctrlDown = false;
decompiledTextArea.setCursor(Cursor.getDefaultCursor());
gotoDeclaration();
}
gotoDeclaration();
}
}
@Override
public void mousePressed(MouseEvent e) {
public void mousePressed(MouseEvent e) {
}
@Override
@@ -634,12 +626,12 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
@Override
public void mouseMoved(MouseEvent e) {
if(ctrlDown && decompiledTextArea.isEditable()){
if (ctrlDown && decompiledTextArea.isEditable()) {
ctrlDown = false;
decompiledTextArea.setCursor(Cursor.getDefaultCursor());
}
}
}
public void reload() {
@@ -713,11 +705,11 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
public void run() {
searchPanel.showQuickFindDialog(decompiledTextArea);
}
});
}
public String lastDecompiled = null;
@@ -951,6 +943,5 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
break;
}
}
}

View File

@@ -1,37 +1,36 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.ScriptPack;
/**
*
* @author JPEXS
*/
public class ABCPanelSearchResult {
public ScriptPack scriptPack;
public ClassPath classPath;
@Override
public String toString() {
return classPath.toString();
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.ScriptPack;
/**
*
* @author JPEXS
*/
public class ABCPanelSearchResult {
public ScriptPack scriptPack;
public ClassPath classPath;
@Override
public String toString() {
return classPath.toString();
}
}

View File

@@ -1,348 +1,348 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException;
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.ASM3Parser;
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.MissingSymbolHandler;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.gui.GraphDialog;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.helpers.HilightedText;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretListener {
public ABC abc;
public int bodyIndex = -1;
private List<Highlighting> disassembledHilights = new ArrayList<>();
private List<Highlighting> specialHilights = new ArrayList<>();
private final DecompiledEditorPane decompiledEditor;
private boolean ignoreCarret = false;
private String name;
private HilightedText textWithHex;
private HilightedText textNoHex;
private HilightedText textHexOnly;
private ScriptExportMode exportMode = ScriptExportMode.PCODE;
private Trait trait;
public ABCPanel getAbcPanel(){
return decompiledEditor.getAbcPanel();
}
public ScriptExportMode getExportMode() {
return exportMode;
}
private HilightedText getHilightedText(ScriptExportMode exportMode) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
abc.bodies.get(bodyIndex).code.toASMSource(abc.constants, trait, abc.method_info.get(abc.bodies.get(bodyIndex).method_info), abc.bodies.get(bodyIndex), exportMode, writer);
return new HilightedText(writer);
}
public void setHex(ScriptExportMode exportMode, boolean force) {
if (this.exportMode == exportMode & !force) {
return;
}
this.exportMode = exportMode;
long oldOffset = getSelectedOffset();
if (exportMode == ScriptExportMode.PCODE) {
setContentType("text/flasm");
if (textNoHex == null) {
textNoHex = getHilightedText(exportMode);
}
setText(textNoHex);
} else if (exportMode == ScriptExportMode.PCODE_HEX) {
setContentType("text/flasm");
if (textWithHex == null) {
textWithHex = getHilightedText(exportMode);
}
setText(textWithHex);
} else {
setContentType("text/plain");
if (textHexOnly == null) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
Helper.byteArrayToHexWithHeader(writer, abc.bodies.get(bodyIndex).code.getBytes());
textHexOnly = new HilightedText(writer);
}
setText(textHexOnly);
}
hilighOffset(oldOffset);
}
public void setIgnoreCarret(boolean ignoreCarret) {
this.ignoreCarret = ignoreCarret;
}
public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) {
this.decompiledEditor = decompiledEditor;
addCaretListener(this);
}
public void hilighSpecial(String type, int index) {
Highlighting h2 = null;
for (Highlighting sh : specialHilights) {
if (type.equals(sh.getPropertyString("subtype"))) {
if (sh.getPropertyString("index").equals("" + index)) {
h2 = sh;
break;
}
}
}
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos <= getDocument().getLength()) {
setCaretPosition(h2.startPos);
}
getCaret().setVisible(true);
ignoreCarret = false;
}
}
public void hilighOffset(long offset) {
if (isEditable()) {
return;
}
Highlighting h2 = Highlighting.search(disassembledHilights, "offset", "" + offset);
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos <= getDocument().getLength()) {
setCaretPosition(h2.startPos);
}
getCaret().setVisible(true);
ignoreCarret = false;
}
}
@Override
public String getName() {
return super.getName();
}
public void setBodyIndex(int bodyIndex, ABC abc, String name, Trait trait) {
this.bodyIndex = bodyIndex;
this.abc = abc;
this.name = name;
this.trait = trait;
if (bodyIndex == -1) {
return;
}
textWithHex = null;
textNoHex = null;
setHex(exportMode, true);
}
public void graph() {
try {
AVM2Graph gr = new AVM2Graph(abc.bodies.get(bodyIndex).code, abc, abc.bodies.get(bodyIndex), false, -1, -1, new HashMap<Integer, GraphTargetItem>(), new Stack<GraphTargetItem>(), new HashMap<Integer, String>(), new ArrayList<String>(), new HashMap<Integer, Integer>(), abc.bodies.get(bodyIndex).code.visitCode(abc.bodies.get(bodyIndex)));
(new GraphDialog(getAbcPanel().getMainPanel().getMainFrame().getWindow(),gr, name)).setVisible(true);
} catch (InterruptedException ex) {
Logger.getLogger(ASMSourceEditorPane.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void exec() {
HashMap<Integer, Object> args = new HashMap<>();
args.put(0, new Object()); //object "this"
args.put(1, new Long(466561)); //param1
Object o = abc.bodies.get(bodyIndex).code.execute(args, abc.constants);
View.showMessageDialog(this, "Returned object:" + o.toString());
}
public boolean save(ConstantPool constants) {
try {
String text = getText();
if (text.trim().startsWith("#hexdata")) {
byte[] data = Helper.getBytesFromHexaText(text);
MethodBody mb = abc.bodies.get(bodyIndex);
mb.codeBytes = data;
try {
mb.code = new AVM2Code(new ByteArrayInputStream(mb.codeBytes));
} catch (UnknownInstructionCode re) {
mb.code = new AVM2Code();
Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, re);
}
mb.code.compact();
} else {
AVM2Code acode = ASM3Parser.parse(new StringReader(text), constants, trait, new MissingSymbolHandler() {
//no longer ask for adding new constants
@Override
public boolean missingString(String value) {
return true;
}
@Override
public boolean missingInt(long value) {
return true;
}
@Override
public boolean missingUInt(long value) {
return true;
}
@Override
public boolean missingDouble(double value) {
return true;
}
}, abc.bodies.get(bodyIndex), abc.method_info.get(abc.bodies.get(bodyIndex).method_info));
acode.getBytes(abc.bodies.get(bodyIndex).codeBytes);
abc.bodies.get(bodyIndex).code = acode;
}
((Tag) abc.parentTag).setModified(true);
} catch (IOException ex) {
} catch (InterruptedException ex) {
} catch (ParseException ex) {
View.showMessageDialog(this, (ex.text + " on line " + ex.line));
selectLine((int) ex.line);
return false;
}
return true;
}
@Override
public void setText(String t) {
disassembledHilights = new ArrayList<>();
specialHilights = new ArrayList<>();
super.setText(t);
setCaretPosition(0);
}
public void setText(HilightedText hilightedText) {
disassembledHilights = hilightedText.instructionHilights;
specialHilights = hilightedText.specialHilights;
super.setText(hilightedText.text);
setCaretPosition(0);
}
public void clear() {
setText("");
bodyIndex = -1;
setCaretPosition(0);
}
public void selectInstruction(int pos) {
String text = getText();
int lineCnt = 1;
int lineStart = 0;
int lineEnd;
int instrCount = 0;
int dot = -2;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '\n') {
lineCnt++;
lineEnd = i;
String ins = text.substring(lineStart, lineEnd).trim();
if (!((i > 0) && (text.charAt(i - 1) == ':'))) {
if (!ins.startsWith("exception ")) {
instrCount++;
}
}
if (instrCount == pos + 1) {
break;
}
lineStart = i + 1;
}
}
if (lineCnt == -1) {
//lineEnd = text.length() - 1;
}
//select(lineStart, lineEnd);
setCaretPosition(lineStart);
//requestFocus();
}
public void selectLine(int line) {
String text = getText();
int lineCnt = 1;
int lineStart = 0;
int lineEnd = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '\n') {
lineCnt++;
if (lineCnt == line) {
lineStart = i;
}
if (lineCnt == line + 1) {
lineEnd = i;
}
}
}
if (lineCnt == -1) {
lineEnd = text.length() - 1;
}
select(lineStart, lineEnd);
requestFocus();
}
public Highlighting getSelectedSpecial() {
return Highlighting.search(specialHilights, getCaretPosition());
}
public long getSelectedOffset() {
int pos = getCaretPosition();
Highlighting lastH = null;
for (Highlighting h : disassembledHilights) {
if (pos < h.startPos) {
break;
}
lastH = h;
}
return lastH == null ? 0 : lastH.getPropertyLong("offset");
}
@Override
public void caretUpdate(CaretEvent e) {
if (isEditable()) {
return;
}
if (ignoreCarret) {
return;
}
getCaret().setVisible(true);
decompiledEditor.hilightOffset(getSelectedOffset());
Highlighting spec = getSelectedSpecial();
if (spec != null) {
decompiledEditor.hilightSpecial(spec.getPropertyString("subtype"), (int) (long) spec.getPropertyLong("index"));
}
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException;
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.ASM3Parser;
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.MissingSymbolHandler;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.gui.GraphDialog;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.helpers.HilightedText;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretListener {
public ABC abc;
public int bodyIndex = -1;
private List<Highlighting> disassembledHilights = new ArrayList<>();
private List<Highlighting> specialHilights = new ArrayList<>();
private final DecompiledEditorPane decompiledEditor;
private boolean ignoreCarret = false;
private String name;
private HilightedText textWithHex;
private HilightedText textNoHex;
private HilightedText textHexOnly;
private ScriptExportMode exportMode = ScriptExportMode.PCODE;
private Trait trait;
public ABCPanel getAbcPanel() {
return decompiledEditor.getAbcPanel();
}
public ScriptExportMode getExportMode() {
return exportMode;
}
private HilightedText getHilightedText(ScriptExportMode exportMode) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
abc.bodies.get(bodyIndex).code.toASMSource(abc.constants, trait, abc.method_info.get(abc.bodies.get(bodyIndex).method_info), abc.bodies.get(bodyIndex), exportMode, writer);
return new HilightedText(writer);
}
public void setHex(ScriptExportMode exportMode, boolean force) {
if (this.exportMode == exportMode & !force) {
return;
}
this.exportMode = exportMode;
long oldOffset = getSelectedOffset();
if (exportMode == ScriptExportMode.PCODE) {
setContentType("text/flasm");
if (textNoHex == null) {
textNoHex = getHilightedText(exportMode);
}
setText(textNoHex);
} else if (exportMode == ScriptExportMode.PCODE_HEX) {
setContentType("text/flasm");
if (textWithHex == null) {
textWithHex = getHilightedText(exportMode);
}
setText(textWithHex);
} else {
setContentType("text/plain");
if (textHexOnly == null) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
Helper.byteArrayToHexWithHeader(writer, abc.bodies.get(bodyIndex).code.getBytes());
textHexOnly = new HilightedText(writer);
}
setText(textHexOnly);
}
hilighOffset(oldOffset);
}
public void setIgnoreCarret(boolean ignoreCarret) {
this.ignoreCarret = ignoreCarret;
}
public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) {
this.decompiledEditor = decompiledEditor;
addCaretListener(this);
}
public void hilighSpecial(String type, int index) {
Highlighting h2 = null;
for (Highlighting sh : specialHilights) {
if (type.equals(sh.getPropertyString("subtype"))) {
if (sh.getPropertyString("index").equals("" + index)) {
h2 = sh;
break;
}
}
}
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos <= getDocument().getLength()) {
setCaretPosition(h2.startPos);
}
getCaret().setVisible(true);
ignoreCarret = false;
}
}
public void hilighOffset(long offset) {
if (isEditable()) {
return;
}
Highlighting h2 = Highlighting.search(disassembledHilights, "offset", "" + offset);
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos <= getDocument().getLength()) {
setCaretPosition(h2.startPos);
}
getCaret().setVisible(true);
ignoreCarret = false;
}
}
@Override
public String getName() {
return super.getName();
}
public void setBodyIndex(int bodyIndex, ABC abc, String name, Trait trait) {
this.bodyIndex = bodyIndex;
this.abc = abc;
this.name = name;
this.trait = trait;
if (bodyIndex == -1) {
return;
}
textWithHex = null;
textNoHex = null;
setHex(exportMode, true);
}
public void graph() {
try {
AVM2Graph gr = new AVM2Graph(abc.bodies.get(bodyIndex).code, abc, abc.bodies.get(bodyIndex), false, -1, -1, new HashMap<Integer, GraphTargetItem>(), new Stack<GraphTargetItem>(), new HashMap<Integer, String>(), new ArrayList<String>(), new HashMap<Integer, Integer>(), abc.bodies.get(bodyIndex).code.visitCode(abc.bodies.get(bodyIndex)));
(new GraphDialog(getAbcPanel().getMainPanel().getMainFrame().getWindow(), gr, name)).setVisible(true);
} catch (InterruptedException ex) {
Logger.getLogger(ASMSourceEditorPane.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void exec() {
HashMap<Integer, Object> args = new HashMap<>();
args.put(0, new Object()); //object "this"
args.put(1, new Long(466561)); //param1
Object o = abc.bodies.get(bodyIndex).code.execute(args, abc.constants);
View.showMessageDialog(this, "Returned object:" + o.toString());
}
public boolean save(ConstantPool constants) {
try {
String text = getText();
if (text.trim().startsWith("#hexdata")) {
byte[] data = Helper.getBytesFromHexaText(text);
MethodBody mb = abc.bodies.get(bodyIndex);
mb.codeBytes = data;
try {
mb.code = new AVM2Code(new ByteArrayInputStream(mb.codeBytes));
} catch (UnknownInstructionCode re) {
mb.code = new AVM2Code();
Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, re);
}
mb.code.compact();
} else {
AVM2Code acode = ASM3Parser.parse(new StringReader(text), constants, trait, new MissingSymbolHandler() {
//no longer ask for adding new constants
@Override
public boolean missingString(String value) {
return true;
}
@Override
public boolean missingInt(long value) {
return true;
}
@Override
public boolean missingUInt(long value) {
return true;
}
@Override
public boolean missingDouble(double value) {
return true;
}
}, abc.bodies.get(bodyIndex), abc.method_info.get(abc.bodies.get(bodyIndex).method_info));
acode.getBytes(abc.bodies.get(bodyIndex).codeBytes);
abc.bodies.get(bodyIndex).code = acode;
}
((Tag) abc.parentTag).setModified(true);
} catch (IOException ex) {
} catch (InterruptedException ex) {
} catch (ParseException ex) {
View.showMessageDialog(this, (ex.text + " on line " + ex.line));
selectLine((int) ex.line);
return false;
}
return true;
}
@Override
public void setText(String t) {
disassembledHilights = new ArrayList<>();
specialHilights = new ArrayList<>();
super.setText(t);
setCaretPosition(0);
}
public void setText(HilightedText hilightedText) {
disassembledHilights = hilightedText.instructionHilights;
specialHilights = hilightedText.specialHilights;
super.setText(hilightedText.text);
setCaretPosition(0);
}
public void clear() {
setText("");
bodyIndex = -1;
setCaretPosition(0);
}
public void selectInstruction(int pos) {
String text = getText();
int lineCnt = 1;
int lineStart = 0;
int lineEnd;
int instrCount = 0;
int dot = -2;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '\n') {
lineCnt++;
lineEnd = i;
String ins = text.substring(lineStart, lineEnd).trim();
if (!((i > 0) && (text.charAt(i - 1) == ':'))) {
if (!ins.startsWith("exception ")) {
instrCount++;
}
}
if (instrCount == pos + 1) {
break;
}
lineStart = i + 1;
}
}
if (lineCnt == -1) {
//lineEnd = text.length() - 1;
}
//select(lineStart, lineEnd);
setCaretPosition(lineStart);
//requestFocus();
}
public void selectLine(int line) {
String text = getText();
int lineCnt = 1;
int lineStart = 0;
int lineEnd = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '\n') {
lineCnt++;
if (lineCnt == line) {
lineStart = i;
}
if (lineCnt == line + 1) {
lineEnd = i;
}
}
}
if (lineCnt == -1) {
lineEnd = text.length() - 1;
}
select(lineStart, lineEnd);
requestFocus();
}
public Highlighting getSelectedSpecial() {
return Highlighting.search(specialHilights, getCaretPosition());
}
public long getSelectedOffset() {
int pos = getCaretPosition();
Highlighting lastH = null;
for (Highlighting h : disassembledHilights) {
if (pos < h.startPos) {
break;
}
lastH = h;
}
return lastH == null ? 0 : lastH.getPropertyLong("offset");
}
@Override
public void caretUpdate(CaretEvent e) {
if (isEditable()) {
return;
}
if (ignoreCarret) {
return;
}
getCaret().setVisible(true);
decompiledEditor.hilightOffset(getSelectedOffset());
Highlighting spec = getSelectedSpecial();
if (spec != null) {
decompiledEditor.hilightSpecial(spec.getPropertyString("subtype"), (int) (long) spec.getPropertyLong("index"));
}
}
}

View File

@@ -61,29 +61,27 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
private boolean isStatic = false;
private final Cache<CachedDecompilation> cache = Cache.getInstance(true);
private Trait currentTrait = null;
private final List<Runnable> scriptListeners = new ArrayList<Runnable>();
public void addScriptListener(Runnable l){
public void addScriptListener(Runnable l) {
scriptListeners.add(l);
}
public ABCPanel getAbcPanel() {
return abcPanel;
}
public void removeScriptListener(Runnable l){
public void removeScriptListener(Runnable l) {
scriptListeners.remove(l);
}
public void fireScript(){
for(int i=0;i<scriptListeners.size();i++){
public void fireScript() {
for (int i = 0; i < scriptListeners.size(); i++) {
scriptListeners.get(i).run();
}
}
public Trait getCurrentTrait() {
return currentTrait;
}
@@ -96,7 +94,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
return isStatic;
}
public void setNoTrait() {
public void setNoTrait() {
abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD, null);
}
@@ -450,7 +448,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
setEditable(false);
getCaret().setVisible(true);
addCaretListener(this);
this.abcPanel = abcPanel;
this.abcPanel = abcPanel;
}
private List<ABCContainerTag> abcList;
@@ -537,7 +535,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
}
@Override
public void setText(String t) {
public void setText(String t) {
super.setText(t);
setCaretPosition(0);
}

View File

@@ -58,18 +58,17 @@ public class UsageFrame extends AppDialog implements ActionListener, MouseListen
public UsageFrame(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel, boolean definitions) {
super(abcPanel.getMainPanel().getMainFrame().getWindow());
this.abcPanel = abcPanel;
List<MultinameUsage> usages = definitions?abc.findMultinameDefinition(abcTags,multinameIndex):abc.findMultinameUsage(abcTags,multinameIndex);
List<MultinameUsage> usages = definitions ? abc.findMultinameDefinition(abcTags, multinameIndex) : abc.findMultinameUsage(abcTags, multinameIndex);
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
if(m.namespace_index>0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE)
{
for(ABCContainerTag at:abcTags){
if (m.namespace_index > 0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE) {
for (ABCContainerTag at : abcTags) {
ABC a = at.getABC();
if(a == abc){
if (a == abc) {
continue;
}
int mid=a.constants.getMultinameId(m,false);
if(mid>0){
usages.addAll(definitions?a.findMultinameDefinition(abcTags, mid):a.findMultinameUsage(abcTags, mid));
}
int mid = a.constants.getMultinameId(m, false);
if (mid > 0) {
usages.addAll(definitions ? a.findMultinameDefinition(abcTags, mid) : a.findMultinameUsage(abcTags, mid));
}
}
}
@@ -94,57 +93,56 @@ public class UsageFrame extends AppDialog implements ActionListener, MouseListen
cont.add(new JScrollPane(usageList), BorderLayout.CENTER);
cont.add(buttonsPanel, BorderLayout.SOUTH);
setSize(400, 300);
setTitle((definitions?translate("dialog.title.declaration"):translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants));
setTitle((definitions ? translate("dialog.title.declaration") : translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants));
View.centerScreen(this);
View.setWindowIcon(this);
}
public static void gotoUsage(final ABCPanel abcPanel,final MultinameUsage usage){
public static void gotoUsage(final ABCPanel abcPanel, final MultinameUsage usage) {
if (usage instanceof InsideClassMultinameUsage) {
final InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
Runnable settrait = new Runnable() {
final InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
@Override
public void run() {
abcPanel.decompiledTextArea.removeScriptListener(this);
abcPanel.decompiledTextArea.setClassIndex(icu.classIndex);
if (usage instanceof TraitMultinameUsage) {
TraitMultinameUsage tmu = (TraitMultinameUsage) usage;
int traitIndex;
if (tmu.parentTraitIndex > -1) {
traitIndex = tmu.parentTraitIndex;
} else {
traitIndex = tmu.traitIndex;
}
if (!tmu.isStatic) {
traitIndex += abcPanel.abc.class_info.get(tmu.classIndex).static_traits.traits.size();
}
if (tmu instanceof MethodMultinameUsage) {
MethodMultinameUsage mmu = (MethodMultinameUsage) usage;
if (mmu.isInitializer == true) {
traitIndex = abcPanel.abc.class_info.get(mmu.classIndex).static_traits.traits.size() + abcPanel.abc.instance_info.get(mmu.classIndex).instance_traits.traits.size() + (mmu.isStatic ? 1 : 0);
}
}
abcPanel.decompiledTextArea.gotoTrait(traitIndex);
Runnable settrait = new Runnable() {
@Override
public void run() {
abcPanel.decompiledTextArea.removeScriptListener(this);
abcPanel.decompiledTextArea.setClassIndex(icu.classIndex);
if (usage instanceof TraitMultinameUsage) {
TraitMultinameUsage tmu = (TraitMultinameUsage) usage;
int traitIndex;
if (tmu.parentTraitIndex > -1) {
traitIndex = tmu.parentTraitIndex;
} else {
traitIndex = tmu.traitIndex;
}
if (!tmu.isStatic) {
traitIndex += abcPanel.abc.class_info.get(tmu.classIndex).static_traits.traits.size();
}
if (tmu instanceof MethodMultinameUsage) {
MethodMultinameUsage mmu = (MethodMultinameUsage) usage;
if (mmu.isInitializer == true) {
traitIndex = abcPanel.abc.class_info.get(mmu.classIndex).static_traits.traits.size() + abcPanel.abc.instance_info.get(mmu.classIndex).instance_traits.traits.size() + (mmu.isStatic ? 1 : 0);
}
}
abcPanel.decompiledTextArea.gotoTrait(traitIndex);
}
};
if(abcPanel.decompiledTextArea.getClassIndex() == icu.classIndex && abcPanel.abc == icu.abc){
settrait.run();
}else{
abcPanel.decompiledTextArea.addScriptListener(settrait);
abcPanel.hilightScript(abcPanel.swf, abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants));
}
}
};
if (abcPanel.decompiledTextArea.getClassIndex() == icu.classIndex && abcPanel.abc == icu.abc) {
settrait.run();
} else {
abcPanel.decompiledTextArea.addScriptListener(settrait);
abcPanel.hilightScript(abcPanel.swf, abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants));
}
}
}
private void gotoUsage() {
if (usageList.getSelectedIndex() != -1) {
MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex());
gotoUsage(abcPanel,usage);
gotoUsage(abcPanel, usage);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,41 +1,40 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui.action;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
/**
*
* @author JPEXS
*/
public class ActionSearchResult {
public ASMSource src;
public String path;
public ActionSearchResult(ASMSource src, String path) {
this.src = src;
this.path = path;
}
@Override
public String toString() {
return path;
}
}
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui.action;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
/**
*
* @author JPEXS
*/
public class ActionSearchResult {
public ASMSource src;
public String path;
public ActionSearchResult(ASMSource src, String path) {
this.src = src;
this.path = path;
}
@Override
public String toString() {
return path;
}
}

View File

@@ -62,7 +62,7 @@ public class DefineBinaryDataTag extends CharacterTag {
super(sis.getSwf(), ID, "DefineBinaryData", pos, length);
tag = sis.readUI16("tag");
reserved = sis.readUI32("reserved");
binaryData = sis.readBytesEx(sis.available(),"binaryData");
binaryData = sis.readBytesEx(sis.available(), "binaryData");
}
@Override

View File

@@ -765,7 +765,7 @@ public class DefineEditTextTag extends TextTag {
}
return false;
}
@Override
public void toImage(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
render(false, image, transformation, colorTransform);

View File

@@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
public class TagStub extends Tag {
private final SWFInputStream dataStream;
/**
* Constructor
*

View File

@@ -194,13 +194,13 @@ public class Timeline {
getNeededCharacters(i, usedCharacters);
}
}
public void getNeededCharacters(List<Integer> frames, Set<Integer> usedCharacters) {
for (int frame = 0; frame < frames.size(); frame++) {
getNeededCharacters(frame, usedCharacters);
}
}
public void getNeededCharacters(int frame, Set<Integer> usedCharacters) {
Frame frameObj = frames.get(frame);
for (int depth : frameObj.layers.keySet()) {
@@ -214,7 +214,7 @@ public class Timeline {
}
}
}
public boolean removeCharacter(int characterId) {
boolean modified = false;
for (int i = 0; i < tags.size(); i++) {

View File

@@ -73,9 +73,9 @@ public class FILLSTYLE implements NeedsCharacters, Serializable {
public boolean removeCharacter(int characterId) {
if (bitmapId == characterId) {
if ((fillStyleType == REPEATING_BITMAP)
|| (fillStyleType == CLIPPED_BITMAP)
|| (fillStyleType == NON_SMOOTHED_REPEATING_BITMAP)
|| (fillStyleType == NON_SMOOTHED_CLIPPED_BITMAP)) {
|| (fillStyleType == CLIPPED_BITMAP)
|| (fillStyleType == NON_SMOOTHED_REPEATING_BITMAP)
|| (fillStyleType == NON_SMOOTHED_CLIPPED_BITMAP)) {
fillStyleType = SOLID;
if (color == null) {
color = inShape3 ? new RGBA(0, 0, 0, 0) : new RGB(0, 0, 0);

View File

@@ -78,9 +78,9 @@ public class MORPHFILLSTYLE implements NeedsCharacters, Serializable {
public boolean removeCharacter(int characterId) {
if (bitmapId == characterId) {
if ((fillStyleType == REPEATING_BITMAP)
|| (fillStyleType == CLIPPED_BITMAP)
|| (fillStyleType == NON_SMOOTHED_REPEATING_BITMAP)
|| (fillStyleType == NON_SMOOTHED_CLIPPED_BITMAP)) {
|| (fillStyleType == CLIPPED_BITMAP)
|| (fillStyleType == NON_SMOOTHED_REPEATING_BITMAP)
|| (fillStyleType == NON_SMOOTHED_CLIPPED_BITMAP)) {
fillStyleType = SOLID;
}
bitmapId = 0;

View File

@@ -283,7 +283,7 @@ public class Filtering {
hc.drawImage(hilightIm, 0, 0, null);
hc.setComposite(AlphaComposite.DstOut);
hc.drawImage(shadowIm, 0, 0, null);
sc.drawImage(shadowIm, 0, 0, null);
sc.setComposite(AlphaComposite.DstOut);
sc.drawImage(hilightIm, 0, 0, null);

View File

@@ -88,7 +88,7 @@ public class StyleChangeRecord extends SHAPERECORD implements Cloneable {
@Override
public boolean removeCharacter(int characterId) {
if (fillStyles != null){
if (fillStyles != null) {
return fillStyles.removeCharacter(characterId);
}
return false;

View File

@@ -1604,7 +1604,7 @@ public class XFLConverter {
linkageExportForAS = true;
mediaLinkStr += " linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
}
if(linkageExportForAS){
if (linkageExportForAS) {
mediaLinkStr += " linkageExportForAS=\"true\"";
}
mediaLinkStr += "/>\n";

View File

@@ -1,259 +1,259 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.graph;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.model.BinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
*
* @author JPEXS
*/
public abstract class GraphTargetItem implements Serializable {
public static final int PRECEDENCE_PRIMARY = 0;
public static final int PRECEDENCE_POSTFIX = 1;
public static final int PRECEDENCE_UNARY = 2;
public static final int PRECEDENCE_MULTIPLICATIVE = 3;
public static final int PRECEDENCE_ADDITIVE = 4;
public static final int PRECEDENCE_BITWISESHIFT = 5;
public static final int PRECEDENCE_RELATIONAL = 6;
public static final int PRECEDENCE_EQUALITY = 7;
public static final int PRECEDENCE_BITWISEAND = 8;
public static final int PRECEDENCE_BITWISEXOR = 9;
public static final int PRECEDENCE_BITWISEOR = 10;
public static final int PRECEDENCE_LOGICALAND = 11;
public static final int PRECEDENCE_LOGICALOR = 12;
public static final int PRECEDENCE_CONDITIONAL = 13;
public static final int PRECEDENCE_ASSIGMENT = 14;
public static final int PRECEDENCE_COMMA = 15;
public static final int NOPRECEDENCE = 16;
public GraphSourceItem src;
public int pos = -1;
protected int precedence;
public List<GraphSourceItemPos> moreSrc = new ArrayList<>();
public GraphPart firstPart;
public GraphTargetItem value;
public GraphPart getFirstPart() {
if (value == null) {
return firstPart;
}
GraphPart ret = value.getFirstPart();
if (ret == null) {
return firstPart;
}
return ret;
}
public GraphTargetItem() {
this(null, NOPRECEDENCE);
}
public GraphTargetItem(GraphSourceItem src, int precedence) {
this.src = src;
this.precedence = precedence;
}
public List<GraphSourceItemPos> getNeededSources() {
List<GraphSourceItemPos> ret = new ArrayList<>();
ret.add(new GraphSourceItemPos(src, pos));
ret.addAll(moreSrc);
if (value != null) {
ret.addAll(value.getNeededSources());
}
return ret;
}
public GraphTextWriter toStringSemicoloned(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendTo(writer, localData);
if (needsSemicolon()) {
writer.append(";");
}
writer.endOffset();
return writer;
}
public boolean needsSemicolon() {
return true;
}
@Override
public String toString() {
return this.getClass().getName();
}
public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendTo(writer, localData);
writer.endOffset();
return writer;
}
public abstract GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException;
public String toString(LocalData localData) throws InterruptedException {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
toString(writer, localData);
return writer.toString();
}
public int getPrecedence() {
return precedence;
}
public boolean isCompileTime() {
Set<GraphTargetItem> dependencies = new HashSet<>();
dependencies.add(this);
return isCompileTime(dependencies);
}
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
return false;
}
public boolean hasSideEffect() {
return false;
}
public boolean isVariableComputed() {
return false;
}
public Object getResult() {
return null;
}
public String toStringNoQuotes(LocalData localData) {
return toString();
}
public GraphTextWriter toStringNoQuotes(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendToNoQuotes(writer, localData);
writer.endOffset();
return writer;
}
public GraphTextWriter appendToNoQuotes(GraphTextWriter writer, LocalData localData) throws InterruptedException {
return toString(writer, localData);
}
public GraphTargetItem getNotCoerced() {
return this;
}
public GraphTargetItem getThroughRegister() {
return this;
}
public boolean needsNewLine() {
return false;
}
public GraphTextWriter toStringNL(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendTo(writer, localData);
if (needsNewLine()) {
writer.newLine();
}
writer.endOffset();
return writer;
}
public boolean isEmpty() {
return false;
}
public GraphTargetItem getThroughNotCompilable() {
return this;
}
public GraphTargetItem getThroughDuplicate() {
return this;
}
public boolean valueEquals(GraphTargetItem target) {
return equals(target);
}
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return new ArrayList<>();
}
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
if(!hasReturnValue()){
return toSource(localData, generator);
}
return generator.generateDiscardValue(localData, this);
}
protected List<GraphSourceItem> toSourceBinary(BinaryOp op, GraphSourceItem action) {
List<GraphSourceItem> ret = new ArrayList<>();
return ret;
}
public static List<GraphSourceItem> toSourceMerge(SourceGeneratorLocalData localData, SourceGenerator gen, Object... tar) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
for (Object o : tar) {
if (o == null) {
continue;
}
if (o instanceof GraphTargetItem) {
ret.addAll(((GraphTargetItem) o).toSource(localData, gen));
}
if (o instanceof GraphSourceItem) {
ret.add((GraphSourceItem) o);
}
if (o instanceof List) {
List l = (List) o;
for (Object o2 : l) {
if (o2 instanceof GraphSourceItem) {
ret.add((GraphSourceItem) o2);
}
if (o2 instanceof GraphTargetItem) {
ret.addAll(((GraphTargetItem) o2).toSource(localData, gen));
}
}
}
}
return ret;
}
public abstract boolean hasReturnValue();
public List<GraphTargetItem> getAllSubItems() {
List<GraphTargetItem> ret = new ArrayList<>();
if (value != null) {
ret.add(value);
}
return ret;
}
public abstract GraphTargetItem returnType();
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.graph;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.model.BinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
*
* @author JPEXS
*/
public abstract class GraphTargetItem implements Serializable {
public static final int PRECEDENCE_PRIMARY = 0;
public static final int PRECEDENCE_POSTFIX = 1;
public static final int PRECEDENCE_UNARY = 2;
public static final int PRECEDENCE_MULTIPLICATIVE = 3;
public static final int PRECEDENCE_ADDITIVE = 4;
public static final int PRECEDENCE_BITWISESHIFT = 5;
public static final int PRECEDENCE_RELATIONAL = 6;
public static final int PRECEDENCE_EQUALITY = 7;
public static final int PRECEDENCE_BITWISEAND = 8;
public static final int PRECEDENCE_BITWISEXOR = 9;
public static final int PRECEDENCE_BITWISEOR = 10;
public static final int PRECEDENCE_LOGICALAND = 11;
public static final int PRECEDENCE_LOGICALOR = 12;
public static final int PRECEDENCE_CONDITIONAL = 13;
public static final int PRECEDENCE_ASSIGMENT = 14;
public static final int PRECEDENCE_COMMA = 15;
public static final int NOPRECEDENCE = 16;
public GraphSourceItem src;
public int pos = -1;
protected int precedence;
public List<GraphSourceItemPos> moreSrc = new ArrayList<>();
public GraphPart firstPart;
public GraphTargetItem value;
public GraphPart getFirstPart() {
if (value == null) {
return firstPart;
}
GraphPart ret = value.getFirstPart();
if (ret == null) {
return firstPart;
}
return ret;
}
public GraphTargetItem() {
this(null, NOPRECEDENCE);
}
public GraphTargetItem(GraphSourceItem src, int precedence) {
this.src = src;
this.precedence = precedence;
}
public List<GraphSourceItemPos> getNeededSources() {
List<GraphSourceItemPos> ret = new ArrayList<>();
ret.add(new GraphSourceItemPos(src, pos));
ret.addAll(moreSrc);
if (value != null) {
ret.addAll(value.getNeededSources());
}
return ret;
}
public GraphTextWriter toStringSemicoloned(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendTo(writer, localData);
if (needsSemicolon()) {
writer.append(";");
}
writer.endOffset();
return writer;
}
public boolean needsSemicolon() {
return true;
}
@Override
public String toString() {
return this.getClass().getName();
}
public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendTo(writer, localData);
writer.endOffset();
return writer;
}
public abstract GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException;
public String toString(LocalData localData) throws InterruptedException {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
toString(writer, localData);
return writer.toString();
}
public int getPrecedence() {
return precedence;
}
public boolean isCompileTime() {
Set<GraphTargetItem> dependencies = new HashSet<>();
dependencies.add(this);
return isCompileTime(dependencies);
}
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
return false;
}
public boolean hasSideEffect() {
return false;
}
public boolean isVariableComputed() {
return false;
}
public Object getResult() {
return null;
}
public String toStringNoQuotes(LocalData localData) {
return toString();
}
public GraphTextWriter toStringNoQuotes(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendToNoQuotes(writer, localData);
writer.endOffset();
return writer;
}
public GraphTextWriter appendToNoQuotes(GraphTextWriter writer, LocalData localData) throws InterruptedException {
return toString(writer, localData);
}
public GraphTargetItem getNotCoerced() {
return this;
}
public GraphTargetItem getThroughRegister() {
return this;
}
public boolean needsNewLine() {
return false;
}
public GraphTextWriter toStringNL(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos);
appendTo(writer, localData);
if (needsNewLine()) {
writer.newLine();
}
writer.endOffset();
return writer;
}
public boolean isEmpty() {
return false;
}
public GraphTargetItem getThroughNotCompilable() {
return this;
}
public GraphTargetItem getThroughDuplicate() {
return this;
}
public boolean valueEquals(GraphTargetItem target) {
return equals(target);
}
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return new ArrayList<>();
}
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
if (!hasReturnValue()) {
return toSource(localData, generator);
}
return generator.generateDiscardValue(localData, this);
}
protected List<GraphSourceItem> toSourceBinary(BinaryOp op, GraphSourceItem action) {
List<GraphSourceItem> ret = new ArrayList<>();
return ret;
}
public static List<GraphSourceItem> toSourceMerge(SourceGeneratorLocalData localData, SourceGenerator gen, Object... tar) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
for (Object o : tar) {
if (o == null) {
continue;
}
if (o instanceof GraphTargetItem) {
ret.addAll(((GraphTargetItem) o).toSource(localData, gen));
}
if (o instanceof GraphSourceItem) {
ret.add((GraphSourceItem) o);
}
if (o instanceof List) {
List l = (List) o;
for (Object o2 : l) {
if (o2 instanceof GraphSourceItem) {
ret.add((GraphSourceItem) o2);
}
if (o2 instanceof GraphTargetItem) {
ret.addAll(((GraphTargetItem) o2).toSource(localData, gen));
}
}
}
}
return ret;
}
public abstract boolean hasReturnValue();
public List<GraphTargetItem> getAllSubItems() {
List<GraphTargetItem> ret = new ArrayList<>();
if (value != null) {
ret.add(value);
}
return ret;
}
public abstract GraphTargetItem returnType();
}

View File

@@ -1,72 +1,72 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.graph;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.graph.model.AndItem;
import com.jpexs.decompiler.graph.model.BreakItem;
import com.jpexs.decompiler.graph.model.CommaExpressionItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.DoWhileItem;
import com.jpexs.decompiler.graph.model.DuplicateItem;
import com.jpexs.decompiler.graph.model.ForItem;
import com.jpexs.decompiler.graph.model.IfItem;
import com.jpexs.decompiler.graph.model.NotItem;
import com.jpexs.decompiler.graph.model.OrItem;
import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.TernarOpItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import java.util.List;
/**
*
* @author JPEXS
*/
public interface SourceGenerator {
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, AndItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, OrItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, IfItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TernarOpItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, WhileItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, DoWhileItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ForItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, SwitchItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, NotItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, DuplicateItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, BreakItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ContinueItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, List<GraphTargetItem> commands) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, CommaExpressionItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TypeItem item) throws CompilationException;
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException;
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.graph;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.graph.model.AndItem;
import com.jpexs.decompiler.graph.model.BreakItem;
import com.jpexs.decompiler.graph.model.CommaExpressionItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.DoWhileItem;
import com.jpexs.decompiler.graph.model.DuplicateItem;
import com.jpexs.decompiler.graph.model.ForItem;
import com.jpexs.decompiler.graph.model.IfItem;
import com.jpexs.decompiler.graph.model.NotItem;
import com.jpexs.decompiler.graph.model.OrItem;
import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.TernarOpItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import java.util.List;
/**
*
* @author JPEXS
*/
public interface SourceGenerator {
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, AndItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, OrItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, IfItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TernarOpItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, WhileItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, DoWhileItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ForItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, SwitchItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, NotItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, DuplicateItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, BreakItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ContinueItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, List<GraphTargetItem> commands) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, CommaExpressionItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TypeItem item) throws CompilationException;
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException;
}

View File

@@ -462,7 +462,7 @@ public class Helper {
while ((cnt = is.read(buf)) > 0) {
os.write(buf, 0, cnt);
maxLength -= cnt;
// last chunk is smaller
if (maxLength < bufSize) {
buf = new byte[(int) maxLength];
@@ -472,7 +472,7 @@ public class Helper {
Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void writeFile(String file, byte[]
... data) {
try (FileOutputStream fos = new FileOutputStream(file)) {

View File

@@ -27,5 +27,5 @@ public class NulStream extends OutputStream {
@Override
public void write(int i) {
}
}

View File

@@ -840,8 +840,8 @@ var cxform = function(r_add, g_add, b_add, a_add, r_mult, g_mult, b_mult, a_mult
v = max;
return v;
};
this.apply = function(c) {
var d = c;
this.apply = function(c) {
var d = c;
d[0] = this._cut(Math.round(d[0] * this.r_mult / 255 + this.r_add), 0, 255);
d[1] = this._cut(Math.round(d[1] * this.g_mult / 255 + this.g_add), 0, 255);
d[2] = this._cut(Math.round(d[2] * this.b_mult / 255 + this.b_add), 0, 255);