diff --git a/trunk/src/com/jpexs/decompiler/flash/ReReadableInputStream.java b/trunk/src/com/jpexs/decompiler/flash/ReReadableInputStream.java index c904790aa..610ad72e1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/ReReadableInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/ReReadableInputStream.java @@ -74,6 +74,6 @@ public class ReReadableInputStream extends InputStream { @Override public int available() throws IOException { - return (pos < count ? count - pos : 0) + is.available(); + return (count + is.available()) - pos; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 01a91b707..46c5198bd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash; -import com.jpexs.decompiler.flash.flv.FLVOutputStream; import SevenZip.Compression.LZMA.Encoder; import com.jpexs.decompiler.flash.flv.AUDIODATA; +import com.jpexs.decompiler.flash.flv.FLVOutputStream; import com.jpexs.decompiler.flash.flv.FLVTAG; import com.jpexs.decompiler.flash.flv.VIDEODATA; import com.jpexs.decompiler.flash.gui.TagNode; @@ -33,8 +33,6 @@ import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; import com.jpexs.decompiler.flash.tags.DoABCTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; -import com.jpexs.decompiler.flash.tags.SoundStreamHead2Tag; -import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag; import com.jpexs.decompiler.flash.tags.SoundStreamHeadTypeTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.VideoFrameTag; @@ -490,7 +488,7 @@ public class SWF { } public void exportSounds(String outdir, List tags, boolean mp3) throws IOException { - if(tags.isEmpty()){ + if (tags.isEmpty()) { return; } if (!(new File(outdir)).exists()) { @@ -559,7 +557,7 @@ public class SWF { } public void exportMovies(String outdir, List tags) throws IOException { - if(tags.isEmpty()){ + if (tags.isEmpty()) { return; } if (!(new File(outdir)).exists()) { @@ -626,7 +624,7 @@ public class SWF { } public static void exportShapes(String outdir, List tags) throws IOException { - if(tags.isEmpty()){ + if (tags.isEmpty()) { return; } if (!(new File(outdir)).exists()) { @@ -656,7 +654,7 @@ public class SWF { } public static void exportImages(String outdir, List tags, JPEGTablesTag jtt) throws IOException { - if(tags.isEmpty()){ + if (tags.isEmpty()) { return; } if (!(new File(outdir)).exists()) { diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index c03d3d677..35f2ea825 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash; +import com.jpexs.decompiler.flash.action.UnknownActionException; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.parser.ASMParser; import com.jpexs.decompiler.flash.action.parser.ParseException; @@ -54,6 +55,7 @@ import java.io.PrintStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Scanner; import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; @@ -210,7 +212,7 @@ public class SWFInputStream extends InputStream { baos.write(r); } } - + /** * Reads one UI32 (Unsigned 32bit integer) value from the stream * @@ -483,6 +485,11 @@ public class SWFInputStream extends InputStream { return ret; } + public List readActionList() throws IOException { + ReReadableInputStream rri = new ReReadableInputStream(this); + return readActionList(rri, version, 0); + } + /** * Reads list of actions from the stream. Reading ends with ActionEndFlag(=0) * or end of the stream. @@ -490,15 +497,27 @@ public class SWFInputStream extends InputStream { * @return List of actions * @throws IOException */ - public List readActionList() throws IOException { + public static List readActionList(ReReadableInputStream rri, int version, int ip) throws IOException { List retdups = new ArrayList(); ConstantPool cpool = null; Stack stack = new Stack(); - ReReadableInputStream rri = new ReReadableInputStream(this); + List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); + + + //ReReadableInputStream rri = new ReReadableInputStream(this); SWFInputStream sis = new SWFInputStream(rri, version); - readActionListAtPos(stack, cpool, sis, rri, 0, retdups); + boolean goesPrev = false; + try { + goesPrev = readActionListAtPos(false, localData, stack, cpool, sis, rri, ip, retdups, ip); + } catch (Exception ex) { + goesPrev = readActionListAtPos(true, localData, stack, cpool, sis, rri, ip, retdups, ip); + } + if (goesPrev) { + retdups.add(0, new ActionJump(ip)); + + } List ret = new ArrayList(); Action last = null; for (Action a : retdups) { @@ -507,27 +526,44 @@ public class SWFInputStream extends InputStream { } last = a; } + String s = null; try { - String s = Highlighting.stripHilights(Action.actionsToString(ret, null, version)); + s = Highlighting.stripHilights(Action.actionsToString(ret, null, version)); ret = ASMParser.parse(new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION); } catch (ParseException ex) { Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex); } return ret; } + public static List dobranch = new ArrayList(); - private void readActionListAtPos(Stack stack, ConstantPool cpool, SWFInputStream sis, ReReadableInputStream rri, int ip, List ret) throws IOException { + private static boolean readActionListAtPos(boolean enableVariables, List localData, Stack stack, ConstantPool cpool, SWFInputStream sis, ReReadableInputStream rri, int ip, List ret, int startIp) throws IOException { boolean debugMode = false; - boolean displayCompiletime = false; + boolean decideBranch = false; + boolean retv = false; rri.setPos(ip); Action a; List output = new ArrayList(); long filePos = rri.getPos(); + Scanner sc = new Scanner(System.in); while ((a = sis.readAction()) != null) { - if (debugMode) { - System.out.println("ip: " + ip + " action: " + a + " stack:" + Highlighting.stripHilights(stack.toString())); + /*int info=a.actionLength+1+((a.actionCode>0x80)?2:0); + int actual=a.getBytes(sis.version).length; + if(info!=actual){ + if(!(a instanceof ActionDefineFunction)) if(!(a instanceof ActionDefineFunction2)) + throw new RuntimeException("Lengths do not match "+a+" "+info+"<>"+actual); + }*/ + if (ip < startIp) { + retv = true; } - + if (debugMode) { + //if(a instanceof ActionIf){ + System.out.println(" ip: " + ip + " action(len " + a.actionLength + "): " + a + " stack:" + Highlighting.stripHilights(stack.toString()) + " " + Helper.byteArrToString(a.getBytes(SWF.DEFAULT_VERSION))); + //} + } + /*if(a instanceof ActionConstantPool){ + throw new IllegalArgumentException("CP found"); + } */ if (a instanceof ActionPush) { if (cpool != null) { ((ActionPush) a).constantPool = cpool.constants; @@ -548,7 +584,7 @@ public class SWFInputStream extends InputStream { ensureCapacity(ret, ip); int newip = -1; - if (!(ret.get(ip) instanceof ActionNop)) { + if (!enableVariables && (!(ret.get(ip) instanceof ActionNop))) { break; } @@ -564,14 +600,35 @@ public class SWFInputStream extends InputStream { if (a instanceof ActionIf) { aif = (ActionIf) a; GraphTargetItem top = stack.pop(); - if (top.isCompileTime()) { + int nip = rri.getPos() + aif.offset; + + if (decideBranch) { + System.out.print("newip " + nip + ", "); + System.out.print("Action: jump(j),ignore(i),compute(c)?"); + String next = sc.next(); + if (next.equals("j")) { + newip = rri.getPos() + aif.offset; + rri.setPos(newip); + + } else if (next.equals("i")) { + } else if (next.equals("c")) { + goaif = true; + } + } else if (top.isCompileTime() && ((!top.isVariableComputed()) || (top.isVariableComputed() && enableVariables))) { + //if(top.isCompileTime()) { + //if(false){ + if (enableVariables) { + ((ActionIf) a).compileTime = true; + } if (debugMode) { System.out.print("is compiletime -> "); } if (top.toBoolean()) { newip = rri.getPos() + aif.offset; - rri.setPos(newip); - a = new ActionJump(aif.offset); + //rri.setPos(newip); + if (!enableVariables) { + a = new ActionJump(aif.offset); + } if (debugMode) { System.out.println("jump"); } @@ -579,11 +636,11 @@ public class SWFInputStream extends InputStream { if (debugMode) { System.out.println("ignore"); } - a = new ActionNop(); + if (!enableVariables) { + a = new ActionNop(); + } } - if (displayCompiletime) { - beforeInsert = new ActionPop(); - } else { + if (!enableVariables) { List needed = top.getNeededSources(); for (GraphSourceItemPos ig : needed) { if (ig.item instanceof ActionPush) { @@ -601,13 +658,16 @@ public class SWFInputStream extends InputStream { } } else { + //throw new RuntimeException("goaif"); goaif = true; } } else if (a instanceof ActionJump) { newip = rri.getPos() + ((ActionJump) a).offset; - rri.setPos(newip); + //if(newip>=0){ + //rri.setPos(newip); + //} } else { - a.translate(Helper.toList(new HashMap()), stack, output); + a.translate(localData, stack, output); } for (int i = 0; i < actionLen; i++) { ensureCapacity(ret, ip + i); @@ -627,16 +687,20 @@ public class SWFInputStream extends InputStream { } else { ip = ip + (int) actionLen; } + rri.setPos(ip); filePos = rri.getPos(); if (goaif) { int oldPos = rri.getPos(); - readActionListAtPos(stack, cpool, sis, rri, rri.getPos() + aif.offset, ret); + if (readActionListAtPos(enableVariables, localData, stack, cpool, sis, rri, rri.getPos() + aif.offset, ret, startIp)) { + retv = true; + } rri.setPos(oldPos); } } + return retv; } - private void ensureCapacity(List ret, int index) { + private static void ensureCapacity(List ret, int index) { while (ret.size() <= index) { ret.add(new ActionNop()); } @@ -673,6 +737,7 @@ public class SWFInputStream extends InputStream { public List readTagList(int level) throws IOException { List tags = new ArrayList(); Tag tag; + Tag previousTag = null; while (true) { long pos = getPos(); tag = readTag(level, pos); @@ -683,6 +748,8 @@ public class SWFInputStream extends InputStream { if (Main.dump_tags && level == 0) { dumpTag(System.out, version, tag, level); } + tag.previousTag = previousTag; + previousTag = tag; } return tags; } @@ -1195,7 +1262,8 @@ public class SWFInputStream extends InputStream { if (actionLength > 0) { skip(actionLength); } - return new Action(actionCode, actionLength); + throw new UnknownActionException(actionCode); + //return new Action(actionCode, actionLength); } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java index bc3afe10f..0b5a721fb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -106,7 +106,7 @@ public class SWFOutputStream extends OutputStream { write(value.getBytes("utf8")); write(0); } - + /** * Writes UI32 (Unsigned 32bit integer) value to the stream * @@ -258,7 +258,6 @@ public class SWFOutputStream extends OutputStream { value = value >> 7; } while (loop); } - /** * Flushes data to underlying stream @@ -374,6 +373,27 @@ public class SWFOutputStream extends OutputStream { } } + public static byte[] getTagHeader(Tag tag, byte data[], int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + + SWFOutputStream sos = new SWFOutputStream(baos, version); + int tagLength = data.length; + int tagID = tag.getId(); + int tagIDLength = (tagID << 6); + if ((tagLength < 0x3f) && (!tag.forceWriteAsLong)) { + tagIDLength += tagLength; + sos.writeUI16(tagIDLength); + } else { + tagIDLength += 0x3f; + sos.writeUI16(tagIDLength); + sos.writeSI32(tagLength); + } + } catch (IOException iex) { + } + return baos.toByteArray(); + } + /** * Writes Tag value to the stream * @@ -382,17 +402,7 @@ public class SWFOutputStream extends OutputStream { */ public void writeTag(Tag tag) throws IOException { byte data[] = tag.getData(version); - int tagLength = data.length; - int tagID = tag.getId(); - int tagIDLength = (tagID << 6); - if ((tagLength < 0x3f) && (!tag.forceWriteAsLong)) { - tagIDLength += tagLength; - writeUI16(tagIDLength); - } else { - tagIDLength += 0x3f; - writeUI16(tagIDLength); - writeSI32(tagLength); - } + write(getTagHeader(tag, data, version)); write(data); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index 6ce6ff621..31f6022aa 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -283,24 +283,6 @@ public class ABC { bodyIdxFromMethodIdx[mb.method_info] = i; } loadNamespaceMap(); - /* for(ScriptInfo si:script_info){ - System.out.println("--------------------------------------------"); - System.out.println(findBody(si.init_index).toString(true, false, -1, this, constants, method_info,new Stack(),false,false)); - System.out.println("sitrait:"+si.traits.toString(this)); - }*/ - /*try { - MethodBody body=new MethodBody(); - AVM2Code code=ASM3Parser.parse(new FileInputStream("D:\\tst2.txt"), constants, body); - //code.removeTraps(constants, body); - code.restoreControlFlow(constants, body); - FileOutputStream fos=new FileOutputStream("D:\\tst3.txt"); - fos.write(Highlighting.stripHilights(code.toASMSource(constants, body)).getBytes()); - fos.close(); - System.out.println(code.toSource(false, 0, this, constants, method_info, body, new HashMap(), new Stack(), false, null, null)); - System.exit(0); - } catch (Exception ex) { - Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, ex); - }*/ } public void saveToStream(OutputStream os) throws IOException { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 2f8d24662..51ed2d437 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1158,10 +1158,6 @@ public class AVM2Code implements Serializable { unknownJumps.remove(new Integer(ip)); throw new UnknownJumpException(stack, ip, output); } - //System.out.println("ip"+ip+" ofs"+Helper.formatAddress(pos2adr(ip))); - if (ip == 21) { - //System.out.println("hh"); - } if (visited[ip]) { Logger.getLogger(AVM2Code.class.getName()).warning("Code already visited, ofs:" + Helper.formatAddress(pos2adr(ip)) + ", ip:" + ip); break; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index fa14dc521..400c6abd0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -48,6 +48,7 @@ import com.jpexs.decompiler.flash.graph.BreakItem; import com.jpexs.decompiler.flash.graph.Graph; import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphPartMulti; +import com.jpexs.decompiler.flash.graph.GraphSource; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.Loop; import com.jpexs.decompiler.flash.graph.SwitchItem; @@ -1141,7 +1142,7 @@ public class AVM2Graph extends Graph { }*/ @Override - protected List check(List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { + protected List check(GraphSource srcCode, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { List ret = null; @@ -1454,13 +1455,13 @@ public class AVM2Graph extends Graph { nextCase = next; if (next != null) { if (i < caseBodies.size() - 1) { - if (!caseBodies.get(i).leadsTo(caseBodies.get(i + 1), ignored)) { + if (!caseBodies.get(i).leadsTo(srcCode, caseBodies.get(i + 1), ignored)) { cc.add(new BreakItem(null, currentLoop.id)); } else { nextCase = caseBodies.get(i + 1); } } else if (hasDefault) { - if (!caseBodies.get(i).leadsTo(defaultPart, ignored)) { + if (!caseBodies.get(i).leadsTo(srcCode, defaultPart, ignored)) { cc.add(new BreakItem(null, currentLoop.id)); } else { nextCase = defaultPart; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index df5da575a..472cd97d0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -283,4 +283,9 @@ public class AVM2Instruction implements Serializable, GraphSourceItem { } return ret; } + + @Override + public boolean ignoredLoops() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java index 249341f74..c8e89c4b5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java @@ -23,8 +23,6 @@ import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.tags.DoABCTag; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.*; import java.util.ArrayList; @@ -214,15 +212,14 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { navigator.setABC(list, abc); - navPanel = new JPanel(new BorderLayout()); - JPanel navIconsPanel=new JPanel(); + navPanel = new JPanel(new BorderLayout()); + JPanel navIconsPanel = new JPanel(); navIconsPanel.setLayout(new BoxLayout(navIconsPanel, BoxLayout.X_AXIS)); - final JToggleButton sortButton=new JToggleButton(View.getIcon("sort16")); - navIconsPanel.add(sortButton); - navPanel.add(navIconsPanel,BorderLayout.SOUTH); + final JToggleButton sortButton = new JToggleButton(View.getIcon("sort16")); + navIconsPanel.add(sortButton); + navPanel.add(navIconsPanel, BorderLayout.SOUTH); navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER); sortButton.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent e) { navigator.setSorted(sortButton.isSelected()); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java index 5aa57ff1d..f8141c888 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.gui; -import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; @@ -24,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph; import com.jpexs.decompiler.flash.abc.avm2.parser.ASM3Parser; import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.helpers.Highlighting; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -43,6 +43,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi private DecompiledEditorPane decompiledEditor; private boolean ignoreCarret = false; private String name; + public void setIgnoreCarret(boolean ignoreCarret) { this.ignoreCarret = ignoreCarret; } @@ -72,11 +73,10 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi return super.getName(); } - - public void setBodyIndex(int bodyIndex, ABC abc,String name) { + public void setBodyIndex(int bodyIndex, ABC abc, String name) { this.bodyIndex = bodyIndex; this.abc = abc; - this.name=name; + this.name = name; setText(abc.bodies[bodyIndex].code.toASMSource(abc.constants, abc.bodies[bodyIndex])); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java index 234f36970..6820cf208 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java @@ -136,7 +136,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL if ((pos >= tm.startPos) && (pos < tm.startPos + tm.len)) { String name = ""; if (abc != null) { - name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); + name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); } for (Highlighting th : traitHighlights) { if ((pos >= th.startPos) && (pos < th.startPos + th.len)) { @@ -144,7 +144,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL if (abc != null) { Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex); if (t != null) { - name += ":"+t.getName(abc).getName(abc.constants, new ArrayList()); + name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); } } } @@ -180,7 +180,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex); if (t != null) { - name+=":"+t.getName(abc).getName(abc.constants, new ArrayList()); + name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java index 517537073..0901941b2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java @@ -52,20 +52,20 @@ public class IconListRenderer // Get icon to use for the list item value - TraitsListItem tli=(TraitsListItem)value; - - if (tli.getType()==TraitsListItem.Type.CONST) { + TraitsListItem tli = (TraitsListItem) value; + + if (tli.getType() == TraitsListItem.Type.CONST) { label.setIcon(constIcon); } - if (tli.getType()==TraitsListItem.Type.VAR) { + if (tli.getType() == TraitsListItem.Type.VAR) { label.setIcon(variableIcon); } - if (tli.getType()==TraitsListItem.Type.METHOD) { + if (tli.getType() == TraitsListItem.Type.METHOD) { label.setIcon(functionIcon); } - if (tli.getType()==TraitsListItem.Type.INITIALIZER) { + if (tli.getType() == TraitsListItem.Type.INITIALIZER) { label.setIcon(functionIcon); - } + } return label; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java index bafd70b5e..872d3b26e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java @@ -49,11 +49,9 @@ public class LineMarkedEditorPane extends JEditorPane { @Override public void setText(String t) { - lastLine=-1; + lastLine = -1; super.setText(t); } - - @Override public void paint(Graphics g) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java index 91d85d6c4..47903a101 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java @@ -40,8 +40,8 @@ public class MethodCodePanel extends JPanel implements ActionListener { public void focusEditor() { sourceTextArea.requestFocusInWindow(); } - - public String getTraitName(){ + + public String getTraitName() { return sourceTextArea.getName(); } @@ -54,10 +54,11 @@ public class MethodCodePanel extends JPanel implements ActionListener { } public void setBodyIndex(int bodyIndex, ABC abc) { - sourceTextArea.setBodyIndex(bodyIndex, abc,sourceTextArea.getName()); + sourceTextArea.setBodyIndex(bodyIndex, abc, sourceTextArea.getName()); } - public void setBodyIndex(int bodyIndex, ABC abc,String name) { - sourceTextArea.setBodyIndex(bodyIndex, abc,name); + + public void setBodyIndex(int bodyIndex, ABC abc, String name) { + sourceTextArea.setBodyIndex(bodyIndex, abc, name); } public int getBodyIndex() { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java index 714493987..3ff1dbbbb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java @@ -30,19 +30,14 @@ public class TraitsList extends JList implements ListSelectionListener { List abcTags; int classIndex = -1; private ABCPanel abcPanel; - - private boolean sorted=false; + private boolean sorted = false; public void setSorted(boolean sorted) { - if(getModel() instanceof TraitsListModel){ - ((TraitsListModel)getModel()).setSorted(sorted); + if (getModel() instanceof TraitsListModel) { + ((TraitsListModel) getModel()).setSorted(sorted); } - this.sorted=sorted; + this.sorted = sorted; } - - - - public int getClassIndex() { return classIndex; @@ -67,21 +62,20 @@ public class TraitsList extends JList implements ListSelectionListener { setModel(new DefaultListModel()); } else { if (abc != null) { - setModel(new TraitsListModel(abcTags, abc, classIndex,sorted)); + setModel(new TraitsListModel(abcTags, abc, classIndex, sorted)); } } } - - private int lastSelected=-1; + private int lastSelected = -1; @Override public void valueChanged(ListSelectionEvent e) { - if(getSelectedIndex()==lastSelected){ + if (getSelectedIndex() == lastSelected) { return; } - lastSelected=getSelectedIndex(); - TraitsListItem sel = (TraitsListItem)getSelectedValue(); - abcPanel.decompiledTextArea.gotoTrait(sel==null?-1:sel.getGlobalTraitId()); + lastSelected = getSelectedIndex(); + TraitsListItem sel = (TraitsListItem) getSelectedValue(); + abcPanel.decompiledTextArea.gotoTrait(sel == null ? -1 : sel.getGlobalTraitId()); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java index cdd65a7ae..12f71485a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java @@ -13,6 +13,7 @@ import java.util.List; * @author JPEXS */ public class TraitsListItem { + private Type type; private boolean isStatic; private List abcTags; @@ -21,79 +22,79 @@ public class TraitsListItem { private int index; public static final String STR_INSTANCE_INITIALIZER = "instance initializer"; public static final String STR_CLASS_INITIALIZER = "class initializer"; - public TraitsListItem(Type type, int index, boolean isStatic, List abcTags, ABC abc, int classIndex) { this.type = type; - this.index=index; + this.index = index; this.isStatic = isStatic; this.abcTags = abcTags; this.abc = abc; this.classIndex = classIndex; } - public int getGlobalTraitId(){ - if(type == Type.INITIALIZER){ - if(!isStatic){ - return abc.class_info[classIndex].static_traits.traits.length+abc.instance_info[classIndex].instance_traits.traits.length; - }else{ - return abc.class_info[classIndex].static_traits.traits.length+abc.instance_info[classIndex].instance_traits.traits.length+1; + public int getGlobalTraitId() { + if (type == Type.INITIALIZER) { + if (!isStatic) { + return abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length; + } else { + return abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length + 1; } } - if(isStatic){ + if (isStatic) { return index; - }else{ - return abc.class_info[classIndex].static_traits.traits.length+index; - } - } - - public String toStringName(){ - if ((type!= Type.INITIALIZER) && isStatic) { - return abc.class_info[classIndex].static_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); - } else if ((type!= Type.INITIALIZER) && (!isStatic)) { - return abc.instance_info[classIndex].instance_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); - } else if (!isStatic) { - return "__"+STR_INSTANCE_INITIALIZER; } else { - return "__"+STR_CLASS_INITIALIZER; + return abc.class_info[classIndex].static_traits.traits.length + index; } } - + + public String toStringName() { + if ((type != Type.INITIALIZER) && isStatic) { + return abc.class_info[classIndex].static_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); + } else if ((type != Type.INITIALIZER) && (!isStatic)) { + return abc.instance_info[classIndex].instance_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); + } else if (!isStatic) { + return "__" + STR_INSTANCE_INITIALIZER; + } else { + return "__" + STR_CLASS_INITIALIZER; + } + } + @Override public String toString() { - if ((type!= Type.INITIALIZER) && isStatic) { + if ((type != Type.INITIALIZER) && isStatic) { return abc.class_info[classIndex].static_traits.traits[index].convertHeader("", abcTags, abc, true, false, classIndex, false, new ArrayList()); - } else if ((type!= Type.INITIALIZER) && (!isStatic)) { - return abc.instance_info[classIndex].instance_traits.traits[index].convertHeader("", abcTags, abc, false, false, classIndex, false, new ArrayList()); + } else if ((type != Type.INITIALIZER) && (!isStatic)) { + return abc.instance_info[classIndex].instance_traits.traits[index].convertHeader("", abcTags, abc, false, false, classIndex, false, new ArrayList()); } else if (!isStatic) { return STR_INSTANCE_INITIALIZER; } else { return STR_CLASS_INITIALIZER; } - } - + } + public Type getType() { return type; } - - public boolean isStatic(){ + + public boolean isStatic() { return isStatic; } - + public enum Type { + METHOD, VAR, CONST, INITIALIZER; - - public static Type getTypeForTrait(Trait t){ - if(t instanceof TraitMethodGetterSetter){ + + public static Type getTypeForTrait(Trait t) { + if (t instanceof TraitMethodGetterSetter) { return METHOD; } - if(t instanceof TraitSlotConst){ - if(((TraitSlotConst)t).isConst()){ + if (t instanceof TraitSlotConst) { + if (((TraitSlotConst) t).isConst()) { return CONST; - }else{ + } else { return VAR; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java index c659f179a..e1d25f2a6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java @@ -57,12 +57,12 @@ public class TraitsListModel implements ListModel { items.add(new TraitsListItem(TraitsListItem.Type.INITIALIZER, 0, true, abcTags, abc, classIndex)); } - public TraitsListModel(List abcTags, ABC abc, int classIndex,boolean sorted) { + public TraitsListModel(List abcTags, ABC abc, int classIndex, boolean sorted) { this.abcTags = abcTags; this.abc = abc; this.classIndex = classIndex; reset(); - if(sorted){ + if (sorted) { setSorted(true); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 684a88b14..bc13f8dcd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -20,11 +20,9 @@ import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.parser.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.ParsedSymbol; -import com.jpexs.decompiler.flash.action.special.ActionNop; import com.jpexs.decompiler.flash.action.swf4.*; import com.jpexs.decompiler.flash.action.swf5.*; import com.jpexs.decompiler.flash.action.swf6.ActionEnumerate2; -import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; import com.jpexs.decompiler.flash.action.swf7.ActionTry; import com.jpexs.decompiler.flash.action.treemodel.*; import com.jpexs.decompiler.flash.action.treemodel.clauses.*; @@ -371,9 +369,9 @@ public class Action implements GraphSourceItem { if (a.beforeInsert != null) { ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version) + "\r\n"; } - if (!(a instanceof ActionNop)) { - ret += Highlighting.hilighOffset("", offset) + a.getASMSource(importantOffsets, constantPool, version) + "\r\n"; - } + //if (!(a instanceof ActionNop)) { + ret += Highlighting.hilighOffset("", offset) + a.getASMSource(importantOffsets, constantPool, version) + "\r\n"; + //} } offset += a.getBytes(version).length; } @@ -403,7 +401,7 @@ public class Action implements GraphSourceItem { * @param output Output * @param regNames Register names */ - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { } /** @@ -476,7 +474,7 @@ public class Action implements GraphSourceItem { public static String actionsToSource(List actions, int version) { try { //List tree = actionsToTree(new HashMap(), actions, version); - List tree = actionsToTree(new HashMap(), actions, version); + List tree = actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, version); return Graph.graphToString(tree); @@ -494,15 +492,15 @@ public class Action implements GraphSourceItem { * @param version SWF version * @return List of treeItems */ - public static List actionsToTree(HashMap regNames, List actions, int version) { + public static List actionsToTree(HashMap regNames, HashMap variables, HashMap functions, List actions, int version) { //Stack stack = new Stack(); - return ActionGraph.translateViaGraph(regNames, actions, version); + return ActionGraph.translateViaGraph(regNames, variables, functions, actions, version); //return actionsToTree(regNames, stack, actions, 0, actions.size() - 1, version); } @Override public void translate(List localData, Stack stack, List output) { - translate(stack, output, (HashMap) localData.get(0)); + translate(stack, output, (HashMap) localData.get(0), (HashMap) localData.get(1), (HashMap) localData.get(2)); } @Override @@ -552,12 +550,14 @@ public class Action implements GraphSourceItem { logger.fine(s); } - public static List actionsPartToTree(HashMap registerNames, Stack stack, List actions, int start, int end, int version) { + public static List actionsPartToTree(HashMap registerNames, HashMap variables, HashMap functions, Stack stack, List actions, int start, int end, int version) { if (start < actions.size() && (end > 0) && (start > 0)) { log("Entering " + start + "-" + end + (actions.size() > 0 ? (" (" + actions.get(start).toString() + " - " + actions.get(end == actions.size() ? end - 1 : end) + ")") : "")); } List localData = new ArrayList(); localData.add(registerNames); + localData.add(variables); + localData.add(functions); List output = new ArrayList(); int ip = start; boolean isWhile = false; @@ -617,7 +617,7 @@ public class Action implements GraphSourceItem { continue; } else if (action instanceof ActionTry) { ActionTry atry = (ActionTry) action; - List tryCommands = ActionGraph.translateViaGraph(registerNames, atry.tryBody, version); + List tryCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, atry.tryBody, version); TreeItem catchName; if (atry.catchInRegisterFlag) { catchName = new DirectValueTreeItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList()); @@ -627,53 +627,14 @@ public class Action implements GraphSourceItem { List catchExceptions = new ArrayList(); catchExceptions.add(catchName); List> catchCommands = new ArrayList>(); - catchCommands.add(ActionGraph.translateViaGraph(registerNames, atry.catchBody, version)); - List finallyCommands = ActionGraph.translateViaGraph(registerNames, atry.finallyBody, version); + catchCommands.add(ActionGraph.translateViaGraph(registerNames, variables, functions, atry.catchBody, version)); + List finallyCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, atry.finallyBody, version); output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); } else if (action instanceof ActionWith) { ActionWith awith = (ActionWith) action; - List withCommands = ActionGraph.translateViaGraph(registerNames, awith.actions, version); + List withCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, awith.actions, version); output.add(new WithTreeItem(action, stack.pop(), withCommands)); - } else if (action instanceof ActionDefineFunction) { - FunctionTreeItem fti = new FunctionTreeItem(action, ((ActionDefineFunction) action).functionName, ((ActionDefineFunction) action).paramNames, ActionGraph.translateViaGraph(registerNames, ((ActionDefineFunction) action).code, version), ((ActionDefineFunction) action).constantPool, 1); - stack.push(fti); - } else if (action instanceof ActionDefineFunction2) { - HashMap funcRegNames = (HashMap) registerNames.clone(); - for (int f = 0; f < ((ActionDefineFunction2) action).paramNames.size(); f++) { - int reg = ((ActionDefineFunction2) action).paramRegisters.get(f); - if (reg != 0) { - funcRegNames.put(reg, ((ActionDefineFunction2) action).paramNames.get(f)); - } - } - int pos = 1; - if (((ActionDefineFunction2) action).preloadThisFlag) { - funcRegNames.put(pos, "this"); - pos++; - } - if (((ActionDefineFunction2) action).preloadArgumentsFlag) { - funcRegNames.put(pos, "arguments"); - pos++; - } - if (((ActionDefineFunction2) action).preloadSuperFlag) { - funcRegNames.put(pos, "super"); - pos++; - } - if (((ActionDefineFunction2) action).preloadRootFlag) { - funcRegNames.put(pos, "_root"); - pos++; - } - if (((ActionDefineFunction2) action).preloadParentFlag) { - funcRegNames.put(pos, "_parent"); - pos++; - } - if (((ActionDefineFunction2) action).preloadGlobalFlag) { - funcRegNames.put(pos, "_global"); - pos++; - } - - FunctionTreeItem fti = new FunctionTreeItem(action, ((ActionDefineFunction2) action).functionName, ((ActionDefineFunction2) action).paramNames, ActionGraph.translateViaGraph(funcRegNames, ((ActionDefineFunction2) action).code, version), ((ActionDefineFunction2) action).constantPool, ((ActionDefineFunction2) action).getFirstRegister()); - stack.push(fti); - } /*else if (action instanceof ActionPushDuplicate) { + }/*else if (action instanceof ActionPushDuplicate) { do { if (actions.get(ip + 1) instanceof ActionNot) { if (actions.get(ip + 2) instanceof ActionIf) { @@ -749,7 +710,6 @@ public class Action implements GraphSourceItem { try { action.translate(localData, stack, output); } catch (EmptyStackException ese) { - System.err.println("EMPTYSTACK==========================="); Logger.getLogger(Action.class.getName()).log(Level.SEVERE, null, ese); output.add(new UnsupportedTreeItem(action, "Empty stack")); } @@ -783,9 +743,9 @@ public class Action implements GraphSourceItem { } if (((GetMemberTreeItem) t).object instanceof GetVariableTreeItem) { GetVariableTreeItem v = (GetVariableTreeItem) ((GetMemberTreeItem) t).object; - if (v.value instanceof DirectValueTreeItem) { - if (((DirectValueTreeItem) v.value).value instanceof String) { - if (((DirectValueTreeItem) v.value).value.equals("_global")) { + if (v.name instanceof DirectValueTreeItem) { + if (((DirectValueTreeItem) v.name).value instanceof String) { + if (((DirectValueTreeItem) v.name).value.equals("_global")) { GetVariableTreeItem gvt = new GetVariableTreeItem(null, ((GetMemberTreeItem) t).memberName); if (lastMember == null) { return gvt; @@ -1001,4 +961,9 @@ public class Action implements GraphSourceItem { } return ret; } + + @Override + public boolean ignoredLoops() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java index a981543e6..9a9755cfe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.graph.BreakItem; import com.jpexs.decompiler.flash.graph.ContinueItem; import com.jpexs.decompiler.flash.graph.Graph; import com.jpexs.decompiler.flash.graph.GraphPart; +import com.jpexs.decompiler.flash.graph.GraphSource; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.Loop; import com.jpexs.decompiler.flash.graph.SwitchItem; @@ -44,8 +45,8 @@ public class ActionGraph extends Graph { private List code; //private int version; - public ActionGraph(List code, HashMap registerNames, int version) { - super(new ActionGraphSource(code, version, registerNames), new ArrayList()); + public ActionGraph(List code, HashMap registerNames, HashMap variables, HashMap functions, int version) { + super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList()); //this.version = version; this.code = code; /*heads = makeGraph(code, new ArrayList()); @@ -55,8 +56,8 @@ public class ActionGraph extends Graph { }*/ } - public static List translateViaGraph(HashMap registerNames, List code, int version) { - ActionGraph g = new ActionGraph(code, registerNames, version); + public static List translateViaGraph(HashMap registerNames, HashMap variables, HashMap functions, List code, int version) { + ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version); List localData = new ArrayList(); localData.add(registerNames); return g.translate(localData); @@ -72,7 +73,7 @@ public class ActionGraph extends Graph { } @Override - protected List check(List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { + protected List check(GraphSource code, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { List ret = null; if ((part.nextParts.size() == 2) && (stack.peek() instanceof StrictEqTreeItem)) { @@ -139,7 +140,7 @@ public class ActionGraph extends Graph { List breakParts = new ArrayList(); for (int g = 0; g < caseBodyParts.size(); g++) { if (g < caseBodyParts.size() - 1) { - if (caseBodyParts.get(g).leadsTo(caseBodyParts.get(g + 1), loopContinues)) { + if (caseBodyParts.get(g).leadsTo(code, caseBodyParts.get(g + 1), loopContinues)) { continue; } } @@ -212,13 +213,13 @@ public class ActionGraph extends Graph { nextCase = next; if (next != null) { if (i < caseBodies.size() - 1) { - if (!caseBodies.get(i).leadsTo(caseBodies.get(i + 1), ignored)) { + if (!caseBodies.get(i).leadsTo(code, caseBodies.get(i + 1), ignored)) { cc.add(new BreakItem(null, currentLoop.id)); } else { nextCase = caseBodies.get(i + 1); } } else if (!defaultCommands.isEmpty()) { - if (!caseBodies.get(i).leadsTo(defaultPart, ignored)) { + if (!caseBodies.get(i).leadsTo(code, defaultPart, ignored)) { cc.add(new BreakItem(null, currentLoop.id)); } else { nextCase = defaultPart; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java index 48edd4c78..e8ff27898 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java @@ -16,11 +16,15 @@ public class ActionGraphSource extends GraphSource { private List actions; public int version; private HashMap registerNames; + private HashMap variables; + private HashMap functions; - public ActionGraphSource(List actions, int version, HashMap registerNames) { + public ActionGraphSource(List actions, int version, HashMap registerNames, HashMap variables, HashMap functions) { this.actions = actions; this.version = version; this.registerNames = registerNames; + this.variables = variables; + this.functions = functions; } @Override @@ -40,7 +44,7 @@ public class ActionGraphSource extends GraphSource { @Override public List translatePart(List localData, Stack stack, int start, int end) { - return (Action.actionsPartToTree(registerNames, stack, actions, start, end, version)); + return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version)); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/action/UnknownActionException.java b/trunk/src/com/jpexs/decompiler/flash/action/UnknownActionException.java new file mode 100644 index 000000000..106fc8fb9 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/action/UnknownActionException.java @@ -0,0 +1,14 @@ +package com.jpexs.decompiler.flash.action; + +/** + * + * @author JPEXS + */ +public class UnknownActionException extends RuntimeException{ + public int opCode; + + public UnknownActionException(int opCode) { + this.opCode = opCode; + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java index d23a6fa31..dbabef07a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.FSCommand2TreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionFSCommand2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { long numArgs = popLong(stack); GraphTargetItem command = stack.pop(); List args = new ArrayList(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java index 583588a33..6b417300d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.treemodel.StrictModeTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -60,7 +61,7 @@ public class ActionStrictMode extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new StrictModeTreeItem(this, mode)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java index 9a9f7926f..9562996a5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java @@ -18,11 +18,12 @@ package com.jpexs.decompiler.flash.action.gui; import com.jpexs.decompiler.flash.Main; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.abc.gui.LineMarkedEditorPane; import com.jpexs.decompiler.flash.action.ActionGraph; import com.jpexs.decompiler.flash.action.parser.ASMParser; import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; @@ -242,7 +243,7 @@ public class ActionPanel extends JPanel implements ActionListener { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("GRAPH")) { if (lastCode != null) { - GraphFrame gf = new GraphFrame(new ActionGraph(lastCode, new HashMap(), SWF.DEFAULT_VERSION), ""); + GraphFrame gf = new GraphFrame(new ActionGraph(lastCode, new HashMap(), new HashMap(), new HashMap(), SWF.DEFAULT_VERSION), ""); gf.setVisible(true); } } else if (e.getActionCommand().equals("EDITACTION")) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java index c521e97e0..c7975dd9a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java @@ -38,6 +38,16 @@ public class ASMParser { ParsedSymbol symb = lexer.yylex(); if (symb.type == ParsedSymbol.TYPE_LABEL) { labels.add(new Label((String) symb.value, address)); + } else if (symb.type == ParsedSymbol.TYPE_COMMENT) { + if (!list.isEmpty()) { + String cmt = (String) symb.value; + if (cmt.equals("compileTime")) { + Action a = list.get(list.size() - 1); + if (a instanceof ActionIf) { + ((ActionIf) a).compileTime = true; + } + } + } } else if (symb.type == ParsedSymbol.TYPE_INSTRUCTION_NAME) { String instructionName = ((String) symb.value).toLowerCase(); if (instructionName.equals("GetURL".toLowerCase())) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/FlasmLexer.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/FlasmLexer.java index 73abfdca6..b38e45478 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/FlasmLexer.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/FlasmLexer.java @@ -1,19 +1,6 @@ -/* - * Copyright (C) 2010-2013 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 . - */ +/* The following code was generated by JFlex 1.4.3 on 9.3.13 17:48 */ + +/* Flash assembler language lexer specification */ package com.jpexs.decompiler.flash.action.parser; import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; @@ -23,8 +10,8 @@ import com.jpexs.decompiler.flash.action.swf4.Undefined; /** * This class is a scanner generated by JFlex - * 1.4.3 on 15.1.11 16:48 from the specification file - * D:/Dokumenty/Programovani/JavaSE/ASDec/trunk/src/com/jpexs/decompiler/flash/action/parser/flasm.flex + * 1.4.3 on 9.3.13 17:48 from the specification file + * D:/Dokumenty/Programovani/JavaSE/FFDec/trunk/src/com/jpexs/decompiler/flash/action/parser/flasm.flex */ public final class FlasmLexer { @@ -55,10 +42,10 @@ public final class FlasmLexer { */ private static final String ZZ_CMAP_PACKED = "\11\6\1\4\1\2\1\0\1\4\1\1\16\6\4\0\1\4\1\0" - + "\1\41\1\0\1\5\2\0\1\43\3\0\1\33\1\0\1\33\1\31" - + "\1\0\1\30\3\44\4\34\2\11\1\12\1\3\5\0\4\7\1\32" - + "\25\7\1\0\1\35\2\0\1\10\1\0\1\22\1\42\1\37\1\26" - + "\1\20\1\21\1\36\1\7\1\27\2\7\1\23\1\7\1\25\1\40" + + "\1\42\1\0\1\5\2\0\1\44\3\0\1\34\1\0\1\31\1\32" + + "\1\0\1\30\3\45\4\35\2\11\1\12\1\3\5\0\4\7\1\33" + + "\25\7\1\0\1\36\2\0\1\10\1\0\1\22\1\43\1\40\1\26" + + "\1\20\1\21\1\37\1\7\1\27\2\7\1\23\1\7\1\25\1\41" + "\2\7\1\16\1\24\1\15\1\17\5\7\1\13\1\0\1\14\1\0" + "\41\6\2\0\4\5\4\0\1\5\2\0\1\6\7\0\1\5\4\0" + "\1\5\5\0\27\5\1\0\37\5\1\0\u013f\5\31\0\162\5\4\0" @@ -151,14 +138,15 @@ public final class FlasmLexer { private static final int[] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = "\3\0\3\1\1\2\1\3\1\4\2\5\1\1\1\6" - + "\2\7\1\10\1\11\1\12\1\13\5\11\1\12\1\1" + + "\2\7\1\10\1\11\1\12\1\13\5\11\1\12\2\1" + "\1\11\1\14\1\0\1\15\1\16\1\17\1\20\1\21" + "\1\22\2\23\1\24\1\25\1\26\1\27\1\0\1\30" - + "\5\11\1\30\1\11\1\23\1\30\1\0\6\11\1\31" - + "\3\11\1\32\3\11\1\33\12\11\2\34\1\35\2\36"; + + "\5\11\1\30\2\12\1\11\1\23\1\30\1\0\6\11" + + "\1\31\3\11\1\32\3\11\1\33\12\11\2\34\1\35" + + "\2\36"; private static int[] zzUnpackAction() { - int[] result = new int[83]; + int[] result = new int[86]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -182,20 +170,20 @@ public final class FlasmLexer { */ private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\45\0\112\0\157\0\224\0\271\0\336\0\157" - + "\0\u0103\0\u0128\0\157\0\u014d\0\157\0\u0172\0\157\0\u0197" - + "\0\u01bc\0\u01e1\0\157\0\u0206\0\u022b\0\u0250\0\u0275\0\u029a" - + "\0\u02bf\0\u02e4\0\u0309\0\157\0\271\0\157\0\157\0\157" - + "\0\157\0\157\0\157\0\u032e\0\u0353\0\157\0\157\0\157" - + "\0\157\0\u0378\0\u039d\0\u03c2\0\u03e7\0\u040c\0\u0431\0\u0456" - + "\0\u02bf\0\u047b\0\157\0\u04a0\0\u04a0\0\u04c5\0\u04ea\0\u050f" - + "\0\u0534\0\u0559\0\u057e\0\u01bc\0\u05a3\0\u05c8\0\u05ed\0\u01bc" - + "\0\u0612\0\u0637\0\u065c\0\u01bc\0\u0681\0\u06a6\0\u06cb\0\u06f0" - + "\0\u0715\0\u073a\0\u075f\0\u0784\0\u07a9\0\u07ce\0\u07f3\0\u01bc" - + "\0\u01bc\0\u0818\0\u01bc"; + "\0\0\0\46\0\114\0\162\0\230\0\276\0\344\0\162" + + "\0\u010a\0\u0130\0\162\0\u0156\0\162\0\u017c\0\162\0\u01a2" + + "\0\u01c8\0\u01ee\0\162\0\u0214\0\u023a\0\u0260\0\u0286\0\u02ac" + + "\0\u02d2\0\u02f8\0\u031e\0\u0344\0\162\0\276\0\162\0\162" + + "\0\162\0\162\0\162\0\162\0\u036a\0\u0390\0\162\0\162" + + "\0\162\0\162\0\u03b6\0\u03dc\0\u0402\0\u0428\0\u044e\0\u0474" + + "\0\u049a\0\u02d2\0\u04c0\0\162\0\u04e6\0\162\0\u050c\0\u050c" + + "\0\u0532\0\u0558\0\u057e\0\u05a4\0\u05ca\0\u05f0\0\u01c8\0\u0616" + + "\0\u063c\0\u0662\0\u01c8\0\u0688\0\u06ae\0\u06d4\0\u01c8\0\u06fa" + + "\0\u0720\0\u0746\0\u076c\0\u0792\0\u07b8\0\u07de\0\u0804\0\u082a" + + "\0\u0850\0\u0876\0\u01c8\0\u01c8\0\u089c\0\u01c8"; private static int[] zzUnpackRowMap() { - int[] result = new int[83]; + int[] result = new int[86]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -217,106 +205,109 @@ public final class FlasmLexer { private static final int[] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = "\4\4\1\5\1\6\1\4\1\7\1\6\3\4\1\10" - + "\13\7\2\4\1\7\3\4\3\7\1\4\1\7\2\4" - + "\1\11\1\12\1\13\32\11\1\14\3\11\1\15\3\11" + + "\13\7\3\4\1\7\3\4\3\7\1\4\1\7\2\4" + + "\1\11\1\12\1\13\33\11\1\14\3\11\1\15\3\11" + "\1\4\1\16\1\17\1\20\1\4\1\21\1\4\2\21" + "\1\22\1\4\1\23\1\4\1\24\1\25\1\26\1\21" - + "\1\27\3\21\1\30\2\21\1\31\1\32\1\21\1\4" - + "\1\22\1\4\1\21\1\33\1\21\1\34\1\21\1\4" - + "\1\22\51\0\1\5\45\0\5\35\1\36\2\0\14\35" - + "\1\0\1\35\1\0\1\35\1\0\3\35\1\0\1\35" - + "\1\0\1\35\5\0\2\35\3\7\1\36\2\0\14\7" - + "\1\0\1\7\1\0\1\7\1\0\3\7\1\0\1\7" - + "\1\0\1\7\1\11\2\0\32\11\1\0\3\11\1\0" - + "\3\11\2\0\1\13\42\0\2\37\1\0\12\37\1\40" - + "\1\41\2\37\1\42\3\37\1\43\2\37\1\44\3\37" - + "\1\45\1\46\3\37\1\47\1\50\1\51\1\44\2\0" - + "\1\17\42\0\1\20\2\0\42\20\5\0\5\21\3\0" - + "\14\21\1\0\1\21\1\0\1\21\1\0\3\21\1\0" - + "\1\21\1\0\1\21\11\0\1\22\6\0\1\52\7\0" - + "\1\22\1\53\1\52\1\0\1\22\7\0\1\22\5\0" - + "\5\21\3\0\1\21\1\54\12\21\1\0\1\21\1\0" - + "\1\21\1\0\3\21\1\0\1\21\1\0\1\21\5\0" - + "\5\21\3\0\3\21\1\55\10\21\1\0\1\21\1\0" - + "\1\21\1\0\3\21\1\0\1\21\1\0\1\21\5\0" - + "\5\21\3\0\10\21\1\56\3\21\1\0\1\21\1\0" - + "\1\21\1\0\3\21\1\0\1\21\1\0\1\21\5\0" - + "\5\21\3\0\5\21\1\57\6\21\1\0\1\21\1\0" - + "\1\21\1\0\3\21\1\0\1\21\1\0\1\21\5\0" - + "\5\21\3\0\2\21\1\60\11\21\1\0\1\21\1\0" - + "\1\21\1\0\3\21\1\0\1\21\1\0\1\21\11\0" - + "\1\61\6\0\1\52\7\0\1\61\1\53\1\52\1\0" - + "\1\61\7\0\1\61\11\0\1\53\16\0\1\53\3\0" - + "\1\53\7\0\1\53\5\0\5\21\3\0\14\21\1\0" - + "\1\21\1\0\1\21\1\0\2\21\1\62\1\0\1\21" - + "\1\0\1\21\30\0\1\45\3\0\1\45\7\0\1\45" - + "\30\0\1\63\3\0\1\63\7\0\1\63\11\0\1\64" - + "\16\0\1\64\2\0\1\65\1\64\7\0\1\64\11\0" - + "\1\53\6\0\1\52\7\0\1\53\1\0\1\52\1\0" - + "\1\53\7\0\1\53\5\0\5\21\3\0\2\21\1\66" - + "\11\21\1\0\1\21\1\0\1\21\1\0\3\21\1\0" - + "\1\21\1\0\1\21\5\0\5\21\3\0\14\21\1\0" - + "\1\21\1\0\1\21\1\0\1\67\2\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\11\21\1\70\2\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\6\21\1\71\5\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\6\21\1\72\5\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\10\21\1\73\3\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\11\0\1\64\16\0\1\64\3\0\1\64" - + "\7\0\1\64\5\0\5\21\3\0\3\21\1\74\10\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\12\21\1\75\1\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\3\21\1\76\10\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\7\21\1\77\4\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\6\21\1\100\5\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\7\21\1\101\4\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\7\21\1\102\4\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\4\21\1\103\7\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\3\21\1\104\10\21" - + "\1\0\1\21\1\0\1\21\1\0\3\21\1\0\1\21" - + "\1\0\1\21\5\0\5\21\3\0\1\105\13\21\1\0" + + "\1\27\3\21\1\30\2\21\1\31\1\32\1\33\1\21" + + "\1\4\1\22\1\4\1\21\1\34\1\21\1\35\1\21" + + "\1\4\1\22\52\0\1\5\46\0\5\36\1\37\2\0" + + "\14\36\2\0\1\36\1\0\1\36\1\0\3\36\1\0" + + "\1\36\1\0\1\36\5\0\2\36\3\7\1\37\2\0" + + "\14\7\2\0\1\7\1\0\1\7\1\0\3\7\1\0" + + "\1\7\1\0\1\7\1\11\2\0\33\11\1\0\3\11" + + "\1\0\3\11\2\0\1\13\43\0\2\40\1\0\12\40" + + "\1\41\1\42\2\40\1\43\3\40\1\44\2\40\1\45" + + "\4\40\1\46\1\47\3\40\1\50\1\51\1\52\1\45" + + "\2\0\1\17\43\0\1\20\2\0\43\20\5\0\5\21" + + "\3\0\14\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\11\0\1\22\6\0\1\53" + + "\7\0\1\22\1\0\1\54\1\53\1\0\1\22\7\0" + + "\1\22\5\0\5\21\3\0\1\21\1\55\12\21\2\0" + "\1\21\1\0\1\21\1\0\3\21\1\0\1\21\1\0" - + "\1\21\5\0\5\21\3\0\1\106\13\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\12\21\1\107\1\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\5\21\1\110\6\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\3\21\1\111\10\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\10\21\1\112\3\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\10\21\1\113\3\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\1\21\1\114\12\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\3\21\1\115\10\21\1\0\1\21" - + "\1\0\1\21\1\0\3\21\1\0\1\21\1\0\1\21" - + "\5\0\5\21\3\0\1\116\13\21\1\0\1\21\1\0" + + "\1\21\5\0\5\21\3\0\3\21\1\56\10\21\2\0" + + "\1\21\1\0\1\21\1\0\3\21\1\0\1\21\1\0" + + "\1\21\5\0\5\21\3\0\10\21\1\57\3\21\2\0" + + "\1\21\1\0\1\21\1\0\3\21\1\0\1\21\1\0" + + "\1\21\5\0\5\21\3\0\5\21\1\60\6\21\2\0" + + "\1\21\1\0\1\21\1\0\3\21\1\0\1\21\1\0" + + "\1\21\5\0\5\21\3\0\2\21\1\61\11\21\2\0" + + "\1\21\1\0\1\21\1\0\3\21\1\0\1\21\1\0" + + "\1\21\11\0\1\62\6\0\1\53\7\0\1\62\1\0" + + "\1\54\1\53\1\0\1\62\7\0\1\62\11\0\1\63" + + "\16\0\1\64\4\0\1\63\7\0\1\63\11\0\1\54" + + "\16\0\1\54\4\0\1\54\7\0\1\54\5\0\5\21" + + "\3\0\14\21\2\0\1\21\1\0\1\21\1\0\2\21" + + "\1\65\1\0\1\21\1\0\1\21\30\0\1\46\4\0" + + "\1\46\7\0\1\46\30\0\1\66\4\0\1\66\7\0" + + "\1\66\11\0\1\67\16\0\1\67\1\70\2\0\1\70" + + "\1\67\7\0\1\67\11\0\1\54\6\0\1\53\7\0" + + "\1\54\2\0\1\53\1\0\1\54\7\0\1\54\5\0" + + "\5\21\3\0\2\21\1\71\11\21\2\0\1\21\1\0" + "\1\21\1\0\3\21\1\0\1\21\1\0\1\21\5\0" - + "\4\21\1\117\3\0\13\21\1\120\1\0\1\21\1\0" - + "\1\117\1\0\3\21\1\0\1\21\1\0\1\117\5\0" - + "\5\21\3\0\11\21\1\121\2\21\1\0\1\21\1\0" - + "\1\21\1\0\3\21\1\0\1\21\1\0\1\21\5\0" - + "\4\21\1\122\3\0\13\21\1\123\1\0\1\21\1\0" - + "\1\122\1\0\3\21\1\0\1\21\1\0\1\122\5\0" - + "\4\21\1\117\3\0\13\21\1\117\1\0\1\21\1\0" - + "\1\117\1\0\3\21\1\0\1\21\1\0\1\117\5\0" - + "\4\21\1\122\3\0\13\21\1\122\1\0\1\21\1\0" - + "\1\122\1\0\3\21\1\0\1\21\1\0\1\122"; + + "\5\21\3\0\14\21\2\0\1\21\1\0\1\21\1\0" + + "\1\72\2\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\11\21\1\73\2\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\6\21\1\74\5\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\6\21\1\75\5\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\11\0\1\63" + + "\16\0\1\63\4\0\1\63\7\0\1\63\5\0\5\21" + + "\3\0\10\21\1\76\3\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\11\0\1\67" + + "\16\0\1\67\4\0\1\67\7\0\1\67\5\0\5\21" + + "\3\0\3\21\1\77\10\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\12\21\1\100\1\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\3\21\1\101\10\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\7\21\1\102\4\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\6\21\1\103\5\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\7\21\1\104\4\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\7\21\1\105\4\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\4\21\1\106\7\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\3\21\1\107\10\21\2\0\1\21\1\0\1\21" + + "\1\0\3\21\1\0\1\21\1\0\1\21\5\0\5\21" + + "\3\0\1\110\13\21\2\0\1\21\1\0\1\21\1\0" + + "\3\21\1\0\1\21\1\0\1\21\5\0\5\21\3\0" + + "\1\111\13\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\12\21" + + "\1\112\1\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\5\21" + + "\1\113\6\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\3\21" + + "\1\114\10\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\10\21" + + "\1\115\3\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\10\21" + + "\1\116\3\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\1\21" + + "\1\117\12\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\3\21" + + "\1\120\10\21\2\0\1\21\1\0\1\21\1\0\3\21" + + "\1\0\1\21\1\0\1\21\5\0\5\21\3\0\1\121" + + "\13\21\2\0\1\21\1\0\1\21\1\0\3\21\1\0" + + "\1\21\1\0\1\21\5\0\4\21\1\122\3\0\13\21" + + "\1\123\2\0\1\21\1\0\1\122\1\0\3\21\1\0" + + "\1\21\1\0\1\122\5\0\5\21\3\0\11\21\1\124" + + "\2\21\2\0\1\21\1\0\1\21\1\0\3\21\1\0" + + "\1\21\1\0\1\21\5\0\4\21\1\125\3\0\13\21" + + "\1\126\2\0\1\21\1\0\1\125\1\0\3\21\1\0" + + "\1\21\1\0\1\125\5\0\4\21\1\122\3\0\13\21" + + "\1\122\2\0\1\21\1\0\1\122\1\0\3\21\1\0" + + "\1\21\1\0\1\122\5\0\4\21\1\125\3\0\13\21" + + "\1\125\2\0\1\21\1\0\1\125\1\0\3\21\1\0" + + "\1\21\1\0\1\125"; private static int[] zzUnpackTrans() { - int[] result = new int[2109]; + int[] result = new int[2242]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -354,11 +345,12 @@ public final class FlasmLexer { private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = "\3\0\1\11\3\1\1\11\2\1\1\11\1\1\1\11" - + "\1\1\1\11\3\1\1\11\10\1\1\11\1\0\6\11" - + "\2\1\4\11\1\0\10\1\1\11\1\1\1\0\36\1"; + + "\1\1\1\11\3\1\1\11\11\1\1\11\1\0\6\11" + + "\2\1\4\11\1\0\10\1\1\11\1\1\1\11\1\1" + + "\1\0\36\1"; private static int[] zzUnpackAttribute() { - int[] result = new int[83]; + int[] result = new int[86]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/flasm.flex b/trunk/src/com/jpexs/decompiler/flash/action/parser/flasm.flex index a6c72896b..ab9646d05 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/flasm.flex +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/flasm.flex @@ -70,8 +70,11 @@ Undefined = "undefined" /* integer literals */ -NumberLiteral = 0 | [1-9][0-9]* - +PositiveNumberLiteral = 0 | [1-9][0-9]* +NegativeNumberLiteral = - {PositiveNumberLiteral} + +NumberLiteral = {PositiveNumberLiteral}|{NegativeNumberLiteral} + /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? @@ -85,8 +88,8 @@ OctDigit = [0-7] /* string and character literals */ StringCharacter = [^\r\n\"\\] -Register= register{NumberLiteral} -Constant= constant{NumberLiteral} +Register= register{PositiveNumberLiteral} +Constant= constant{PositiveNumberLiteral} %state STRING,PARAMETERS diff --git a/trunk/src/com/jpexs/decompiler/flash/action/special/ActionNop.java b/trunk/src/com/jpexs/decompiler/flash/action/special/ActionNop.java index 88b656b82..69d628440 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/special/ActionNop.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/special/ActionNop.java @@ -17,6 +17,8 @@ package com.jpexs.decompiler.flash.action.special; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -32,7 +34,7 @@ public class ActionNop extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { //output.add(new SimpleActionTreeItem(this, "nop();")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java index 32e828f37..5dd59ddec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.helpers.Helper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -68,7 +69,7 @@ public class ActionGetURL extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new GetURLTreeItem(this, urlString, targetString)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java index 98c47aea7..ff6d4dbd0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.helpers.Helper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -64,7 +65,7 @@ public class ActionGoToLabel extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new GotoLabelTreeItem(this, label)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java index eb17d2990..9fe72fc6f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.treemodel.GotoFrameTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -60,7 +61,7 @@ public class ActionGotoFrame extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new GotoFrameTreeItem(this, frame)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java index 377733ce1..ab2abf8f9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionNextFrame extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SimpleActionTreeItem(this, "nextFrame()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java index a829337a1..bf8498326 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionPlay extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SimpleActionTreeItem(this, "Play()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java index 8ee6d0332..2371211ef 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionPrevFrame extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SimpleActionTreeItem(this, "prevFrame()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java index b5f3ce190..fc44219d6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.helpers.Helper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -64,7 +65,7 @@ public class ActionSetTarget extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SetTargetTreeItem(this, targetName)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java index cb1c827c5..4a1a83edd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStop extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SimpleActionTreeItem(this, "stop()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java index f15208f49..0fd44aec7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStopSounds extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SimpleActionTreeItem(this, "stopAllSounds()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java index 18cbd51ac..70f6d5b85 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionToggleQuality extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SimpleActionTreeItem(this, "toggleHighQuality()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java index 98270882c..f5bf3e1a1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.treemodel.WaitForFrameTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -64,7 +65,7 @@ public class ActionWaitForFrame extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new WaitForFrameTreeItem(this, frame, skipCount)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java index d4505e146..4a15c1428 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.AddTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionAdd extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new AddTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java index 286f702b9..14fbbb8c1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.AndTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionAnd extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new AndTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java index 13eb60d67..775223446 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.AsciiToCharTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionAsciiToChar extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new AsciiToCharTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java index c3cb2b06a..f51087f90 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.CallTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionCall extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new CallTreeItem(this, stack.pop())); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java index 93426ed9a..f357807c5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.CharToAsciiTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionCharToAscii extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new CharToAsciiTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java index 14f41eda1..184567c96 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.CloneSpriteTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionCloneSprite extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem depth = stack.pop(); GraphTargetItem target = stack.pop(); GraphTargetItem source = stack.pop(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java index 3ee80c3f1..b05f24ac8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.DivideTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionDivide extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new DivideTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java index a2a0ae4a8..b613ab529 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionEndDrag extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { output.add(new SimpleActionTreeItem(this, "stopDrag()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java index 610f3aa6e..c6e05942b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.EqTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionEquals extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new EqTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java index b4be61fa2..07b32f950 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem; import com.jpexs.decompiler.flash.action.treemodel.GetPropertyTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionGetProperty extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem index = stack.pop(); GraphTargetItem target = stack.pop(); int indexInt = 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java index 6c0711523..d1cfe548b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionGetTime extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { stack.push(new SimpleActionTreeItem(this, "getTimer()")); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java index d81918ba1..0ffd84e9f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.treemodel.GetURL2TreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -72,7 +73,7 @@ public class ActionGetURL2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem targetString = stack.pop(); GraphTargetItem urlString = stack.pop(); output.add(new GetURL2TreeItem(this, urlString, targetString, sendVarsMethod, loadTargetFlag, loadTargetFlag)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java index 380d940ca..8752ffc3c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java @@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.GetVariableTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.helpers.Highlighting; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,8 +36,11 @@ public class ActionGetVariable extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { - GraphTargetItem value = stack.pop(); - stack.push(new GetVariableTreeItem(this, value)); + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { + GraphTargetItem name = stack.pop(); + GraphTargetItem computedVal = variables.get(Highlighting.stripHilights(name.toStringNoQuotes())); + GetVariableTreeItem gvt = new GetVariableTreeItem(this, name); + gvt.computedValue = computedVal; + stack.push(gvt); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java index fdcfde588..821c1a0f1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.treemodel.GotoFrame2TreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -76,7 +77,7 @@ public class ActionGotoFrame2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem frame = stack.pop(); output.add(new GotoFrame2TreeItem(this, frame, sceneBiasFlag, playFlag, sceneBias)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java index 893093c49..f954a4cae 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java @@ -33,6 +33,7 @@ public class ActionIf extends Action { public int offset; public String identifier; + public boolean compileTime; public ActionIf(SWFInputStream sis) throws IOException { super(0x9D, 2); @@ -64,7 +65,7 @@ public class ActionIf extends Action { @Override public String getASMSource(List knownAddreses, List constantPool, int version) { - return "If loc" + Helper.formatAddress(getAddress() + getBytes(version).length + offset); + return "If loc" + Helper.formatAddress(getAddress() + getBytes(version).length + offset) + (compileTime ? " ;compileTime" : ""); } public ActionIf(FlasmLexer lexer) throws IOException, ParseException { @@ -96,4 +97,9 @@ public class ActionIf extends Action { ret.add(code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length)); return ret; } + + @Override + public boolean ignoredLoops() { + return compileTime; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java index de9cb979e..7bfea691c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java @@ -86,7 +86,7 @@ public class ActionJump extends Action { @Override public String toString() { - return "Jump"; + return "Jump " + offset; } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java index bfc2796b7..9e67496d3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.LtTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionLess extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new LtTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java index 8705c4e01..fbeb3a46f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.MBAsciiToCharTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionMBAsciiToChar extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new MBAsciiToCharTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java index e38cb9444..4ca1c627d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.MBCharToAsciiTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionMBCharToAscii extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new MBCharToAsciiTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java index f819fac74..28268d882 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.MBStringExtractTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionMBStringExtract extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem count = stack.pop(); GraphTargetItem index = stack.pop(); GraphTargetItem value = stack.pop(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java index b95e73882..8b7f66157 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.MBStringLengthTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionMBStringLength extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new MBStringLengthTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java index a9b3b60e7..5b5e8db3a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.MultiplyTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionMultiply extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new MultiplyTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java index 702f13c18..ffc9e66cc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.NotTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionNot extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new NotTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java index 0642f27c4..24977b002 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.OrTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionOr extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new OrTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java index b487527f7..696b4b084 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.CallFunctionTreeItem; import com.jpexs.decompiler.flash.action.treemodel.CallMethodTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionPop extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { if (stack.isEmpty()) { return; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 633ffaf53..56a555005 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -29,6 +29,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -61,13 +62,20 @@ public class ActionPush extends Action { values.add(new RegisterNumber(sis.readUI8())); break; case 5: - values.add((Boolean) (sis.readUI8() == 1)); + int b = sis.readUI8(); + if (b == 0) { + values.add((Boolean) false); + } else { + values.add((Boolean) true); + } + break; case 6: values.add(sis.readDOUBLE()); break; case 7: - values.add((Long) sis.readUI32()); + long el = sis.readSI32(); + values.add((Long) el); break; case 8: values.add(new ConstantIndex(sis.readUI8())); @@ -113,7 +121,7 @@ public class ActionPush extends Action { } if (o instanceof Long) { sos.writeUI8(7); - sos.writeUI32((Long) o); + sos.writeSI32((Long) o); } if (o instanceof ConstantIndex) { int cIndex = ((ConstantIndex) o).index; @@ -191,19 +199,20 @@ public class ActionPush extends Action { ret += ((ConstantIndex) values.get(i)).toString(); } else if (values.get(i) instanceof String) { ret += "\"" + Helper.escapeString((String) values.get(i)) + "\""; - } else if (values.get(i) instanceof Long) { - long l = (Long) values.get(i); - l = l & 0xffffffffL; - ret += l; + } else if (values.get(i) instanceof RegisterNumber) { + ret += ((RegisterNumber) values.get(i)).toStringNoName(); } else { ret += values.get(i).toString(); } } + if (ret.equals("Push 138")) { + new Exception().printStackTrace(); + } return ret; } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { int pos = 0; for (Object o : values) { if (o instanceof ConstantIndex) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java index e4cac4669..3e7c00fe6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.RandomNumberTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionRandomNumber extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem maximum = stack.pop(); stack.push(new RandomNumberTreeItem(this, maximum)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java index 963096c45..955ac6963 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.RemoveSpriteTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionRemoveSprite extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem target = stack.pop(); output.add(new RemoveSpriteTreeItem(this, target)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java index 43ef22c60..2df608982 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem; import com.jpexs.decompiler.flash.action.treemodel.SetPropertyTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionSetProperty extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem value = stack.pop(); GraphTargetItem index = stack.pop(); GraphTargetItem target = stack.pop(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java index 9401d7d9f..f4fee04d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SetTarget2TreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionSetTarget2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem target = stack.pop(); output.add(new SetTarget2TreeItem(this, target)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java index e2bc02e64..fa8bdbffb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java @@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SetVariableTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.helpers.Highlighting; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,9 +36,11 @@ public class ActionSetVariable extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem value = stack.pop(); GraphTargetItem name = stack.pop(); - output.add(new SetVariableTreeItem(this, name, value)); + SetVariableTreeItem svt = new SetVariableTreeItem(this, name, value); + variables.put(Highlighting.stripHilights(name.toStringNoQuotes(regNames, variables)), value); + output.add(svt); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java index 02f614dec..5e5e8b523 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem; import com.jpexs.decompiler.flash.action.treemodel.StartDragTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionStartDrag extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem target = stack.pop(); GraphTargetItem lockCenter = stack.pop(); GraphTargetItem constrain = stack.pop(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java index 6c7bcd50a..4d7b8cd36 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.StringAddTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStringAdd extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringAddTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java index 7e4678aa6..c10734507 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.StringEqTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStringEquals extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringEqTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java index 131dc2b84..164466b71 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.StringExtractTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStringExtract extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem count = stack.pop(); GraphTargetItem index = stack.pop(); GraphTargetItem value = stack.pop(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java index 208b7ecc9..bf2488f57 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.StringLengthTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStringLength extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new StringLengthTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java index b0e9b92cf..a3689698e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.StringLtTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStringLess extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringLtTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java index 91ed96047..9a0548d9c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.SubtractTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionSubtract extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new SubtractTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java index ef1212f35..1b0ec7a34 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ToIntegerTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionToInteger extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new ToIntegerTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java index 3bee84b1e..f6ff8dd99 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.TraceTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionTrace extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem value = stack.pop(); output.add(new TraceTreeItem(this, value)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index c6d395f6c..8b8503ac7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.treemodel.WaitForFrame2TreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -60,7 +61,7 @@ public class ActionWaitForFrame2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem frame = stack.pop(); output.add(new WaitForFrame2TreeItem(this, frame, skipCount)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java index 753463202..41b90d429 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java @@ -28,8 +28,12 @@ public class RegisterNumber { @Override public String toString() { if (name == null || name.trim().equals("")) { - return "register" + number; + return toStringNoName(); } return name; } + + public String toStringNoName() { + return "register" + number; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java index b4adc29e2..6e8b8339e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.AddTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionAdd2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new AddTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java index de5cabc69..a2cc55cb2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.BitAndTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionBitAnd extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new BitAndTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java index 83737cb4d..33efeb90f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.LShiftTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionBitLShift extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new LShiftTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java index 1dc463a4a..371b83176 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.BitOrTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionBitOr extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new BitOrTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java index fd73ec663..cc5601c7f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.RShiftTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionBitRShift extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new RShiftTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java index 4a49a9140..74a8d877b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.URShiftTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionBitURShift extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new URShiftTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java index 6069b5779..2c9defece 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.BitXorTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionBitXor extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new BitXorTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java index d1df16a9a..476b26312 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java @@ -19,7 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.CallFunctionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.helpers.Highlighting; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,13 +37,15 @@ public class ActionCallFunction extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem functionName = stack.pop(); long numArgs = popLong(stack); List args = new ArrayList(); for (long l = 0; l < numArgs; l++) { args.add(stack.pop()); } - stack.push(new CallFunctionTreeItem(this, functionName, args)); + CallFunctionTreeItem cft = new CallFunctionTreeItem(this, functionName, args); + cft.calculatedFunction = functions.get(Highlighting.stripHilights(functionName.toStringNoQuotes(variables, functions))); + stack.push(cft); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java index 829cc3b98..9d4cdd4fe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.CallMethodTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionCallMethod extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem methodName = stack.pop(); GraphTargetItem scriptObject = stack.pop(); long numArgs = popLong(stack); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java index b81b5e8e1..6c255abcf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java @@ -28,6 +28,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -85,6 +86,6 @@ public class ActionConstantPool extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java index 1a38a59f7..29f0e6715 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.DecrementTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionDecrement extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new DecrementTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index 73e2c3f87..c904f5853 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.ActionGraph; import com.jpexs.decompiler.flash.action.parser.ASMParser; import com.jpexs.decompiler.flash.action.parser.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.Label; @@ -153,8 +154,10 @@ public class ActionDefineFunction extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames) { - stack.push(new FunctionTreeItem(this, functionName, paramNames, Action.actionsToTree(regNames, code, version), constantPool, 1)); + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + FunctionTreeItem fti = new FunctionTreeItem(this, functionName, paramNames, ActionGraph.translateViaGraph(regNames, variables, functions, code, version), constantPool, 1); + stack.push(fti); + functions.put(functionName, fti); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java index f75c1e86b..bc3fbc2bb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java @@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.DefineLocalTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.helpers.Highlighting; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,9 +36,10 @@ public class ActionDefineLocal extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem value = stack.pop(); GraphTargetItem name = stack.pop(); + variables.put(Highlighting.stripHilights(name.toStringNoQuotes(regNames, variables, functions)), value); output.add(new DefineLocalTreeItem(this, name, value)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java index d89af087f..4e33cb8ee 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.DefineLocalTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionDefineLocal2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem name = stack.pop(); output.add(new DefineLocalTreeItem(this, name, null)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java index 7c67d395e..43c480258 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.action.treemodel.DeleteTreeItem; import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -36,7 +37,7 @@ public class ActionDelete extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem propertyName = stack.pop(); GraphTargetItem object = stack.pop(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java index be549581a..b16bc3048 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.action.treemodel.DeleteTreeItem; import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -36,7 +37,7 @@ public class ActionDelete2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem propertyName = stack.pop(); output.add(new DeleteTreeItem(this, null, propertyName)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java index 319370f91..1a575516d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.EnumerateTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionEnumerate extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); stack.push(new EnumerateTreeItem(this, object)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java index 6d3b9d067..b18cf3b89 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.EqTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionEquals2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new EqTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java index a0c16400e..273a4758e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.GetMemberTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionGetMember extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem functionName = stack.pop(); GraphTargetItem object = stack.pop(); stack.push(new GetMemberTreeItem(this, object, functionName)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java index ff63ef001..a752219ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.IncrementTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionIncrement extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); stack.push(new IncrementTreeItem(this, a)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java index 02afbe508..d6259df05 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.InitArrayTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -30,7 +31,7 @@ public class ActionInitArray extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { long numArgs = popLong(stack); List args = new ArrayList(); for (int l = 0; l < numArgs; l++) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java index 87f03c8d7..530cd4ba0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.InitObjectTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionInitObject extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { long numArgs = popLong(stack); List values = new ArrayList(); List names = new ArrayList(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java index b73170857..320989d6f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.LtTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionLess2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new LtTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java index ea5a603ef..1f046f612 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.ModuloTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionModulo extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new ModuloTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java index b604e96c6..b393aeb2a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.NewMethodTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionNewMethod extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem methodName = stack.pop(); GraphTargetItem scriptObject = stack.pop(); long numArgs = popLong(stack); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java index 88726b254..1269f00c5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.NewObjectTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionNewObject extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem objectName = stack.pop(); long numArgs = popLong(stack); List args = new ArrayList(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java index 662fc7491..907b59313 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.graph.GraphSourceItemPos; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionPushDuplicate extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem value = stack.pop(); stack.push(value); stack.push(value); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java index 74b791467..b5fc7a80e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ReturnTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionReturn extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem value = stack.pop(); output.add(new ReturnTreeItem(this, value)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java index eeec2e98e..3b3b35b9c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.SetMemberTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionSetMember extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem value = stack.pop(); GraphTargetItem objectName = stack.pop(); GraphTargetItem object = stack.pop(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java index 27695e36b..a3005ab30 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -33,7 +34,7 @@ public class ActionStackSwap extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(a); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index d5f01689e..691adbb4f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.action.treemodel.StoreRegisterTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -61,7 +62,7 @@ public class ActionStoreRegister extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem item = stack.peek(); RegisterNumber rn = new RegisterNumber(registerNumber); if (regNames.containsKey(registerNumber)) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java index d2b2e02e4..68b19f80b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.TargetPathTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionTargetPath extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); stack.push(new TargetPathTreeItem(this, object)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java index 31941add3..23230a451 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ToNumberTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionToNumber extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); stack.push(new ToNumberTreeItem(this, object)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java index dcdcbf617..69f01b72c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ToStringTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionToString extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); stack.push(new ToStringTreeItem(this, object)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java index a7d702039..d4cf37df5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.TypeOfTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionTypeOf extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); stack.push(new TypeOfTreeItem(this, object)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java index 68aee4599..3e0a5f7fb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.EnumerateTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionEnumerate2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); stack.push(new EnumerateTreeItem(this, object)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java index 723d8deee..b54cacdaf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.GtTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionGreater extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new GtTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java index 0dfc70cba..8ce9dc1e7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.InstanceOfTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionInstanceOf extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new InstanceOfTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java index 077b015cd..7831d95ba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.StrictEqTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStrictEquals extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StrictEqTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java index 04b44f0a3..8a24ba247 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.operations.GtTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionStringGreater extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new GtTreeItem(this, b, a)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java index 168f9e43a..8003b32d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.CastOpTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionCastOp extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); GraphTargetItem constructor = stack.pop(); stack.push(new CastOpTreeItem(this, constructor, object)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index f59ec8d40..e6ab3d887 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.ActionGraph; import com.jpexs.decompiler.flash.action.parser.ASMParser; import com.jpexs.decompiler.flash.action.parser.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.Label; @@ -238,8 +239,44 @@ public class ActionDefineFunction2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames) { - stack.push(new FunctionTreeItem(this, functionName, paramNames, Action.actionsToTree(regNames, code, version), constantPool, getFirstRegister())); + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + + HashMap funcRegNames = (HashMap) regNames.clone(); + for (int f = 0; f < paramNames.size(); f++) { + int reg = paramRegisters.get(f); + if (reg != 0) { + funcRegNames.put(reg, paramNames.get(f)); + } + } + int pos = 1; + if (preloadThisFlag) { + funcRegNames.put(pos, "this"); + pos++; + } + if (preloadArgumentsFlag) { + funcRegNames.put(pos, "arguments"); + pos++; + } + if (preloadSuperFlag) { + funcRegNames.put(pos, "super"); + pos++; + } + if (preloadRootFlag) { + funcRegNames.put(pos, "_root"); + pos++; + } + if (preloadParentFlag) { + funcRegNames.put(pos, "_parent"); + pos++; + } + if (preloadGlobalFlag) { + funcRegNames.put(pos, "_global"); + pos++; + } + + FunctionTreeItem fti = new FunctionTreeItem(this, functionName, paramNames, ActionGraph.translateViaGraph(funcRegNames, variables, functions, code, version), constantPool, getFirstRegister()); + functions.put(functionName, fti); + stack.push(fti); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java index deba93690..bfaf9ae31 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ExtendsTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionExtends extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem superclass = stack.pop(); GraphTargetItem subclass = stack.pop(); output.add(new ExtendsTreeItem(this, subclass, superclass)); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java index 513b9fd28..74596cd99 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ImplementsOpTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -35,7 +36,7 @@ public class ActionImplementsOp extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem subclass = stack.pop(); long inCount = popLong(stack); List superclasses = new ArrayList(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java index 9d2613727..91934c2e3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ThrowTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -34,7 +35,7 @@ public class ActionThrow extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames) { + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { GraphTargetItem object = stack.pop(); output.add(new ThrowTreeItem(this, object)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CallFunctionTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CallFunctionTreeItem.java index 2a7ac7324..0b0ef8af6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CallFunctionTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CallFunctionTreeItem.java @@ -24,6 +24,7 @@ public class CallFunctionTreeItem extends TreeItem { public GraphTargetItem functionName; public List arguments; + public GraphTargetItem calculatedFunction; public CallFunctionTreeItem(GraphSourceItem instruction, GraphTargetItem functionName, List arguments) { super(instruction, PRECEDENCE_PRIMARY); @@ -52,4 +53,28 @@ public class CallFunctionTreeItem extends TreeItem { } return ret; } + + @Override + public boolean isCompileTime() { + if (calculatedFunction == null) { + return false; + } + return calculatedFunction.isCompileTime(); + } + + @Override + public boolean toBoolean() { + if (calculatedFunction == null) { + return false; + } + return calculatedFunction.toBoolean(); + } + + @Override + public double toNumber() { + if (calculatedFunction == null) { + return 0; + } + return calculatedFunction.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java index af406068d..99d1a7b0a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java @@ -30,7 +30,7 @@ public class DirectValueTreeItem extends TreeItem { super(instruction, PRECEDENCE_PRIMARY); this.constants = constants; this.value = value; - this.instructionPos = instructionPos; + this.pos = instructionPos; } @Override @@ -44,6 +44,9 @@ public class DirectValueTreeItem extends TreeItem { if (value instanceof Long) { return (Long) value; } + if (value instanceof Boolean) { + return ((Boolean) value) ? 1 : 0; + } return super.toNumber(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/FunctionTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/FunctionTreeItem.java index 68b3876c8..b6b3785b5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/FunctionTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/FunctionTreeItem.java @@ -41,6 +41,9 @@ public class FunctionTreeItem extends TreeItem { @Override public String toString(ConstantPool constants) { + if (true) { + //return ""; + } String ret = hilight("function"); if (calculatedFunctionName != null) { ret += " " + calculatedFunctionName.toStringNoQuotes(constants); @@ -75,4 +78,36 @@ public class FunctionTreeItem extends TreeItem { public boolean needsSemicolon() { return false; } + + @Override + public boolean isCompileTime() { + for (GraphTargetItem a : actions) { + if (!a.isCompileTime()) { + return false; + } + } + return true; + } + + @Override + public boolean toBoolean() { + if (!actions.isEmpty()) { + if (actions.get(actions.size() - 1) instanceof ReturnTreeItem) { + ReturnTreeItem r = (ReturnTreeItem) actions.get(actions.size() - 1); + return r.value.toBoolean(); + } + } + return false; + } + + @Override + public double toNumber() { + if (!actions.isEmpty()) { + if (actions.get(actions.size() - 1) instanceof ReturnTreeItem) { + ReturnTreeItem r = (ReturnTreeItem) actions.get(actions.size() - 1); + return r.value.toNumber(); + } + } + return 0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/GetVariableTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/GetVariableTreeItem.java index de8c5813f..4b053561c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/GetVariableTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/GetVariableTreeItem.java @@ -22,22 +22,53 @@ import java.util.List; public class GetVariableTreeItem extends TreeItem { - public GraphTargetItem value; + public GraphTargetItem name; + public GraphTargetItem computedValue; public GetVariableTreeItem(GraphSourceItem instruction, GraphTargetItem value) { super(instruction, PRECEDENCE_PRIMARY); - this.value = value; + this.name = value; } @Override public String toString(ConstantPool constants) { - return stripQuotes(value); + //return ""+computedValue.toNumber(); + return stripQuotes(name); } @Override public List getNeededSources() { List ret = super.getNeededSources(); - ret.addAll(value.getNeededSources()); + ret.addAll(name.getNeededSources()); return ret; } + + @Override + public boolean isVariableComputed() { + return true; + } + + @Override + public boolean isCompileTime() { + if (computedValue == null) { + return false; + } + return computedValue.isCompileTime(); + } + + @Override + public boolean toBoolean() { + if (computedValue == null) { + return false; + } + return computedValue.toBoolean(); + } + + @Override + public double toNumber() { + if (computedValue == null) { + return 0; + } + return computedValue.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java index eac3d11f7..6a9d60611 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java @@ -40,4 +40,9 @@ public class ReturnTreeItem extends TreeItem { ret.addAll(value.getNeededSources()); return ret; } + + @Override + public boolean isCompileTime() { + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java index 5a00acad9..ea30b5903 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java @@ -48,4 +48,9 @@ public class SetVariableTreeItem extends TreeItem implements SetTypeTreeItem { ret.addAll(value.getNeededSources()); return ret; } + + @Override + public boolean isCompileTime() { + return value.isCompileTime(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/TreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/TreeItem.java index e9acfb80f..e8c9bb1f7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/TreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/TreeItem.java @@ -17,16 +17,11 @@ package com.jpexs.decompiler.flash.action.treemodel; import com.jpexs.decompiler.flash.graph.GraphSourceItem; -import com.jpexs.decompiler.flash.graph.GraphSourceItemPos; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -import java.util.ArrayList; import java.util.List; public abstract class TreeItem extends GraphTargetItem { - public int instructionPos = 0; - public List moreInstructions = new ArrayList(); - public TreeItem(GraphSourceItem instruction, int precedence) { super(instruction, precedence); } @@ -64,11 +59,6 @@ public abstract class TreeItem extends GraphTargetItem { } } - @Override - public List getNeededSources() { - return getNeededSources(); - } - @Override public String toString(List localData) { if (localData.isEmpty()) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/UnaryOpTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/UnaryOpTreeItem.java index a255f6dbf..5cce9f0f0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/UnaryOpTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/UnaryOpTreeItem.java @@ -48,6 +48,11 @@ public abstract class UnaryOpTreeItem extends TreeItem { return value.isCompileTime(); } + @Override + public boolean isVariableComputed() { + return value.isVariableComputed(); + } + @Override public List getNeededSources() { List ret = super.getNeededSources(); diff --git a/trunk/src/com/jpexs/decompiler/flash/flv/AUDIODATA.java b/trunk/src/com/jpexs/decompiler/flash/flv/AUDIODATA.java index 1d20a2d66..2727fe6b1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/flv/AUDIODATA.java +++ b/trunk/src/com/jpexs/decompiler/flash/flv/AUDIODATA.java @@ -7,27 +7,24 @@ import java.io.IOException; * * @author JPEXS */ -public class AUDIODATA extends DATA{ - public static final int SOUNDFORMAT_UNCOMPRESSED_NE=0; - public static final int SOUNDFORMAT_ADPCM=1; - public static final int SOUNDFORMAT_MP3=2; - public static final int SOUNDFORMAT_UNCOMPRESSED_LE=3; - public static final int SOUNDFORMAT_NELLYMOSER_16=4; - public static final int SOUNDFORMAT_NELLYMOSER_8=5; - public static final int SOUNDFORMAT_NELLYMOSER=6; - public static final int SOUNDFORMAT_SPEEX=11; - - public static final int SOUNDRATE_5K5=0; - public static final int SOUNDRATE_11K=1; - public static final int SOUNDRATE_22K=2; - public static final int SOUNDRATE_44K=3; - - public static final int SOUNDSIZE_8BIT=0; - public static final int SOUNDSIZE_16BIT=1; - - public static final int SOUNDTYPE_MONO=0; - public static final int SOUNDTYPE_STEREO=1; - +public class AUDIODATA extends DATA { + + public static final int SOUNDFORMAT_UNCOMPRESSED_NE = 0; + public static final int SOUNDFORMAT_ADPCM = 1; + public static final int SOUNDFORMAT_MP3 = 2; + public static final int SOUNDFORMAT_UNCOMPRESSED_LE = 3; + public static final int SOUNDFORMAT_NELLYMOSER_16 = 4; + public static final int SOUNDFORMAT_NELLYMOSER_8 = 5; + public static final int SOUNDFORMAT_NELLYMOSER = 6; + public static final int SOUNDFORMAT_SPEEX = 11; + public static final int SOUNDRATE_5K5 = 0; + public static final int SOUNDRATE_11K = 1; + public static final int SOUNDRATE_22K = 2; + public static final int SOUNDRATE_44K = 3; + public static final int SOUNDSIZE_8BIT = 0; + public static final int SOUNDSIZE_16BIT = 1; + public static final int SOUNDTYPE_MONO = 0; + public static final int SOUNDTYPE_STEREO = 1; public int soundFormat; public int soundRate; public int soundSize; @@ -42,19 +39,17 @@ public class AUDIODATA extends DATA{ this.soundData = soundData; } - - @Override public byte[] getBytes() { - ByteArrayOutputStream baos=new ByteArrayOutputStream(); - try{ - FLVOutputStream flv=new FLVOutputStream(baos); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + FLVOutputStream flv = new FLVOutputStream(baos); flv.writeUB(4, soundFormat); flv.writeUB(2, soundRate); flv.writeUB(1, soundSize); flv.writeUB(1, soundType); flv.write(soundData); - }catch(IOException ex){ + } catch (IOException ex) { //ignore } return baos.toByteArray(); diff --git a/trunk/src/com/jpexs/decompiler/flash/flv/DATA.java b/trunk/src/com/jpexs/decompiler/flash/flv/DATA.java index 891fd050e..2d6cebd1d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/flv/DATA.java +++ b/trunk/src/com/jpexs/decompiler/flash/flv/DATA.java @@ -1,4 +1,3 @@ - package com.jpexs.decompiler.flash.flv; /** @@ -6,5 +5,6 @@ package com.jpexs.decompiler.flash.flv; * @author JPEXS */ public abstract class DATA { + public abstract byte[] getBytes(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java index 4e97c7331..8d6b4c25b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java @@ -114,24 +114,24 @@ public class FLVOutputStream extends OutputStream { write("FLV".getBytes()); write(1); //version writeUB(5, 0); //must be 0 - writeUB(1, audio?1:0); //audio present + writeUB(1, audio ? 1 : 0); //audio present writeUB(1, 0); //reserved - writeUB(1, video?1:0); //video present + writeUB(1, video ? 1 : 0); //video present writeUI32(9); //header size writeUI32(0); } - + public void writeTag(FLVTAG tag) throws IOException { - long posBefore=getPos(); + long posBefore = getPos(); writeUI8(tag.tagType); - byte data[]=tag.data.getBytes(); + byte data[] = tag.data.getBytes(); writeUI24(data.length); - writeUI24(tag.timeStamp&0xffffff); - writeUI8((int)((tag.timeStamp>>24) & 0xff)); + writeUI24(tag.timeStamp & 0xffffff); + writeUI8((int) ((tag.timeStamp >> 24) & 0xff)); writeUI24(0); write(data); - long posAfter=getPos(); - long size=posAfter-posBefore; + long posAfter = getPos(); + long size = posAfter - posBefore; writeUI32(size); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/flv/FLVTAG.java b/trunk/src/com/jpexs/decompiler/flash/flv/FLVTAG.java index a3b4bc05d..6555b27cc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/flv/FLVTAG.java +++ b/trunk/src/com/jpexs/decompiler/flash/flv/FLVTAG.java @@ -5,23 +5,23 @@ package com.jpexs.decompiler.flash.flv; * @author JPEXS */ public class FLVTAG { + public int tagType; public long timeStamp; public DATA data; - - public static final int DATATYPE_VIDEO=9; - public static final int DATATYPE_AUDIO=8; - public static final int DATATYPE_SCRIPT_DATA=18; + public static final int DATATYPE_VIDEO = 9; + public static final int DATATYPE_AUDIO = 8; + public static final int DATATYPE_SCRIPT_DATA = 18; public FLVTAG(long timeStamp, VIDEODATA data) { this.tagType = DATATYPE_VIDEO; this.timeStamp = timeStamp; this.data = data; } - - public FLVTAG(long timeStamp, AUDIODATA data) { + + public FLVTAG(long timeStamp, AUDIODATA data) { this.tagType = DATATYPE_AUDIO; this.timeStamp = timeStamp; this.data = data; - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/flv/VIDEODATA.java b/trunk/src/com/jpexs/decompiler/flash/flv/VIDEODATA.java index 9c24850da..301c5c26d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/flv/VIDEODATA.java +++ b/trunk/src/com/jpexs/decompiler/flash/flv/VIDEODATA.java @@ -7,7 +7,8 @@ import java.io.IOException; * * @author JPEXS */ -public class VIDEODATA extends DATA{ +public class VIDEODATA extends DATA { + public int frameType; public int codecId; public byte[] videoData; @@ -18,17 +19,15 @@ public class VIDEODATA extends DATA{ this.videoData = videoData; } - - @Override public byte[] getBytes() { - ByteArrayOutputStream baos=new ByteArrayOutputStream(); - try{ - FLVOutputStream flv=new FLVOutputStream(baos); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + FLVOutputStream flv = new FLVOutputStream(baos); flv.writeUB(4, frameType); flv.writeUB(4, codecId); flv.write(videoData); - }catch(IOException ex){ + } catch (IOException ex) { //ignore } return baos.toByteArray(); diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java index e3f01b8b8..ef3cc5c93 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java @@ -55,4 +55,14 @@ public abstract class BinaryOpItem extends GraphTargetItem { ret.addAll(rightSide.getNeededSources()); return ret; } + + @Override + public boolean isCompileTime() { + return leftSide.isCompileTime() && rightSide.isCompileTime(); + } + + @Override + public boolean isVariableComputed() { + return leftSide.isVariableComputed() || rightSide.isVariableComputed(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java index 8f91c90d9..0238eb231 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.graph; +import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem; import com.jpexs.decompiler.flash.helpers.Highlighting; import java.util.ArrayList; import java.util.HashMap; @@ -84,7 +85,7 @@ public class Graph { if (r.path.startsWith("e") && !part.path.startsWith("e")) { continue; } - if (part.leadsTo(r, new ArrayList())) { + if (part.leadsTo(code, r, new ArrayList())) { //modify=false; //continue; } @@ -352,7 +353,7 @@ public class Graph { return false; } - protected List check(List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { + protected List check(GraphSource code, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { return null; } @@ -432,11 +433,34 @@ public class Graph { end--; }*/ - output.addAll(code.translatePart(localData, stack, start, end)); - + try { + output.addAll(code.translatePart(localData, stack, start, end)); + } catch (Exception ex) { + //ex.printStackTrace(); + return ret; + } + } + if (part.nextParts.size() == 2) { + if (!stack.isEmpty()) { + GraphTargetItem top = stack.peek(); + if (false) { //top.isCompileTime()){ + stack.pop(); + if (top.toBoolean()) { + ret.addAll(output); + ret.addAll(printGraph(localData, stack, allParts, parent, part.nextParts.get(0), stopPart, loops, forFinalCommands)); + return ret; + } else { + ret.addAll(output); + ret.addAll(printGraph(localData, stack, allParts, parent, part.nextParts.get(1), stopPart, loops, forFinalCommands)); + return ret; + } + } else { + } + } else { + //EMPTY STACK + } } if (part.nextParts.size() == 2) { - if ((stack.size() >= 2) && (stack.get(stack.size() - 1) instanceof NotItem) && (((NotItem) (stack.get(stack.size() - 1))).getOriginal() == stack.get(stack.size() - 2))) { ret.addAll(output); @@ -445,8 +469,8 @@ public class Graph { boolean reversed = false; List loopContinues = getLoopsContinues(loops); loopContinues.add(part); - if (sp1.leadsTo(sp0, loopContinues)) { - } else if (sp0.leadsTo(sp1, loopContinues)) { + if (sp1.leadsTo(code, sp0, loopContinues)) { + } else if (sp0.leadsTo(code, sp1, loopContinues)) { reversed = true; } GraphPart next = reversed ? sp0 : sp1; @@ -493,8 +517,8 @@ public class Graph { boolean reversed = false; List loopContinues = getLoopsContinues(loops); loopContinues.add(part); - if (sp1.leadsTo(sp0, loopContinues)) { - } else if (sp0.leadsTo(sp1, loopContinues)) { + if (sp1.leadsTo(code, sp0, loopContinues)) { + } else if (sp0.leadsTo(code, sp1, loopContinues)) { reversed = true; } GraphPart next = reversed ? sp0 : sp1; @@ -825,8 +849,12 @@ public class Graph { return ret; }*/ + if ((part.nextParts.size() == 1) && (!stack.isEmpty()) && (stack.peek() instanceof DirectValueTreeItem) && ((DirectValueTreeItem) stack.peek()).value instanceof Boolean) { + System.out.println("dd"); + } + List retChecked = null; - if ((retChecked = check(localData, allParts, stack, parent, part, stopPart, loops, output, forFinalCommands)) != null) { + if ((retChecked = check(code, localData, allParts, stack, parent, part, stopPart, loops, output, forFinalCommands)) != null) { ret.addAll(retChecked); return ret; } @@ -835,8 +863,8 @@ public class Graph { boolean reversed = false; boolean whileTrue = false; Loop whileTrueLoop = null; - if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(part, loopContinues)) { - if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { + if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(code, part, loopContinues)) { + if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(code, part, loopContinues)) { if (output.isEmpty()) { whileTrueLoop = new Loop(loops.size(), part, null); loops.add(whileTrueLoop); @@ -848,7 +876,7 @@ public class Graph { } else { loop = true; } - } else if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { + } else if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(code, part, loopContinues)) { loop = true; reversed = true; } @@ -1043,7 +1071,7 @@ public class Graph { ret.add(new ForInTreeItem(null, currentLoop.id, part.start, new InTreeItem(expr.instruction, obj, ((HasNextTreeItem) expr).collection), loopBody)); }*/ else { if (doWhile) { - if (stack.isEmpty()) { + if (stack.isEmpty() || (part.nextParts.size() == 1)) { expr = new TrueItem(null); } else { expr = stack.pop(); @@ -1074,7 +1102,11 @@ public class Graph { next = part.nextParts.get(reversed ? 0 : 1); } if (doWhile) { - next = null; + if (part.nextParts.size() == 1) { + next = part.nextParts.get(0); + } else { + next = null; + } } if (next != null) { GraphTargetItem ti = checkLoop(next, stopPart, loops); diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphPart.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphPart.java index b09f518f7..f9a2dfb16 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphPart.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphPart.java @@ -36,7 +36,7 @@ public class GraphPart { public boolean ignored = false; public List forContinues = new ArrayList(); - private boolean leadsTo(GraphPart part, List visited, List ignored) { + private boolean leadsTo(GraphSource code, GraphPart part, List visited, List ignored) { if (visited.contains(this)) { return false; } @@ -44,11 +44,14 @@ public class GraphPart { return false; } visited.add(this); + if (end < code.size() && code.get(end).isBranch() && (code.get(end).ignoredLoops())) { + return false; + } for (GraphPart p : nextParts) { if (p == part) { return true; } else { - if (p.leadsTo(part, visited, ignored)) { + if (p.leadsTo(code, part, visited, ignored)) { return true; } } @@ -56,9 +59,9 @@ public class GraphPart { return false; } - public boolean leadsTo(GraphPart part, List ignored) { + public boolean leadsTo(GraphSource code, GraphPart part, List ignored) { - return leadsTo(part, new ArrayList(), ignored); + return leadsTo(code, part, new ArrayList(), ignored); } public GraphPart(int start, int end) { diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java index fbbd1fb7e..e6ace7ab8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java @@ -19,5 +19,7 @@ public interface GraphSourceItem { public long getOffset(); + public boolean ignoredLoops(); + public List getBranches(GraphSource code); } diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java index 8505ebe13..f62ddd6d7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java @@ -1,6 +1,5 @@ package com.jpexs.decompiler.flash.graph; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import java.util.ArrayList; import java.util.List; @@ -91,6 +90,10 @@ public abstract class GraphTargetItem { return false; } + public boolean isVariableComputed() { + return false; + } + public double toNumber() { return 0; } @@ -103,8 +106,12 @@ public abstract class GraphTargetItem { return toString(localData); } - public String toStringNoQuotes(Object o) { - return toStringNoQuotes(Helper.toList(o)); + public String toStringNoQuotes(Object... localData) { + List localData2 = new ArrayList(); + for (Object o : localData) { + localData2.add(o); + } + return toStringNoQuotes(localData2); } public GraphTargetItem getNotCoerced() { diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java index 086e84ec9..cc3a595e0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java @@ -25,6 +25,11 @@ public class IfItem extends GraphTargetItem implements Block { public List onTrue; public List onFalse; + @Override + public boolean isCompileTime() { + return expression.isCompileTime(); + } + @Override public List> getSubs() { List> ret = new ArrayList>(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index 8401fe17b..49deb22a2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -21,7 +21,7 @@ public class ExportDialog extends JDialog { {"SVG"}, {"PNG/JPEG"}, {"FLV (No audio)"}, - {"MP3/FLV","FLV (Audio only)"}, + {"MP3/FLV", "FLV (Audio only)"}, {"AS", "PCODE"} }; String optionNames[] = { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java index 92ae83e43..02c5dd6be 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java @@ -242,9 +242,9 @@ public class GraphFrame extends JFrame { gp = new GraphPanel(graph); setTitle("Graph " + name); cnt.add(new JScrollPane(gp)); - + View.setWindowIcon(this); - + } @Override @@ -255,21 +255,19 @@ public class GraphFrame extends JFrame { Dimension dim = new Dimension(0, 0); Dimension panDim = gp.getPreferredSize(); if (panDim.width < screen.width) { - dim.width = panDim.width+10; + dim.width = panDim.width + 10; } else { dim.width = screen.width; } if (panDim.height < screen.height) { - dim.height = panDim.height+10; + dim.height = panDim.height + 10; } else { dim.height = screen.height; - } - setVisibleSize(dim); + } + setVisibleSize(dim); View.centerScreen(this); } - - private void setVisibleSize(Dimension dim) { Insets insets = this.getInsets(); setSize(new Dimension(insets.left + insets.right + dim.width, diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java b/trunk/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java index dffe9c375..40d3091d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java @@ -70,13 +70,13 @@ public class LoadingDialog extends JFrame implements ImageObserver { JPanel pan = new JPanel(); pan.setLayout(null); pan.setPreferredSize(new Dimension(120, 150)); - JLabel loadingLabel=new JLabel("Loading, please wait..."); + JLabel loadingLabel = new JLabel("Loading, please wait..."); loadingLabel.setBounds(0, 30, 125, 20); loadingLabel.setHorizontalAlignment(SwingConstants.CENTER); - detailLabel.setBounds(0, 45, 125,20); + detailLabel.setBounds(0, 45, 125, 20); progressBar.setBounds(0, 70, 125, 25); pan.add(loadingLabel); - pan.add(detailLabel); + pan.add(detailLabel); pan.add(progressBar); add(pan, BorderLayout.CENTER); progressBar.setVisible(false); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 5801cb78b..b0f07e376 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -60,8 +60,6 @@ import com.jpexs.decompiler.flash.tags.EndTag; import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; import com.jpexs.decompiler.flash.tags.PlaceObject2Tag; -import com.jpexs.decompiler.flash.tags.PlaceObject3Tag; -import com.jpexs.decompiler.flash.tags.PlaceObjectTag; import com.jpexs.decompiler.flash.tags.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; @@ -105,7 +103,6 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFileChooser; import javax.swing.JFrame; diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java index 97f223296..3495164a6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java @@ -18,10 +18,15 @@ package com.jpexs.decompiler.flash.helpers; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Class with helper method @@ -273,4 +278,46 @@ public class Helper { } return ret; } + + public static ByteArrayInputStream getInputStream(byte[]... data) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try { + for (byte[] d : data) { + baos.write(d); + } + } catch (IOException iex) { + } + return new ByteArrayInputStream(baos.toByteArray()); + } + + public static byte[] readFile(String... file) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + for (String f : file) { + try { + FileInputStream fis = new FileInputStream(f); + byte buf[] = new byte[4096]; + int cnt = 0; + while ((cnt = fis.read(buf)) > 0) { + baos.write(buf, 0, cnt); + } + fis.close(); + } catch (IOException ex) { + Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex); + } + + } + return baos.toByteArray(); + } + + public static void writeFile(String file, byte[]... data) { + try { + FileOutputStream fos = new FileOutputStream(file); + for (byte d[] : data) { + fos.write(d); + } + fos.close(); + } catch (Exception ex) { + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 627226fe5..4985d7ac1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.Main; +import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; @@ -115,13 +116,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT * @return ASM source */ public String getASMSource(int version) { - List actions = new ArrayList(); - try { - actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); - } catch (IOException ex) { - Logger.getLogger(DefineButtonTag.class.getName()).log(Level.SEVERE, null, ex); - } - return Action.actionsToString(actions, null, version); + return Action.actionsToString(getActions(version), null, version); } /** @@ -141,8 +136,19 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT */ public List getActions(int version) { try { - return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int prevLength = 0; + if (previousTag != null) { + byte prevData[] = previousTag.getData(version); + baos.write(prevData); + prevLength = prevData.length; + } + baos.write(actionBytes); + ReReadableInputStream rri = new ReReadableInputStream(new ByteArrayInputStream(baos.toByteArray())); + rri.setPos(prevLength); + return SWFInputStream.readActionList(rri, version, prevLength); } catch (IOException ex) { + Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex); return new ArrayList(); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index b7ec54f26..5b6977963 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -80,25 +80,25 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT public RECT getRect(HashMap characters) { RECT ret = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); - HashMap depthMap=new HashMap(); + HashMap depthMap = new HashMap(); for (Tag t : subTags) { - Set needed = t.getNeededCharacters(); - MATRIX m = null; + Set needed = t.getNeededCharacters(); + MATRIX m = null; if (t instanceof PlaceObjectTypeTag) { - PlaceObjectTypeTag pot=(PlaceObjectTypeTag) t; + PlaceObjectTypeTag pot = (PlaceObjectTypeTag) t; m = pot.getMatrix(); - int charId=pot.getCharacterId(); - if(charId>-1){ + int charId = pot.getCharacterId(); + if (charId > -1) { depthMap.put(pot.getDepth(), charId); - }else{ + } else { needed.add(depthMap.get(pot.getDepth())); } - } + } if (needed.isEmpty()) { continue; } RECT r = getCharacterBounds(characters, needed); - + if (m != null) { Point topleft = m.apply(new Point(r.Xmin, r.Ymin)); Point bottomright = m.apply(new Point(r.Xmax, r.Ymax)); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 10a567749..49323e59e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -16,10 +16,14 @@ */ package com.jpexs.decompiler.flash.tags; +import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.base.ASMSource; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -47,14 +51,7 @@ public class DoActionTag extends Tag implements ASMSource { */ public DoActionTag(byte[] data, int version, long pos) { super(12, "DoAction", data, pos); - try { - ByteArrayInputStream bais = new ByteArrayInputStream(data); - SWFInputStream sis = new SWFInputStream(bais, version); - //actions = sis.readActionList(); - actionBytes = sis.readBytes(sis.available()); - } catch (IOException e) { - Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, e); - } + actionBytes = data; } /** @@ -74,14 +71,9 @@ public class DoActionTag extends Tag implements ASMSource { * @param version SWF version * @return ASM source */ + @Override public String getASMSource(int version) { - List actions = new ArrayList(); - try { - actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); - } catch (IOException ex) { - Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex); - } - return Action.actionsToString(actions, null, version); + return Action.actionsToString(getActions(version), null, version); } /** @@ -105,7 +97,20 @@ public class DoActionTag extends Tag implements ASMSource { public List getActions(int version) { try { - return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int prevLength = 0; + if (previousTag != null) { + byte prevData[] = previousTag.getData(version); + baos.write(prevData); + prevLength = prevData.length; + byte header[] = SWFOutputStream.getTagHeader(this, data, version); + baos.write(header); + prevLength += header.length; + } + baos.write(actionBytes); + ReReadableInputStream rri = new ReReadableInputStream(new ByteArrayInputStream(baos.toByteArray())); + rri.setPos(prevLength); + return SWFInputStream.readActionList(rri, version, prevLength); } catch (IOException ex) { Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex); return new ArrayList(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index f18964443..80bdfb9c5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.tags; +import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -91,21 +92,33 @@ public class DoInitActionTag extends CharacterTag implements ASMSource { * @param version SWF version * @return ASM source */ + @Override public String getASMSource(int version) { - List actions = new ArrayList(); - try { - actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); - } catch (IOException ex) { - Logger.getLogger(DoInitActionTag.class.getName()).log(Level.SEVERE, null, ex); - } - return Action.actionsToString(actions, null, version); + return Action.actionsToString(getActions(version), null, version); } + @Override public List getActions(int version) { try { - return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int prevLength = 0; + if (previousTag != null) { + byte prevData[] = previousTag.getData(version); + baos.write(prevData); + prevLength = prevData.length; + baos.write(0); + baos.write(0); + prevLength += 2; + byte header[] = SWFOutputStream.getTagHeader(this, data, version); + baos.write(header); + prevLength += header.length; + } + baos.write(actionBytes); + ReReadableInputStream rri = new ReReadableInputStream(new ByteArrayInputStream(baos.toByteArray())); + rri.setPos(prevLength); + return SWFInputStream.readActionList(rri, version, prevLength); } catch (IOException ex) { - Logger.getLogger(DoInitActionTag.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex); return new ArrayList(); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index b49a2598c..b46d34353 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -256,9 +256,9 @@ public class PlaceObject2Tag extends Tag implements Container, PlaceObjectTypeTa } public int getCharacterId() { - if(placeFlagHasCharacter){ + if (placeFlagHasCharacter) { return characterId; - }else{ + } else { return -1; } } @@ -268,14 +268,10 @@ public class PlaceObject2Tag extends Tag implements Container, PlaceObjectTypeTa } public MATRIX getMatrix() { - if(placeFlagHasMatrix){ + if (placeFlagHasMatrix) { return matrix; - }else{ + } else { return null; } } - - - - } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index 3096c6ef0..6d2a068e8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -334,13 +334,12 @@ public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTa public int getDepth() { return depth; } - + public MATRIX getMatrix() { - if(placeFlagHasMatrix){ + if (placeFlagHasMatrix) { return matrix; - }else{ + } else { return null; } } - } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java index ab0eaa21f..150778470 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java @@ -32,7 +32,7 @@ import java.util.Set; * * @author JPEXS */ -public class PlaceObjectTag extends Tag implements PlaceObjectTypeTag{ +public class PlaceObjectTag extends Tag implements PlaceObjectTypeTag { /** * ID of character to place @@ -119,8 +119,4 @@ public class PlaceObjectTag extends Tag implements PlaceObjectTypeTag{ public MATRIX getMatrix() { return matrix; } - - - - } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java index ee2029ea3..b7f21fa29 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java @@ -7,7 +7,10 @@ import com.jpexs.decompiler.flash.types.MATRIX; * @author JPEXS */ public interface PlaceObjectTypeTag { + public int getCharacterId(); + public int getDepth(); + public MATRIX getMatrix(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java index 872d30229..9c3449f3a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java @@ -28,7 +28,7 @@ import java.io.OutputStream; * * @author JPEXS */ -public class SoundStreamHead2Tag extends Tag implements SoundStreamHeadTypeTag{ +public class SoundStreamHead2Tag extends Tag implements SoundStreamHeadTypeTag { public int playBackSoundRate; public int playBackSoundSize; @@ -92,7 +92,7 @@ public class SoundStreamHead2Tag extends Tag implements SoundStreamHeadTypeTag{ latencySeek = sis.readSI16(); } } - + @Override public int getSoundFormat() { return streamSoundCompression; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java index b6eccda7c..45f692aac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java @@ -28,7 +28,7 @@ import java.io.OutputStream; * * @author JPEXS */ -public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag{ +public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag { public int playBackSoundRate; public int playBackSoundSize; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTypeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTypeTag.java index 26a80d6ff..7e9e9a1b4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTypeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTypeTag.java @@ -5,8 +5,12 @@ package com.jpexs.decompiler.flash.tags; * @author JPEXS */ public interface SoundStreamHeadTypeTag { + public int getSoundFormat(); + public int getSoundRate(); + public int getSoundSize(); + public int getSoundType(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java index f8eff5a38..240d28472 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -42,6 +42,7 @@ public class Tag { public boolean forceWriteAsLong = false; private final long pos; protected String name; + public Tag previousTag; public String getName() { return name; @@ -122,14 +123,14 @@ public class Tag { public Set getNeededCharacters() { return new HashSet(); } - - public Set getDeepNeededCharacters(HashMap characters){ - Set ret=new HashSet(); - Set needed=getNeededCharacters(); + + public Set getDeepNeededCharacters(HashMap characters) { + Set ret = new HashSet(); + Set needed = getNeededCharacters(); ret.addAll(needed); - for(int ch:needed){ + for (int ch : needed) { ret.addAll(characters.get(ch).getDeepNeededCharacters(characters)); - } + } return ret; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 6f206f126..bd0d395d9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.tags.base.ASMSource; @@ -111,13 +112,7 @@ public class BUTTONCONDACTION implements ASMSource { * @return ASM source */ public String getASMSource(int version) { - List actions = new ArrayList(); - try { - actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); - } catch (IOException ex) { - Logger.getLogger(BUTTONCONDACTION.class.getName()).log(Level.SEVERE, null, ex); - } - return Action.actionsToString(actions, null, version); + return Action.actionsToString(getActions(version), null, version); } /** @@ -135,15 +130,17 @@ public class BUTTONCONDACTION implements ASMSource { * @param version Version * @return List of actions */ + @Override public List getActions(int version) { try { - return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); + return SWFInputStream.readActionList(new ReReadableInputStream(new ByteArrayInputStream(actionBytes)), version, 0); } catch (IOException ex) { Logger.getLogger(BUTTONCONDACTION.class.getName()).log(Level.SEVERE, null, ex); return new ArrayList(); } } + @Override public void setActions(List actions, int version) { actionBytes = Action.actionsToBytes(actions, true, version); } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index d6bfc6d44..b888647d2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.tags.base.ASMSource; @@ -78,13 +79,7 @@ public class CLIPACTIONRECORD implements ASMSource { * @return ASM source */ public String getASMSource(int version) { - List actions = new ArrayList(); - try { - actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); - } catch (IOException ex) { - Logger.getLogger(CLIPACTIONRECORD.class.getName()).log(Level.SEVERE, null, ex); - } - return Action.actionsToString(actions, null, version); + return Action.actionsToString(getActions(version), null, version); } /** @@ -98,9 +93,9 @@ public class CLIPACTIONRECORD implements ASMSource { public List getActions(int version) { try { - return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); + return SWFInputStream.readActionList(new ReReadableInputStream(new ByteArrayInputStream(actionBytes)), version, 0); } catch (IOException ex) { - Logger.getLogger(CLIPACTIONRECORD.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(BUTTONCONDACTION.class.getName()).log(Level.SEVERE, null, ex); return new ArrayList(); } }