Some Actions do not require Charset parameter

This commit is contained in:
Jindra Petřík
2025-08-02 13:21:53 +02:00
parent 041a9de9e1
commit 14aca37e80
10 changed files with 35 additions and 35 deletions

View File

@@ -1928,7 +1928,7 @@ public class SWFInputStream implements AutoCloseable {
try {
actionCode = readUI8("actionCode");
if (actionCode == 0) {
return new ActionEnd(getCharset());
return new ActionEnd();
}
if (actionCode == -1) {
return null;
@@ -1980,7 +1980,7 @@ public class SWFInputStream implements AutoCloseable {
case 0x0D:
return new ActionDivide();
case 0x0E:
return new ActionEquals(getCharset());
return new ActionEquals();
case 0x0F:
return new ActionLess();
case 0x10:
@@ -2115,11 +2115,11 @@ public class SWFInputStream implements AutoCloseable {
case 0x50:
return new ActionIncrement();
case 0x4C:
return new ActionPushDuplicate(getCharset());
return new ActionPushDuplicate();
case 0x3E:
return new ActionReturn();
case 0x4D:
return new ActionStackSwap(getCharset());
return new ActionStackSwap();
case 0x87:
return new ActionStoreRegister(actionLength, this);
// SWF6 Actions

View File

@@ -144,7 +144,7 @@ public class ActionListReader {
Action lastAction = actionMap.get(addresses.get(addresses.size() - 1));
long endAddress;
if (!(lastAction instanceof ActionEnd)) {
Action aEnd = new ActionEnd(sis.getCharset());
Action aEnd = new ActionEnd();
aEnd.setAddress(nextOffsets.get(lastAction.getAddress()));
endAddress = aEnd.getAddress();
actionMap.put(aEnd.getAddress(), aEnd);
@@ -703,7 +703,7 @@ public class ActionListReader {
long startIp = actions.get(0).getAddress();
Action lastAction = actions.get(actions.size() - 1);
if (!(lastAction instanceof ActionEnd)) {
Action aEnd = new ActionEnd(actions.getCharset());
Action aEnd = new ActionEnd();
aEnd.setAddress(lastAction.getAddress() + lastAction.getTotalActionLength());
actions.add(aEnd);
lastAction = aEnd;
@@ -769,7 +769,7 @@ public class ActionListReader {
long startIp = actions.get(0).getAddress();
Action lastAction = actions.get(actions.size() - 1);
if (!(lastAction instanceof ActionEnd)) {
Action aEnd = new ActionEnd(actions.getCharset());
Action aEnd = new ActionEnd();
aEnd.setAddress(lastAction.getAddress() + lastAction.getTotalActionLength());
actions.add(aEnd);
lastAction = aEnd;

View File

@@ -284,14 +284,14 @@ public class TryActionItem extends ActionItem implements Block {
fullCatchBody.addAll(0, GraphTargetItem.toSourceMerge(localData, generator,
new DirectValueActionItem(new RegisterNumber(catchRegister)),
ename,
new ActionStackSwap(charset),
new ActionStackSwap(),
new ActionDefineLocal(),
ebody
));
} else {
List<GraphSourceItem> ifBody = GraphTargetItem.toSourceMerge(localData, generator,
ename,
new ActionStackSwap(charset),
new ActionStackSwap(),
new ActionDefineLocal(),
ebody);
fullCatchBody.add(0, new ActionPop());
@@ -306,7 +306,7 @@ public class TryActionItem extends ActionItem implements Block {
etype,
new ActionPush(new RegisterNumber(catchRegister), charset),
new ActionCastOp(),
new ActionPushDuplicate(charset),
new ActionPushDuplicate(),
new ActionPush(Null.INSTANCE, charset),
new ActionEquals2(),
new ActionIf(ifBodySize, charset)

View File

@@ -193,7 +193,7 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("EndDrag") == 0) {
a = new ActionEndDrag();
} else if (instructionName.compareToIgnoreCase("Equals") == 0) {
a = new ActionEquals(charset);
a = new ActionEquals();
} else if (instructionName.compareToIgnoreCase("GetProperty") == 0) {
a = new ActionGetProperty();
} else if (instructionName.compareToIgnoreCase("GetTime") == 0) {
@@ -311,13 +311,13 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("NewObject") == 0) {
a = new ActionNewObject();
} else if (instructionName.compareToIgnoreCase("PushDuplicate") == 0) {
a = new ActionPushDuplicate(charset);
a = new ActionPushDuplicate();
} else if (instructionName.compareToIgnoreCase("Return") == 0) {
a = new ActionReturn();
} else if (instructionName.compareToIgnoreCase("SetMember") == 0) {
a = new ActionSetMember();
} else if (instructionName.compareToIgnoreCase("StackSwap") == 0) {
a = new ActionStackSwap(charset);
a = new ActionStackSwap();
} else if (instructionName.compareToIgnoreCase("StoreRegister") == 0) {
a = new ActionStoreRegister(lexer, charset);
} else if (instructionName.compareToIgnoreCase("TargetPath") == 0) {
@@ -357,9 +357,9 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("StrictMode") == 0) {
a = new ActionStrictMode(lexer, charset);
} else if (instructionName.compareToIgnoreCase("Nop") == 0) {
a = new ActionNop(charset);
a = new ActionNop();
} else if (instructionName.compareToIgnoreCase("End") == 0) {
a = new ActionEnd(charset);
a = new ActionEnd();
} else if (instructionName.compareToIgnoreCase("FFDec_DeobfuscatePop") == 0) {
a = new ActionDeobfuscatePop();
} else if (instructionName.compareToIgnoreCase("FFDec_DeobfuscateJump") == 0) {
@@ -595,7 +595,7 @@ public class ASMParser {
}
if (ret.size() == 0 || !(ret.get(ret.size() - 1) instanceof ActionEnd)) {
ret.add(new ActionEnd(charset));
ret.add(new ActionEnd());
}
return ret;

View File

@@ -769,7 +769,7 @@ public class ActionSourceGenerator implements SourceGenerator {
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, AndItem item) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
ret.addAll(generateToActionList(localData, item.leftSide));
ret.add(new ActionPushDuplicate(charset));
ret.add(new ActionPushDuplicate());
ret.add(new ActionNot());
List<Action> andExpr = generateToActionList(localData, item.rightSide);
andExpr.add(0, new ActionPop());
@@ -784,7 +784,7 @@ public class ActionSourceGenerator implements SourceGenerator {
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, OrItem item) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
ret.addAll(generateToActionList(localData, item.leftSide));
ret.add(new ActionPushDuplicate(charset));
ret.add(new ActionPushDuplicate());
List<Action> orExpr = generateToActionList(localData, item.rightSide);
orExpr.add(0, new ActionPop());
int orExprLen = Action.actionsToBytes(orExpr, false, SWF.DEFAULT_VERSION).length;
@@ -1016,7 +1016,7 @@ public class ActionSourceGenerator implements SourceGenerator {
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, DuplicateItem item) {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionPushDuplicate(charset));
ret.add(new ActionPushDuplicate());
return ret;
}

View File

@@ -24,6 +24,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,10 +39,9 @@ public class ActionEnd extends Action {
/**
* Constructor.
* @param charset Charset
*/
public ActionEnd(String charset) {
super(0, 0, charset);
public ActionEnd() {
super(0, 0, Utf8Helper.charsetName);
setIgnored(true, 0);
}

View File

@@ -23,6 +23,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -36,11 +37,10 @@ import java.util.Set;
public class ActionNop extends Action {
/**
* Constructor.
* @param charset Charset
* Constructor.
*/
public ActionNop(String charset) {
super(-1, 0, charset);
public ActionNop() {
super(-1, 0, Utf8Helper.charsetName);
}
/**

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -42,10 +43,9 @@ public class ActionEquals extends Action {
/**
* Constructor.
*
* @param charset Charset
*/
public ActionEquals(String charset) {
super(0x0E, 0, charset);
public ActionEquals() {
super(0x0E, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.DuplicateItem;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -44,10 +45,9 @@ public class ActionPushDuplicate extends Action {
/**
* Constructor.
*
* @param charset Charset
*/
public ActionPushDuplicate(String charset) {
super(0x4C, 0, charset);
public ActionPushDuplicate() {
super(0x4C, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -42,10 +43,9 @@ public class ActionStackSwap extends Action {
/**
* Constructor.
*
* @param charset Charset
*/
public ActionStackSwap(String charset) {
super(0x4D, 0, charset);
public ActionStackSwap() {
super(0x4D, 0, Utf8Helper.charsetName);
}
@Override