mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 17:20:53 +00:00
AS1/2: Ctrl+click to declaration of variables, registers. Hilighting methods and classes
AS1/2: Debugger - Show registers Fixed ctrl+click underline position
This commit is contained in:
@@ -29,9 +29,15 @@ public class CachedScript implements Serializable {
|
||||
public String text;
|
||||
|
||||
public List<Highlighting> hilights;
|
||||
public List<Highlighting> methodHilights;
|
||||
public List<Highlighting> classHilights;
|
||||
public List<Highlighting> specialHilights;
|
||||
|
||||
public CachedScript(String text, List<Highlighting> hilights) {
|
||||
public CachedScript(String text, List<Highlighting> hilights, List<Highlighting> methodHilights, List<Highlighting> classHilights, List<Highlighting> specialHilights) {
|
||||
this.text = text;
|
||||
this.hilights = hilights;
|
||||
this.methodHilights = methodHilights;
|
||||
this.classHilights = classHilights;
|
||||
this.specialHilights = specialHilights;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
@@ -44,13 +45,17 @@ public class CallFunctionActionItem extends ActionItem {
|
||||
}
|
||||
|
||||
public CallFunctionActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem functionName, List<GraphTargetItem> arguments) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
this.functionName = functionName;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = functionName.toStringNoQuotes(localData);
|
||||
|
||||
if (functionName instanceof DirectValueActionItem) {
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, (functionName).toStringNoQuotes(localData)));
|
||||
} else {
|
||||
|
||||
+5
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
@@ -74,8 +75,12 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
|
||||
writer.append("var ");
|
||||
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = name.toStringNoQuotes(localData);
|
||||
srcData.declaration = true;
|
||||
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
|
||||
IdentifiersDeobfuscation.appendObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData), writer);
|
||||
} else {
|
||||
|
||||
+7
-1
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -171,7 +172,12 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
return writer.append("\"").append(Helper.escapeActionScriptString(this.constants.get(((ConstantIndex) value).index))).append("\"");
|
||||
}
|
||||
if (value instanceof RegisterNumber) {
|
||||
return writer.append(((RegisterNumber) value).translate());
|
||||
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = ((RegisterNumber) value).translate();
|
||||
srcData.regIndex = ((RegisterNumber) value).number;
|
||||
|
||||
return writer.appendWithData(((RegisterNumber) value).translate(), srcData);
|
||||
}
|
||||
//return writer.append(value.toString());
|
||||
return writer.append(EcmaScript.toString(value, true)); // todo, use this line
|
||||
|
||||
+31
-3
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -36,8 +37,10 @@ import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class FunctionActionItem extends ActionItem {
|
||||
@@ -50,6 +53,8 @@ public class FunctionActionItem extends ActionItem {
|
||||
|
||||
public List<String> paramNames;
|
||||
|
||||
public Map<Integer, String> regNames;
|
||||
|
||||
public GraphTargetItem calculatedFunctionName;
|
||||
|
||||
private int regStart;
|
||||
@@ -79,18 +84,26 @@ public class FunctionActionItem extends ActionItem {
|
||||
super(null, null, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
public FunctionActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, String functionName, List<String> paramNames, List<GraphTargetItem> actions, List<String> constants, int regStart, List<VariableActionItem> variables) {
|
||||
public FunctionActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, String functionName, List<String> paramNames, Map<Integer, String> regNames, List<GraphTargetItem> actions, List<String> constants, int regStart, List<VariableActionItem> variables) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
this.actions = actions;
|
||||
this.constants = constants;
|
||||
this.functionName = functionName;
|
||||
this.paramNames = paramNames;
|
||||
this.regNames = regNames;
|
||||
this.regStart = regStart;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String n = calculatedFunctionName != null ? calculatedFunctionName.toStringNoQuotes(localData) : functionName;
|
||||
writer.startFunction(n);
|
||||
HighlightData srcData = getSrcData();
|
||||
if (n != null) {
|
||||
srcData.localName = n;
|
||||
srcData.declaration = true;
|
||||
}
|
||||
writer.append("function");
|
||||
if (calculatedFunctionName != null) {
|
||||
writer.append(" ");
|
||||
@@ -111,6 +124,11 @@ public class FunctionActionItem extends ActionItem {
|
||||
writer.spaceBeforeCallParenthesies(paramNames.size());
|
||||
writer.append("(");
|
||||
|
||||
Map<String, Integer> n2r = new HashMap<>();
|
||||
for (int r : regNames.keySet()) {
|
||||
n2r.put(regNames.get(r), r);
|
||||
}
|
||||
|
||||
for (int p = 0; p < paramNames.size(); p++) {
|
||||
if (p > 0) {
|
||||
writer.append(", ");
|
||||
@@ -119,16 +137,26 @@ public class FunctionActionItem extends ActionItem {
|
||||
if (pname == null || pname.isEmpty()) {
|
||||
pname = new RegisterNumber(regStart + p).translate();
|
||||
}
|
||||
HighlightData d = getSrcData();
|
||||
d.localName = pname;
|
||||
if (n2r.containsKey(pname)) {
|
||||
d.regIndex = n2r.get(pname);
|
||||
}
|
||||
d.declaration = true;
|
||||
|
||||
if (!IdentifiersDeobfuscation.isValidName(false, pname)) {
|
||||
IdentifiersDeobfuscation.appendObfuscatedIdentifier(pname, writer);
|
||||
} else {
|
||||
writer.append(pname);
|
||||
}
|
||||
writer.append(pname);
|
||||
}
|
||||
writer.append(")").startBlock();
|
||||
|
||||
Graph.graphToString(actions, writer, localData);
|
||||
|
||||
return writer.endBlock();
|
||||
writer.endBlock();
|
||||
writer.endMethod();
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-1
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
@@ -57,7 +58,7 @@ public class GetVariableActionItem extends ActionItem {
|
||||
}
|
||||
|
||||
public GetVariableActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem value) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
@@ -65,12 +66,17 @@ public class GetVariableActionItem extends ActionItem {
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
|
||||
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidNameWithDot(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = name.toStringNoQuotes(localData);
|
||||
|
||||
return IdentifiersDeobfuscation.appendObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData), writer);
|
||||
} else if ((!(name instanceof DirectValueActionItem)) || (!((DirectValueActionItem) name).isString())) {
|
||||
writer.append("eval(");
|
||||
name.appendTo(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = name.toStringNoQuotes(localData);
|
||||
return stripQuotes(name, localData, writer);
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -74,6 +75,9 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = name.toStringNoQuotes(localData);
|
||||
|
||||
IdentifiersDeobfuscation.appendObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData), writer);
|
||||
writer.append(" = ");
|
||||
return value.toString(writer, localData);
|
||||
@@ -86,6 +90,9 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = name.toStringNoQuotes(localData);
|
||||
|
||||
stripQuotes(name, localData, writer);
|
||||
writer.append(" = ");
|
||||
return value.toString(writer, localData);
|
||||
|
||||
+8
@@ -20,7 +20,9 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
@@ -77,7 +79,13 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction
|
||||
if (temporary) {
|
||||
value.toString(writer, localData);
|
||||
} else {
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = register.translate();
|
||||
srcData.regIndex = register.number;
|
||||
|
||||
if (define) {
|
||||
srcData.declaration = true;
|
||||
srcData.declaredType = DottedChain.ALL;
|
||||
writer.append("var ");
|
||||
}
|
||||
writer.append(register.translate()).append(" = ");
|
||||
|
||||
+4
-1
@@ -153,6 +153,7 @@ public class ClassActionItem extends ActionItem implements Block {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.startClass(className.toStringNoQuotes(localData));
|
||||
writer.append("class ");
|
||||
className.toStringNoQuotes(writer, localData);
|
||||
if (extendsOp != null) {
|
||||
@@ -204,7 +205,9 @@ public class ClassActionItem extends ActionItem implements Block {
|
||||
f.toString(writer, localData).newLine();
|
||||
}
|
||||
|
||||
return writer.endBlock();
|
||||
writer.endBlock();
|
||||
writer.endClass();
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -47,6 +47,7 @@ public class InterfaceActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.startClass(name.toStringNoQuotes(localData));
|
||||
writer.append("interface ");
|
||||
name.toStringNoQuotes(writer, localData);
|
||||
boolean first = true;
|
||||
@@ -60,7 +61,7 @@ public class InterfaceActionItem extends ActionItem {
|
||||
first = false;
|
||||
Action.getWithoutGlobal(ti).toStringNoQuotes(writer, localData);
|
||||
}
|
||||
return writer.startBlock().endBlock();
|
||||
return writer.startBlock().endBlock().endClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -300,7 +300,7 @@ public class ActionScript2Parser {
|
||||
expectedType(SymbolType.CURLY_CLOSE);
|
||||
}
|
||||
|
||||
return new FunctionActionItem(null, null, functionName, paramNames, body, constantPool, -1, subvariables);
|
||||
return new FunctionActionItem(null, null, functionName, paramNames, new HashMap<>() /*?*/, body, constantPool, -1, subvariables);
|
||||
}
|
||||
|
||||
private GraphTargetItem traits(boolean isInterface, GraphTargetItem nameStr, GraphTargetItem extendsStr, List<GraphTargetItem> implementsStr, List<VariableActionItem> variables) throws IOException, ActionParseException {
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
|
||||
@Override
|
||||
public void translateContainer(List<List<GraphTargetItem>> content, GraphSourceItem lineStartItem, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList<>());
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, getRegNames(), content.get(0), constantPool, 1, new ArrayList<>());
|
||||
//ActionGraph.translateViaGraph(regNames, variables, functions, code, version)
|
||||
stack.push(fti);
|
||||
functions.put(functionName, fti);
|
||||
|
||||
+1
-1
@@ -294,7 +294,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
|
||||
@Override
|
||||
public void translateContainer(List<List<GraphTargetItem>> content, GraphSourceItem lineStartItem, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList<>());
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, getRegNames(), content.get(0), constantPool, getFirstRegister(), new ArrayList<>());
|
||||
functions.put(functionName, fti);
|
||||
stack.push(fti);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user