mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 16:30:47 +00:00
Added: AS1/2 - highlight variable definition and all its instances on cursor place
Fixed: AS1/2 - Incorrect DefineFunction2 parameter names when parameter name is empty
This commit is contained in:
+31
-2
@@ -116,7 +116,17 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
|
||||
* Inner functions
|
||||
*/
|
||||
private List<FunctionActionItem> innerFunctions;
|
||||
|
||||
/**
|
||||
* Parameter positions in the codde
|
||||
*/
|
||||
public List<Integer> paramPositions;
|
||||
|
||||
/**
|
||||
* Parameter registers
|
||||
*/
|
||||
private List<Integer> paramRegisters;
|
||||
|
||||
/**
|
||||
* Register - this
|
||||
*/
|
||||
@@ -146,6 +156,10 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
|
||||
* Register - global
|
||||
*/
|
||||
public static final int REGISTER_GLOBAL = 6;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void visit(GraphTargetVisitorInterface visitor) {
|
||||
@@ -185,8 +199,9 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
|
||||
* @param variables Variables
|
||||
* @param innerFunctions Inner functions
|
||||
* @param hasEval Has eval
|
||||
* @param paramPositions Parameter positions
|
||||
*/
|
||||
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, List<FunctionActionItem> innerFunctions, boolean hasEval) {
|
||||
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, List<FunctionActionItem> innerFunctions, boolean hasEval, List<Integer> paramPositions, List<Integer> paramRegisters) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
this.actions = actions;
|
||||
this.constants = constants;
|
||||
@@ -197,6 +212,8 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
|
||||
this.variables = variables;
|
||||
this.innerFunctions = innerFunctions;
|
||||
this.hasEval = hasEval;
|
||||
this.paramPositions = paramPositions;
|
||||
this.paramRegisters = paramRegisters;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,7 +284,11 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
|
||||
}
|
||||
String pname = paramNames.get(p);
|
||||
if (pname == null || pname.isEmpty()) {
|
||||
pname = new RegisterNumber(regStart + p).translate();
|
||||
if (paramRegisters != null) {
|
||||
pname = new RegisterNumber(paramRegisters.get(p)).translate();
|
||||
} else {
|
||||
pname = new RegisterNumber(regStart + p).translate();
|
||||
}
|
||||
}
|
||||
HighlightData d = getSrcData();
|
||||
d.localName = pname;
|
||||
@@ -336,6 +357,10 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<VariableActionItem> getVariables() {
|
||||
return variables;
|
||||
}
|
||||
|
||||
private Set<String> getDefinedVariableNames(List<VariableActionItem> variables) {
|
||||
Set<String> ret = new HashSet<>();
|
||||
for (VariableActionItem v : variables) {
|
||||
@@ -360,6 +385,10 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
|
||||
}
|
||||
}
|
||||
|
||||
public List<FunctionActionItem> getInnerFunctions() {
|
||||
return innerFunctions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
|
||||
|
||||
+1
-1
@@ -434,7 +434,7 @@ public class ActionScript2Parser {
|
||||
hasEval.setVal(true);
|
||||
}
|
||||
|
||||
FunctionActionItem retf = new FunctionActionItem(null, null, functionName, paramNames, new HashMap<>() /*?*/, body, constantPool, -1, subvariables, subfunctions, subHasEval.getVal());
|
||||
FunctionActionItem retf = new FunctionActionItem(null, null, functionName, paramNames, new HashMap<>() /*?*/, body, constantPool, -1, subvariables, subfunctions, subHasEval.getVal(), new ArrayList<>(), null);
|
||||
functions.add(retf);
|
||||
return retf;
|
||||
}
|
||||
|
||||
+2479
File diff suppressed because it is too large
Load Diff
+352
-342
File diff suppressed because it is too large
Load Diff
+11
-4
@@ -23,24 +23,31 @@ package com.jpexs.decompiler.flash.action.parser.script;
|
||||
*/
|
||||
public class ParsedSymbol {
|
||||
|
||||
/**
|
||||
* Position (characters) in source text
|
||||
*/
|
||||
public int position;
|
||||
|
||||
public SymbolGroup group;
|
||||
|
||||
public Object value;
|
||||
|
||||
public SymbolType type;
|
||||
|
||||
public ParsedSymbol(SymbolGroup group, SymbolType type) {
|
||||
public ParsedSymbol(int position, SymbolGroup group, SymbolType type) {
|
||||
this.position = position;
|
||||
this.group = group;
|
||||
this.type = type;
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
public ParsedSymbol(SymbolGroup group, SymbolType type, Object value) {
|
||||
public ParsedSymbol(int position, SymbolGroup group, SymbolType type, Object value) {
|
||||
this.position = position;
|
||||
this.group = group;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return group.toString() + " " + type.toString() + " " + (value != null ? value.toString() : "");
|
||||
|
||||
+13
-1
@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.action.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.ActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -42,6 +41,11 @@ public class VariableActionItem extends ActionItem {
|
||||
private GraphTargetItem storeValue;
|
||||
|
||||
private boolean definition;
|
||||
|
||||
/**
|
||||
* Position in code
|
||||
*/
|
||||
private int position = -1;
|
||||
|
||||
public void setDefinition(boolean definition) {
|
||||
this.definition = definition;
|
||||
@@ -61,6 +65,14 @@ public class VariableActionItem extends ActionItem {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public boolean isDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
funcList.add((FunctionActionItem) val);
|
||||
}
|
||||
}
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, getRegNames(), content.get(0), constantPool, 1, new ArrayList<>(), funcList, false /*actually unknown*/);
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, getRegNames(), content.get(0), constantPool, 1, new ArrayList<>(), funcList, false /*actually unknown*/, new ArrayList<>(), null);
|
||||
//ActionGraph.translateViaGraph(regNames, variables, functions, code, version)
|
||||
stack.push(fti);
|
||||
functions.put(functionName, fti);
|
||||
|
||||
+1
-1
@@ -429,7 +429,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
funcList.add((FunctionActionItem) val);
|
||||
}
|
||||
}
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, getRegNames(), content.get(0), constantPool, getFirstRegister(), new ArrayList<>(), funcList, false /*actually unknown*/);
|
||||
FunctionActionItem fti = new FunctionActionItem(this, lineStartItem, functionName, paramNames, getRegNames(), content.get(0), constantPool, getFirstRegister(), new ArrayList<>(), funcList, false /*actually unknown*/, new ArrayList<>(), paramRegisters);
|
||||
functions.put(functionName, fti);
|
||||
stack.push(fti);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user