mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-06 02:44:54 +00:00
NewFunction highlight+indent fix
This commit is contained in:
@@ -1190,7 +1190,7 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
|
||||
public String toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap<Integer, String> localRegNames, Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
|
||||
return toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, body, false, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, staticOperation, localRegAssigmentIps, refs);
|
||||
return toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, body, false, true, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, staticOperation, localRegAssigmentIps, refs);
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
@@ -1260,7 +1260,7 @@ public class AVM2Code implements Serializable {
|
||||
ignoredIns = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap<Integer, String> localRegNames, Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
|
||||
public String toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, boolean replaceIndents, HashMap<Integer, String> localRegNames, Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
|
||||
initToSource();
|
||||
List<GraphTargetItem> list;
|
||||
String s;
|
||||
@@ -1375,7 +1375,7 @@ public class AVM2Code implements Serializable {
|
||||
list.remove(lastPos);
|
||||
}
|
||||
|
||||
s = Graph.graphToString(list, hilighted, true, constants, localRegNames, fullyQualifiedNames);
|
||||
s = Graph.graphToString(list, hilighted, replaceIndents, constants, localRegNames, fullyQualifiedNames);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class NewFunctionIns extends InstructionDefinition {
|
||||
String paramStr = "";
|
||||
if (mybody != null) {
|
||||
try {
|
||||
bodyStr = Highlighting.hilighMethodEnd() + mybody.toString(path + "/inner", false, isStatic, scriptIndex, classIndex, abc, constants, method_info, new Stack<GraphTargetItem>()/*scopeStack*/, false, true, fullyQualifiedNames, null) + Highlighting.hilighMethodBegin(body.method_info);
|
||||
bodyStr = Highlighting.hilighMethodEnd() + mybody.toString(path + "/inner", false, isStatic, scriptIndex, classIndex, abc, constants, method_info, new Stack<GraphTargetItem>()/*scopeStack*/, false, true, false, fullyQualifiedNames, null) + Highlighting.hilighMethodBegin(body.method_info);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(NewFunctionIns.class.getName()).log(Level.SEVERE, "error during newfunction", ex);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,6 +40,12 @@ public class NewFunctionAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return hilight("function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr + "\r\n{\r\n", highlight) + (highlight ? functionBody : Highlighting.stripHilights(functionBody)) + "\r\n" + hilight("}", highlight);
|
||||
String ret = hilight("function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr, highlight);
|
||||
ret += "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
ret += (highlight ? functionBody : Highlighting.stripHilights(functionBody)) + "\r\n";
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String toString(final String path, boolean pcode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final ConstantPool constants, final MethodInfo method_info[], final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final boolean hilight, final List<String> fullyQualifiedNames, final Traits initTraits) {
|
||||
public String toString(final String path, boolean pcode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final ConstantPool constants, final MethodInfo method_info[], final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final boolean hilight, final boolean replaceIndents, final List<String> fullyQualifiedNames, final Traits initTraits) {
|
||||
if (debugMode) {
|
||||
System.err.println("Decompiling " + path);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
s += Helper.timedCall(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, scopeStack, isStaticInitializer, hilight, fullyQualifiedNames, initTraits);
|
||||
return toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, scopeStack, isStaticInitializer, hilight, replaceIndents, fullyQualifiedNames, initTraits);
|
||||
}
|
||||
}, timeout, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
|
||||
@@ -139,7 +139,7 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
return s;
|
||||
}
|
||||
|
||||
public String toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, boolean hilight, List<String> fullyQualifiedNames, Traits initTraits) {
|
||||
public String toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, boolean hilight, boolean replaceIndents, List<String> fullyQualifiedNames, Traits initTraits) {
|
||||
AVM2Code deobfuscated = null;
|
||||
MethodBody b = (MethodBody) Helper.deepCopy(this);
|
||||
deobfuscated = b.code;
|
||||
@@ -153,7 +153,7 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
}
|
||||
//deobfuscated.restoreControlFlow(constants, b);
|
||||
//try {
|
||||
String s = deobfuscated.toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, b, hilight, getLocalRegNames(abc), scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<Integer, Integer>(), deobfuscated.visitCode(b));
|
||||
String s = deobfuscated.toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, b, hilight, replaceIndents, getLocalRegNames(abc), scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<Integer, Integer>(), deobfuscated.visitCode(b));
|
||||
s = s.trim();
|
||||
if (s.equals("")) {
|
||||
s = " ";
|
||||
|
||||
@@ -444,7 +444,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
String bodyStr = "";
|
||||
bodyIndex = abc.findBodyIndex(abc.class_info[class_info].cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits);
|
||||
bodyStr = abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), true, highlight, true, fullyQualifiedNames, abc.class_info[class_info].static_traits);
|
||||
}
|
||||
if (Highlighting.stripHilights(bodyStr).trim().equals("")) {
|
||||
toPrint = ABC.addTabs(bodyStr + "/*classInitializer*/", 3);
|
||||
@@ -478,7 +478,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
bodyStr = "";
|
||||
bodyIndex = abc.findBodyIndex(abc.instance_info[class_info].iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3);
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, true, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3);
|
||||
constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, abc.bodies[bodyIndex], abc, fullyQualifiedNames);
|
||||
} else {
|
||||
constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, null, abc, fullyQualifiedNames);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, fullyQualifiedNames, null), 3);
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, true, fullyQualifiedNames, null), 3);
|
||||
}
|
||||
return ABC.IDENT_STRING + ABC.IDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}");
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, fullyQualifiedNames, null), 3);
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, true, fullyQualifiedNames, null), 3);
|
||||
}
|
||||
return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user