mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-12 07:24:50 +00:00
Fixed #2437 AS1 P-code - do not group pushes automatically,
AS1 Direct editation - group pushes on FP5+, AS1 - use Constant pool only on FP5+
This commit is contained in:
@@ -728,20 +728,14 @@ public abstract class Action implements GraphSourceItem {
|
||||
}
|
||||
} else {
|
||||
//if (!(a instanceof ActionNop)) {
|
||||
String add = "";
|
||||
// honfika: commented out the following lines, because it makes no sense
|
||||
/*if (a instanceof ActionIf) {
|
||||
add = " change: " + ((ActionIf) a).getJumpOffset();
|
||||
}
|
||||
if (a instanceof ActionJump) {
|
||||
add = " change: " + ((ActionJump) a).getJumpOffset();
|
||||
}
|
||||
add = "; ofs" + Helper.formatAddress(offset) + add;
|
||||
add = "";*/
|
||||
if ((a instanceof ActionPush) && lastPush) {
|
||||
String add = "";
|
||||
//Flash player 4 does not allow more than 1 item in ActionPush, so I commented this out
|
||||
/*if ((a instanceof ActionPush) && lastPush) {
|
||||
writer.appendNoHilight(", ");
|
||||
((ActionPush) a).paramsToStringReplaced(list, importantOffsets, exportMode, writer);
|
||||
} else {
|
||||
} else
|
||||
*/
|
||||
{
|
||||
if (lastPush) {
|
||||
writer.newLine();
|
||||
//lastPush = false;
|
||||
|
||||
@@ -422,10 +422,12 @@ public class ASMParser {
|
||||
ActionList list = new ActionList(charset);
|
||||
Stack<GraphSourceItemContainer> containers = new Stack<>();
|
||||
|
||||
ActionConstantPool cpool = new ActionConstantPool(constantPool, charset);
|
||||
cpool.setAddress(address);
|
||||
address += cpool.getTotalActionLength();
|
||||
list.add(cpool);
|
||||
if (!constantPool.isEmpty()) {
|
||||
ActionConstantPool cpool = new ActionConstantPool(constantPool, charset);
|
||||
cpool.setAddress(address);
|
||||
address += cpool.getTotalActionLength();
|
||||
list.add(cpool);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
ASMParsedSymbol symb = lexer.lex();
|
||||
|
||||
@@ -2147,6 +2147,12 @@ public class ActionScript2Parser {
|
||||
}
|
||||
|
||||
private DirectValueActionItem pushConst(String s) throws IOException, ActionParseException {
|
||||
|
||||
//ActionConstantPool was introduced in SWF 5
|
||||
if (swfVersion < 5) {
|
||||
return new DirectValueActionItem(null, null, 0, s, constantPool);
|
||||
}
|
||||
|
||||
int index = constantPool.indexOf(s);
|
||||
if (index == -1) {
|
||||
if (ActionConstantPool.calculateSize(constantPool) + ActionConstantPool.calculateSize(s) <= 0xffff) {
|
||||
@@ -2467,7 +2473,9 @@ public class ActionScript2Parser {
|
||||
ret.add((Action) s);
|
||||
}
|
||||
}
|
||||
ret.add(0, new ActionConstantPool(constantPool, charset));
|
||||
if (!constantPool.isEmpty()) {
|
||||
ret.add(0, new ActionConstantPool(constantPool, charset));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,11 +135,35 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
* @return List of Action
|
||||
*/
|
||||
public List<Action> toActionList(List<GraphSourceItem> items) {
|
||||
items = groupPushes(items);
|
||||
List<Action> ret = new ArrayList<>();
|
||||
for (GraphSourceItem s : items) {
|
||||
for (GraphSourceItem s : items) {
|
||||
if (s instanceof Action) {
|
||||
ret.add((Action) s);
|
||||
ret.add((Action) s);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<GraphSourceItem> groupPushes(List<GraphSourceItem> items) {
|
||||
if (swfVersion <= 4) {
|
||||
return items;
|
||||
}
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
ActionPush prevPush = null;
|
||||
for (GraphSourceItem s : items) {
|
||||
if (s instanceof ActionPush) {
|
||||
if (prevPush == null) {
|
||||
prevPush = (ActionPush) s;
|
||||
ret.add(prevPush);
|
||||
} else {
|
||||
prevPush.values.addAll(((ActionPush) s).values);
|
||||
((ActionPush) s).values.clear();
|
||||
}
|
||||
} else {
|
||||
ret.add(s);
|
||||
prevPush = null;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -988,6 +1012,7 @@ public class ActionSourceGenerator implements SourceGenerator {
|
||||
for (GraphTargetItem item : commands) {
|
||||
ret.addAll(item.toSourceIgnoreReturnValue(localData, this));
|
||||
}
|
||||
ret = groupPushes(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user