mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-20 13:05:51 +00:00
Fixed #1963 AS2 properly decompile/direct edit long classes
This commit is contained in:
@@ -84,6 +84,8 @@ public class SourceGeneratorLocalData implements Serializable {
|
||||
|
||||
public List<List<Long>> catchesOpenedLoops = new ArrayList<>();
|
||||
public List<Integer> catchesTempRegs = new ArrayList<>();
|
||||
|
||||
public boolean secondRun = false;
|
||||
|
||||
public String getFullClass() {
|
||||
return pkg == null ? currentClass : pkg.addWithSuffix(currentClass).toRawString();
|
||||
|
||||
@@ -695,6 +695,8 @@ public class ActionScript2ClassDetector {
|
||||
} else if (item instanceof DirectValueActionItem) {
|
||||
//ignore such values
|
||||
//TODO: maybe somehow display in the class ?
|
||||
} else if (item instanceof ScriptEndItem){
|
||||
//ignore
|
||||
} else {
|
||||
throw new AssertException("unknown item - " + item.getClass().getSimpleName());
|
||||
}
|
||||
@@ -812,7 +814,13 @@ public class ActionScript2ClassDetector {
|
||||
}
|
||||
List<String> classPath = pathToSearchVariant1;
|
||||
classPath.remove(0); //remove _global
|
||||
if (this.checkClassContent(ifItem.onTrue, variables, 0, pos, checkPos, commands, classPath, scriptPath)) {
|
||||
if (ifItem.onTrue.isEmpty()) { //if can have zero offset as the code is larger than bytes limit. TODO: make this check also for variant 2 (?)
|
||||
if (this.checkClassContent(commands, variables, checkPos + 1, pos, commands.size() - 1, commands, classPath, scriptPath)) {
|
||||
return true;
|
||||
} else {
|
||||
break check_variant1;
|
||||
}
|
||||
} else if (this.checkClassContent(ifItem.onTrue, variables, 0, pos, checkPos, commands, classPath, scriptPath)) {
|
||||
return true;
|
||||
} else {
|
||||
break check_variant1;
|
||||
|
||||
@@ -2334,16 +2334,17 @@ public class ActionScript2Parser {
|
||||
return retTree;
|
||||
}
|
||||
|
||||
private List<GraphSourceItem> generateActionList(List<GraphTargetItem> tree, List<String> constantPool) throws CompilationException {
|
||||
private List<GraphSourceItem> generateActionList(List<GraphTargetItem> tree, List<String> constantPool, boolean secondRun) throws CompilationException {
|
||||
ActionSourceGenerator gen = new ActionSourceGenerator(swfVersion, constantPool, charset);
|
||||
SourceGeneratorLocalData localData = new SourceGeneratorLocalData(new HashMap<>(), 0, Boolean.FALSE, 0);
|
||||
localData.secondRun = secondRun;
|
||||
return gen.generate(localData, tree);
|
||||
}
|
||||
|
||||
private List<Action> actionsFromTree(List<GraphTargetItem> tree, List<String> constantPool, boolean doOrder, String charset) throws CompilationException, NeedsGenerateAgainException {
|
||||
List<Action> ret = new ArrayList<>();
|
||||
|
||||
List<GraphSourceItem> srcList = generateActionList(tree, constantPool);
|
||||
List<GraphSourceItem> srcList = generateActionList(tree, constantPool, doOrder == false);
|
||||
|
||||
if (doOrder) {
|
||||
List<String> orderedConstantPool = new ArrayList<>();
|
||||
|
||||
@@ -75,6 +75,7 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -868,7 +869,14 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
ret.addAll(typeToActions(globalClassTypeStr, null));
|
||||
ret.add(new ActionNot());
|
||||
ret.add(new ActionNot());
|
||||
ret.add(new ActionIf(Action.actionsToBytes(ifbody, false, SWF.DEFAULT_VERSION).length,charset));
|
||||
int ifOffset = Action.actionsToBytes(ifbody, false, SWF.DEFAULT_VERSION).length;
|
||||
if (ifOffset > 0x7fff) {
|
||||
if (!localData.secondRun) { //to avoid printing the warning twice
|
||||
Logger.getLogger(ActionSourceGenerator.class.getName()).warning("The class is long. If offset for its header would be longer than max value for SI16, 0 was stored instead. This should not have any negative impact.");
|
||||
}
|
||||
ifOffset = 0;
|
||||
}
|
||||
ret.add(new ActionIf(ifOffset, charset));
|
||||
ret.addAll(ifbody);
|
||||
ret.add(new ActionPop());
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user