From 463180f31e2fa31e25247373974c2289bc2d3c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sat, 2 Mar 2013 09:27:48 +0100 Subject: [PATCH] #35 Unicode strings fix --- .../com/jpexs/decompiler/flash/abc/ABC.java | 33 ++++++++------- .../decompiler/flash/abc/avm2/AVM2Code.java | 8 ++-- .../flash/abc/avm2/graph/AVM2Graph.java | 42 +++++++++---------- .../treemodel/clauses/ForEachInTreeItem.java | 3 -- .../avm2/treemodel/clauses/ForInTreeItem.java | 5 +-- .../decompiler/flash/abc/gui/ABCPanel.java | 3 ++ .../flash/abc/gui/MethodCodePanel.java | 2 + .../flash/abc/gui/MethodInfoPanel.java | 4 ++ .../decompiler/flash/action/ActionGraph.java | 4 +- .../flash/action/gui/ActionPanel.java | 4 ++ .../jpexs/decompiler/flash/graph/Graph.java | 14 +++---- .../jpexs/decompiler/flash/graph/Loop.java | 2 +- 12 files changed, 66 insertions(+), 58 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index c98ca06d9..6ce6ff621 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -861,29 +861,30 @@ public class ABC { for (int i = 0; i < bodies.length; i++) { bodies[i].autoFillStats(this); } - } - - public int findMethodBodyByName(int classId,String methodName){ - if(classId>-1){ - for(Trait t:instance_info[classId].instance_traits.traits){ - if(t instanceof TraitMethodGetterSetter){ - if(t.getName(this).getName(constants, new ArrayList()).equals(methodName)){ - return findBodyIndex(((TraitMethodGetterSetter)t).method_info); + } + + public int findMethodBodyByName(int classId, String methodName) { + if (classId > -1) { + for (Trait t : instance_info[classId].instance_traits.traits) { + if (t instanceof TraitMethodGetterSetter) { + if (t.getName(this).getName(constants, new ArrayList()).equals(methodName)) { + return findBodyIndex(((TraitMethodGetterSetter) t).method_info); } } } } return -1; } - public int findMethodBodyByName(String className,String methodName){ - int classId=findClassByName(className); - return findMethodBodyByName(classId,methodName); + + public int findMethodBodyByName(String className, String methodName) { + int classId = findClassByName(className); + return findMethodBodyByName(classId, methodName); } - - public int findClassByName(String name){ - for(int c=0;c()); List valuesMapping = new ArrayList(); @@ -1497,34 +1497,34 @@ public class AVM2Graph extends Graph { } @Override - protected void finalProcess(List list, int level) { - if(level==0){ - if(!list.isEmpty()){ - if(list.get(list.size()-1) instanceof ReturnVoidTreeItem){ - list.remove(list.size()-1); + protected void finalProcess(List list, int level) { + if (level == 0) { + if (!list.isEmpty()) { + if (list.get(list.size() - 1) instanceof ReturnVoidTreeItem) { + list.remove(list.size() - 1); } } } - for(int i=0;i ret = code.clearTemporaryRegisters(list); if (ret != list) { list.clear(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java index 80c87ea29..46482be01 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.clauses; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.treemodel.*; import com.jpexs.decompiler.flash.graph.Block; import com.jpexs.decompiler.flash.graph.ContinueItem; @@ -26,7 +24,6 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.Loop; import com.jpexs.decompiler.flash.graph.LoopItem; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; public class ForEachInTreeItem extends LoopItem implements Block { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java index 94c7d2789..7995e4fcb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.clauses; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.treemodel.*; import com.jpexs.decompiler.flash.graph.Block; import com.jpexs.decompiler.flash.graph.ContinueItem; @@ -26,7 +24,6 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.Loop; import com.jpexs.decompiler.flash.graph.LoopItem; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; public class ForInTreeItem extends LoopItem implements Block { @@ -41,7 +38,7 @@ public class ForInTreeItem extends LoopItem implements Block { return ret; } - public ForInTreeItem(GraphSourceItem instruction,Loop loop, InTreeItem expression, List commands) { + public ForInTreeItem(GraphSourceItem instruction, Loop loop, InTreeItem expression, List commands) { super(instruction, loop); if (!commands.isEmpty()) { GraphTargetItem firstAssign = commands.get(0); 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 ef9cc91c2..38b452e1e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java @@ -23,6 +23,7 @@ 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.Font; import java.awt.event.*; import java.util.ArrayList; import java.util.List; @@ -198,6 +199,8 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { splitPaneDecompiledVSDetail.setResizeWeight(0.5); splitPaneDecompiledVSDetail.setContinuousLayout(true); decompiledTextArea.setContentType("text/actionscript"); + decompiledTextArea.setFont(new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize())); + JPanel pan2 = new JPanel(); pan2.setLayout(new BorderLayout()); 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 2d59aec7e..5a2ee1bea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; @@ -70,6 +71,7 @@ public class MethodCodePanel extends JPanel implements ActionListener { setLayout(new BorderLayout()); add(new JScrollPane(sourceTextArea), BorderLayout.CENTER); sourceTextArea.setContentType("text/flasm3"); + sourceTextArea.setFont(new Font("Monospaced", Font.PLAIN, sourceTextArea.getFont().getSize())); buttonsPanel = new JPanel(); buttonsPanel.setLayout(new FlowLayout()); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java index 720771db1..40c0c6fa3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.methodinfo_parser.ParseException; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.helpers.Helper; import java.awt.Dimension; +import java.awt.Font; import java.util.ArrayList; import javax.swing.*; import jsyntaxpane.syntaxkits.Flasm3MethodInfoSyntaxKit; @@ -49,6 +50,9 @@ public class MethodInfoPanel extends JPanel { add(jsp); paramEditor.setContentType("text/flasm3_methodinfo"); returnTypeEditor.setContentType("text/flasm3_methodinfo"); + paramEditor.setFont(new Font("Monospaced", Font.PLAIN, paramEditor.getFont().getSize())); + returnTypeEditor.setFont(new Font("Monospaced", Font.PLAIN, returnTypeEditor.getFont().getSize())); + jsp.setMaximumSize(new Dimension(1024, 25)); Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) returnTypeEditor.getEditorKit(); sk.deinstallComponent(returnTypeEditor, "jsyntaxpane.components.LineNumbersRuler"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java index 4ae56625e..a981543e6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java @@ -63,7 +63,7 @@ public class ActionGraph extends Graph { } @Override - protected void finalProcess(List list,int level) { + protected void finalProcess(List list, int level) { List ret = Action.checkClass(list); if (ret != list) { list.clear(); @@ -178,7 +178,7 @@ public class ActionGraph extends Graph { next = breakPart; GraphTargetItem ti = checkLoop(next, stopPart, loops); - Loop currentLoop = new Loop(loops.size(),null, next); + Loop currentLoop = new Loop(loops.size(), null, next); loops.add(currentLoop); //switchLoc.getNextPartPath(new ArrayList()); List valuesMapping = new ArrayList(); 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 d2f64d24b..9ea8766e4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java @@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.ByteArrayInputStream; @@ -134,7 +135,10 @@ public class ActionPanel extends JPanel implements TreeSelectionListener, Action splitPane.setResizeWeight(0.5); splitPane2.setResizeWeight(0.5); editor.setContentType("text/flasm"); + editor.setFont(new Font("Monospaced", Font.PLAIN, editor.getFont().getSize())); decompiledEditor.setContentType("text/actionscript"); + decompiledEditor.setFont(new Font("Monospaced", Font.PLAIN, decompiledEditor.getFont().getSize())); + tagTree.addTreeSelectionListener(this); editor.addCaretListener(new CaretListener() { @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java index 40858115e..753b07102 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java @@ -291,23 +291,23 @@ public class Graph { populateParts(head, allParts); } List ret = printGraph(localData, new Stack(), allParts, null, heads.get(0), null, new ArrayList(), new HashMap>()); - finalProcessAll(ret,0); + finalProcessAll(ret, 0); return ret; } - private void finalProcessAll(List list,int level) { - finalProcess(list,level); + private void finalProcessAll(List list, int level) { + finalProcess(list, level); for (GraphTargetItem item : list) { if (item instanceof Block) { List> subs = ((Block) item).getSubs(); for (List sub : subs) { - finalProcessAll(sub,level+1); + finalProcessAll(sub, level + 1); } } } } - protected void finalProcess(List list,int level) { + protected void finalProcess(List list, int level) { } protected List getLoopsContinues(List loops) { @@ -831,7 +831,7 @@ public class Graph { if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(part, loopContinues)) { if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { if (output.isEmpty()) { - whileTrueLoop = new Loop(loops.size(),part, null); + whileTrueLoop = new Loop(loops.size(), part, null); loops.add(whileTrueLoop); whileTrue = true; } else { @@ -853,7 +853,7 @@ public class Graph { } Loop currentLoop = null; if (loop) { - currentLoop=new Loop(loops.size(),part, null); + currentLoop = new Loop(loops.size(), part, null); loops.add(currentLoop); } diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Loop.java b/trunk/src/com/jpexs/decompiler/flash/graph/Loop.java index 3d0c7569f..c4c433108 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Loop.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Loop.java @@ -29,6 +29,6 @@ public class Loop { public Loop(long id, GraphPart loopContinue, GraphPart loopBreak) { this.loopContinue = loopContinue; this.loopBreak = loopBreak; - this.id=id; + this.id = id; } }