Search AS progress

This commit is contained in:
Jindra Pet��k
2013-07-11 18:13:59 +02:00
parent 4b2ee2da42
commit 59ff4d6139
7 changed files with 55 additions and 21 deletions
@@ -2037,6 +2037,12 @@ public class AVM2Code implements Serializable {
if ((ins instanceof AVM2Instruction) && (((AVM2Instruction) ins).definition instanceof PopIns)) {
GraphTargetItem top = stack.peek();
for (GraphSourceItemPos p : top.getNeededSources()) {
if (p == null) {
continue;
}
if (p.item == null) {
continue;
}
if (p.item.isIgnored()) {
ins.setIgnored(true);
break;
@@ -1326,9 +1326,9 @@ public class Graph {
if (part.ignored) {
return ret;
}
List<GraphPart> loopContinues = getLoopsContinues(loops);
boolean isLoop = false;
boolean isLoop = false;
Loop currentLoop = null;
for (Loop el : loops) {
if ((el.loopContinue == part) && (el.phase == 0)) {
@@ -1337,7 +1337,7 @@ public class Graph {
isLoop = true;
break;
}
}
}
if (debugMode) {
System.err.println("loopsize:" + loops.size());
@@ -45,8 +45,4 @@ public class IntegerValueItem extends GraphTargetItem {
public Object getResult() {
return Double.valueOf(intValue);
}
}
@@ -1749,7 +1749,6 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
if (searchDialog.result) {
final String txt = searchDialog.searchField.getText();
if (!txt.equals("")) {
Main.startWork(translate("work.searching") + " \"" + txt + "\"...");
if (abcPanel != null) {
(new Thread() {
@Override
@@ -1760,7 +1759,6 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
} else {
JOptionPane.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE);
}
Main.stopWork();
}
}).start();
} else {
@@ -1772,7 +1770,6 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
} else {
JOptionPane.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE);
}
Main.stopWork();
}
}).start();
}
@@ -100,7 +100,15 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
} else {
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
}
int pos = 0;
for (MyEntry<ClassPath, ScriptPack> item : allpacks) {
pos++;
String workText = translate("work.searching");
String decAdd = "";
if (!decompiledTextArea.isCached(item.value)) {
decAdd = ", " + translate("work.decompiling");
}
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + item.key.toString() + "... ");
decompiledTextArea.cacheScriptPack(item.value, list);
if (pat.matcher(decompiledTextArea.getCachedText(item.value)).find()) {
found.add(item.value);
@@ -108,8 +116,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
}
System.gc();
//found = decompiledTextArea.searchCache(txt, ignoreCase, regexp);
Main.stopWork();
if (found.isEmpty()) {
searchPanel.setVisible(false);
return false;
@@ -253,6 +253,10 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
cache.remove(pack);
}
public boolean isCached(ScriptPack pack) {
return cache.contains(pack);
}
private CachedDecompilation getCached(ScriptPack pack) {
if (!cache.contains(pack)) {
cacheScriptPack(pack, abcList);
@@ -53,6 +53,8 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@@ -157,6 +159,10 @@ public class ActionPanel extends JPanel implements ActionListener {
return (CachedScript) cache.get(pack);
}
private boolean isCached(ASMSource src) {
return cache.contains(src);
}
private void cacheScript(ASMSource src) {
if (!cache.contains(src)) {
List<Action> as = src.getActions(SWF.DEFAULT_VERSION);
@@ -167,14 +173,22 @@ public class ActionPanel extends JPanel implements ActionListener {
}
}
private List<ASMSource> getASMs(List<TagNode> nodes) {
List<ASMSource> ret = new ArrayList<>();
private Map<String, ASMSource> getASMs(String path, List<TagNode> nodes) {
Map<String, ASMSource> ret = new HashMap<>();
for (TagNode n : nodes) {
String subPath = path + "/" + n.toString();
if (n.tag instanceof ASMSource) {
//cacheScript((ASMSource) n.tag);
ret.add((ASMSource) n.tag);
String npath = subPath;
int ppos = 1;
while (ret.containsKey(npath)) {
ppos++;
npath = subPath + "[" + ppos + "]";
}
ret.put(subPath, (ASMSource) n.tag);
}
ret.addAll(getASMs(n.subItems));
ret.putAll(getASMs(subPath, n.subItems));
}
return ret;
}
@@ -185,7 +199,7 @@ public class ActionPanel extends JPanel implements ActionListener {
searchRegexp = regexp;
List<Object> tags = new ArrayList<Object>(Main.swf.tags);
List<TagNode> list = Main.swf.createASTagList(tags, null);
List<ASMSource> asms = getASMs(list);
Map<String, ASMSource> asms = getASMs("", list);
found = new ArrayList<>();
Pattern pat = null;
if (regexp) {
@@ -193,13 +207,23 @@ public class ActionPanel extends JPanel implements ActionListener {
} else {
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
}
for (ASMSource s : asms) {
cacheScript(s);
if (pat.matcher(getCached(s).text).find()) {
found.add(s);
int pos = 0;
for (Entry<String, ASMSource> item : asms.entrySet()) {
pos++;
String workText = translate("work.searching");
String decAdd = "";
if (!isCached(item.getValue())) {
decAdd = ", " + translate("work.decompiling");
}
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ");
cacheScript(item.getValue());
if (pat.matcher(getCached(item.getValue()).text).find()) {
found.add(item.getValue());
}
}
Main.stopWork();
if (found.isEmpty()) {
searchPanel.setVisible(false);
return false;