mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-29 09:46:01 +00:00
Fixed: #2353 AS1/2 - fscommand and other dynamic GetURL related calls (decompilation + editation)
This commit is contained in:
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
@@ -94,7 +95,7 @@ public class FSCommandActionItem extends ActionItem {
|
||||
((parameter instanceof DirectValueActionItem) && ((DirectValueActionItem) parameter).isString()))) {
|
||||
return toSourceMerge(localData, generator, new ActionGetURL("FSCommand:" + ((DirectValueActionItem) command).getAsString(), parameter == null ? "" : ((DirectValueActionItem) parameter).getAsString(), charset));
|
||||
}
|
||||
return toSourceMerge(localData, generator, new AddActionItem(null, null, asGenerator.pushConstTargetItem("FSCommand:"), command, true), parameter == null ? asGenerator.pushConstTargetItem("") : parameter, new ActionGetURL2(1/*GET*/, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
return toSourceMerge(localData, generator, new StringAddActionItem(null, null, asGenerator.pushConstTargetItem("FSCommand:"), command), parameter == null ? asGenerator.pushConstTargetItem("") : parameter, new ActionGetURL2(1/*GET*/, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
@@ -111,7 +112,7 @@ public class LoadMovieNumActionItem extends ActionItem {
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
lev = new StringAddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num);
|
||||
}
|
||||
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
@@ -111,7 +112,7 @@ public class LoadVariablesNumActionItem extends ActionItem {
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
lev = new StringAddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num);
|
||||
}
|
||||
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, true, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
@@ -97,7 +98,7 @@ public class PrintAsBitmapNumActionItem extends ActionItem {
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
lev = new StringAddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num);
|
||||
}
|
||||
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("printasbitmap:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
@@ -97,7 +98,7 @@ public class PrintNumActionItem extends ActionItem {
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
lev = new StringAddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num);
|
||||
}
|
||||
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("print:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
@@ -87,7 +88,7 @@ public class UnLoadMovieNumActionItem extends ActionItem {
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
return toSourceMerge(localData, generator, new ActionGetURL("", "_level" + ((DirectValueActionItem) num).value, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator, new ActionPush("", charset), new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true), new ActionGetURL2(0, false, true, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
return toSourceMerge(localData, generator, new ActionPush("", charset), new StringAddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num), new ActionGetURL2(0, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.as2.Trait;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.FSCommandActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.GetURL2ActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.LoadMovieActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem;
|
||||
@@ -34,6 +35,7 @@ import com.jpexs.decompiler.flash.action.model.PrintAsBitmapNumActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.PrintNumActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.ActionParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
|
||||
@@ -187,7 +189,7 @@ public class ActionGetURL2 extends Action {
|
||||
public void translate(Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem targetString = stack.pop();
|
||||
GraphTargetItem urlString = stack.pop();
|
||||
Integer num = null;
|
||||
GraphTargetItem num = null;
|
||||
if (targetString.isCompileTime()) {
|
||||
Object res = targetString.getResult();
|
||||
if (res instanceof String) {
|
||||
@@ -195,16 +197,35 @@ public class ActionGetURL2 extends Action {
|
||||
String levelPrefix = "_level";
|
||||
if (tarStr.startsWith(levelPrefix)) {
|
||||
try {
|
||||
num = Integer.valueOf(tarStr.substring(levelPrefix.length()));
|
||||
num = new DirectValueActionItem(Long.valueOf(tarStr.substring(levelPrefix.length())));
|
||||
} catch (NumberFormatException nfe) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == null) {
|
||||
if (targetString instanceof StringAddActionItem) {
|
||||
StringAddActionItem sa = (StringAddActionItem) targetString;
|
||||
if (sa.leftSide.isCompileTime()) {
|
||||
Object res = sa.leftSide.getResult();
|
||||
if (res instanceof String) {
|
||||
String tarStr = (String) res;
|
||||
String levelPrefix = "_level";
|
||||
if (tarStr.equals(levelPrefix)) {
|
||||
num = sa.rightSide;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (loadVariablesFlag) {
|
||||
if (num != null) {
|
||||
output.add(new LoadVariablesNumActionItem(this, lineStartAction, urlString, new DirectValueActionItem(null, null, 0, (Long) (long) (int) num, new ArrayList<>()), sendVarsMethod));
|
||||
output.add(new LoadVariablesNumActionItem(this, lineStartAction, urlString, num, sendVarsMethod));
|
||||
} else {
|
||||
output.add(new LoadVariablesActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
}
|
||||
@@ -215,28 +236,72 @@ public class ActionGetURL2 extends Action {
|
||||
output.add(new LoadMovieActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
}
|
||||
} else {
|
||||
String printPrefix = "print:#";
|
||||
String printAsBitmapPrefix = "printasbitmap:#";
|
||||
String urlStr = null;
|
||||
final String printPrefix = "print:#";
|
||||
final String printAsBitmapPrefix = "printasbitmap:#";
|
||||
final String fscommandPrefix = "FSCommand:";
|
||||
GraphTargetItem printType = null;
|
||||
boolean doPrint = false;
|
||||
boolean doPrintAsBitmap = false;
|
||||
boolean doFSCommand = false;
|
||||
boolean doUnload = false;
|
||||
|
||||
if (urlString.isCompileTime() && (urlString.getResult() instanceof String)) {
|
||||
urlStr = (String) urlString.getResult();
|
||||
}
|
||||
String urlStr = (String) urlString.getResult();
|
||||
if ("".equals(urlStr)) {
|
||||
doUnload = true;
|
||||
} else if (urlStr.startsWith(printPrefix)) {
|
||||
printType = new DirectValueActionItem(urlStr.substring(printPrefix.length()));
|
||||
doPrint = true;
|
||||
} else if (urlStr.startsWith(printAsBitmapPrefix)) {
|
||||
printType = new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()));
|
||||
doPrintAsBitmap = true;
|
||||
} else if (urlStr.startsWith(fscommandPrefix)) {
|
||||
urlString = new DirectValueActionItem(urlStr.substring(fscommandPrefix.length()));
|
||||
doFSCommand = true;
|
||||
}
|
||||
} else if (urlString instanceof StringAddActionItem) {
|
||||
StringAddActionItem sa = (StringAddActionItem) urlString;
|
||||
if (sa.leftSide.isCompileTime()) {
|
||||
Object res = sa.leftSide.getResult();
|
||||
if (res instanceof String) {
|
||||
String urlStr = (String) res;
|
||||
switch (urlStr) {
|
||||
case printPrefix:
|
||||
printType = sa.rightSide;
|
||||
doPrint = true;
|
||||
urlString = null;
|
||||
break;
|
||||
case printAsBitmapPrefix:
|
||||
printType = sa.rightSide;
|
||||
doPrintAsBitmap = true;
|
||||
urlString = null;
|
||||
break;
|
||||
case fscommandPrefix:
|
||||
urlString = sa.rightSide;
|
||||
doFSCommand = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (num != null) {
|
||||
if ("".equals(urlStr)) {
|
||||
output.add(new UnLoadMovieNumActionItem(this, lineStartAction, new DirectValueActionItem(null, null, 0, (Long) (long) (int) num, new ArrayList<>())));
|
||||
} else if (urlStr != null && urlStr.startsWith(printPrefix)) {
|
||||
output.add(new PrintNumActionItem(this, lineStartAction, new DirectValueActionItem((Long) (long) (int) num),
|
||||
new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
|
||||
} else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
|
||||
output.add(new PrintAsBitmapNumActionItem(this, lineStartAction, new DirectValueActionItem((Long) (long) (int) num), new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
|
||||
if (doUnload) {
|
||||
output.add(new UnLoadMovieNumActionItem(this, lineStartAction, num));
|
||||
} else if (doPrint) {
|
||||
output.add(new PrintNumActionItem(this, lineStartAction, num,
|
||||
printType));
|
||||
} else if (doPrintAsBitmap) {
|
||||
output.add(new PrintAsBitmapNumActionItem(this, lineStartAction, num, printType));
|
||||
} else {
|
||||
output.add(new LoadMovieNumActionItem(this, lineStartAction, urlString, new DirectValueActionItem(null, null, 0, (Long) (long) (int) num, new ArrayList<>()), sendVarsMethod));
|
||||
output.add(new LoadMovieNumActionItem(this, lineStartAction, urlString, num, sendVarsMethod));
|
||||
}
|
||||
} else if (urlStr != null && urlStr.startsWith(printPrefix)) {
|
||||
output.add(new PrintActionItem(this, lineStartAction, targetString, new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
|
||||
} else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
|
||||
output.add(new PrintAsBitmapActionItem(this, lineStartAction, targetString, new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
|
||||
} else if (doPrint) {
|
||||
output.add(new PrintActionItem(this, lineStartAction, targetString, printType));
|
||||
} else if (doPrintAsBitmap) {
|
||||
output.add(new PrintAsBitmapActionItem(this, lineStartAction, targetString, printType));
|
||||
} else if (doFSCommand) {
|
||||
output.add(new FSCommandActionItem(this, lineStartAction, urlString, targetString));
|
||||
} else {
|
||||
output.add(new GetURL2ActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
}
|
||||
|
||||
@@ -142,6 +142,9 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
/**
|
||||
* Converts a value to an item
|
||||
*
|
||||
* FIXME!!! This should only convert to values relatable to current Graph type,
|
||||
* e.g. ActionItems for AS1/2, AVM2Items for AS3
|
||||
*
|
||||
* @param r Value
|
||||
* @return Graph target item
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user