mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 03:30:51 +00:00
Issue #842 For reconstruction if debug line info present
Spaces added between parts of for
This commit is contained in:
@@ -674,6 +674,75 @@ public class AVM2Code implements Cloneable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void calculateDebugFileLine(ABC abc) {
|
||||
calculateDebugFileLine(null, 0, 0, abc, new HashSet<Integer>());
|
||||
}
|
||||
|
||||
private boolean calculateDebugFileLine(String debugFile, int debugLine, int pos, ABC abc, Set<Integer> seen) {
|
||||
while (pos < code.size()) {
|
||||
AVM2Instruction ins = code.get(pos);
|
||||
if (seen.contains(pos)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
seen.add(pos);
|
||||
|
||||
if (ins.definition instanceof DebugFileIns) {
|
||||
debugFile = abc.constants.getString(ins.operands[0]);
|
||||
}
|
||||
|
||||
if (ins.definition instanceof DebugLineIns) {
|
||||
debugLine = ins.operands[0];
|
||||
}
|
||||
|
||||
ins.setFileLine(debugFile, debugLine);
|
||||
|
||||
if (ins.definition instanceof NewFunctionIns) {
|
||||
MethodBody innerBody = abc.findBody(ins.operands[0]);
|
||||
innerBody.getCode().calculateDebugFileLine(debugFile, debugLine, 0, abc, new HashSet<Integer>());
|
||||
}
|
||||
|
||||
if (ins.definition instanceof ReturnValueIns) {
|
||||
return true;
|
||||
}
|
||||
if (ins.definition instanceof ReturnVoidIns) {
|
||||
return true;
|
||||
}
|
||||
if (ins.definition instanceof JumpIns) {
|
||||
try {
|
||||
pos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]);
|
||||
continue;
|
||||
} catch (ConvertException ex) {
|
||||
return false;
|
||||
}
|
||||
} else if (ins.definition instanceof IfTypeIns) {
|
||||
try {
|
||||
int newpos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]);
|
||||
calculateDebugFileLine(debugFile, debugLine, newpos, abc, seen);
|
||||
} catch (ConvertException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (ins.definition instanceof LookupSwitchIns) {
|
||||
for (int i = 0; i < ins.operands.length; i++) {
|
||||
if (i == 1) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
int newpos = adr2pos(pos2adr(pos) + ins.operands[i]);
|
||||
if (!calculateDebugFileLine(debugFile, debugLine, newpos, abc, seen)) {
|
||||
return false;
|
||||
}
|
||||
} catch (ConvertException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public AVM2Code(ABCInputStream ais) throws IOException {
|
||||
Map<Long, AVM2Instruction> codeMap = new TreeMap<>();
|
||||
Map<Long, Long> endOffsets = new HashMap<>();
|
||||
|
||||
@@ -726,6 +726,7 @@ public class AVM2Graph extends Graph {
|
||||
|
||||
@Override
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData) {
|
||||
super.finalProcess(list, level, localData);
|
||||
if (level == 0) {
|
||||
if (!list.isEmpty()) {
|
||||
if (list.get(list.size() - 1) instanceof ReturnVoidAVM2Item) {
|
||||
|
||||
@@ -79,6 +79,7 @@ public class AVM2GraphSource extends GraphSource {
|
||||
this.scriptIndex = scriptIndex;
|
||||
this.localRegAssigmentIps = localRegAssigmentIp;
|
||||
this.refs = refs;
|
||||
code.calculateDebugFileLine(abc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+20
@@ -56,6 +56,15 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
|
||||
|
||||
public int changeJumpTo = -1;
|
||||
|
||||
private int line;
|
||||
|
||||
private String file;
|
||||
|
||||
public void setFileLine(String file, int line) {
|
||||
this.file = file;
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands) {
|
||||
this.definition = definition;
|
||||
this.operands = operands != null && operands.length > 0 ? operands : null;
|
||||
@@ -382,4 +391,15 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1287,4 +1287,15 @@ public abstract class Action implements GraphSourceItem {
|
||||
public boolean isDeobfuscatePop() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLine() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
*/
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
@@ -93,7 +94,7 @@ public class ActionGraph extends Graph {
|
||||
|
||||
@Override
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData) {
|
||||
|
||||
super.finalProcess(list, level, localData);
|
||||
List<GraphTargetItem> ret = Action.checkClass(list);
|
||||
if (ret != list) {
|
||||
list.clear();
|
||||
|
||||
Reference in New Issue
Block a user