mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 03:00:59 +00:00
Experimental execution of AS1/2 in FFDec Flash viewer (very basic, needs testing and many improvements)
This commit is contained in:
@@ -15,6 +15,14 @@ public class ActionScriptFunction extends ActionScriptObject {
|
||||
protected List<String> paramNames;
|
||||
protected Map<Integer, String> funcRegNames;
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
public Map<Integer, String> getFuncRegNames() {
|
||||
return funcRegNames;
|
||||
}
|
||||
|
||||
public ActionScriptFunction(long functionOffset, long functionLength, String functionName, List<String> paramNames, Map<Integer, String> funcRegNames) {
|
||||
this.functionOffset = functionOffset;
|
||||
this.functionLength = functionLength;
|
||||
@@ -23,11 +31,6 @@ public class ActionScriptFunction extends ActionScriptObject {
|
||||
this.funcRegNames = funcRegNames;
|
||||
}
|
||||
|
||||
public Object execute(Object thisObj, List<Object> args) {
|
||||
//TODO!!!
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getFunctionLength() {
|
||||
return functionLength;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -54,6 +56,11 @@ public class DisplayObject extends ActionScriptObject {
|
||||
paused = false;
|
||||
}
|
||||
|
||||
public Object callFunction(long functionAddress, long functionLength, List<Object> args, Map<Integer, String> regNames, Object thisObj) {
|
||||
//TODO
|
||||
return Undefined.INSTANCE;
|
||||
}
|
||||
|
||||
public void callFrame(int frame) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class LocalDataArea {
|
||||
|
||||
public Stack<Object> stack = new Stack<>();
|
||||
|
||||
public List<Object> functions = new ArrayList<>();
|
||||
public List<ActionScriptFunction> functions = new ArrayList<>();
|
||||
|
||||
public Map<String, Object> localVariables = new HashMap<>();
|
||||
|
||||
@@ -70,6 +70,9 @@ public class LocalDataArea {
|
||||
constantPool = null;
|
||||
stack.clear();
|
||||
localVariables.clear();
|
||||
localRegisters.clear();
|
||||
withs.clear();
|
||||
functions.clear();
|
||||
jump = null;
|
||||
returnValue = null;
|
||||
executionException = null;
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.special;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
@@ -47,6 +48,7 @@ public class ActionEnd extends Action {
|
||||
|
||||
@Override
|
||||
public boolean execute(LocalDataArea lda) {
|
||||
lda.returnValue = Undefined.INSTANCE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,11 @@ package com.jpexs.decompiler.flash.action.swf5;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionScriptFunction;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.model.CallFunctionActionItem;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -47,6 +50,19 @@ public class ActionCallFunction extends Action {
|
||||
|
||||
@Override
|
||||
public boolean execute(LocalDataArea lda) {
|
||||
|
||||
String functionName = lda.popAsString();
|
||||
int numArgs = (int) (double) lda.popAsNumber();
|
||||
List<Object> args = new ArrayList<>();
|
||||
for (int i = 0; i < numArgs; i++) {
|
||||
args.add(lda.pop());
|
||||
}
|
||||
for (ActionScriptFunction f : lda.functions) {
|
||||
if (functionName.equals(f.getFunctionName())) {
|
||||
lda.stack.push(lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), Undefined.INSTANCE /*?*/));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ public class ActionCallMethod extends Action {
|
||||
args.add(lda.pop());
|
||||
}
|
||||
|
||||
lda.stack.push(((ActionScriptFunction) obj.getMember(methodName)).execute(obj, args));
|
||||
ActionScriptFunction f = (ActionScriptFunction) obj.getMember(methodName);
|
||||
|
||||
lda.stack.push(lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), obj));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ public class ActionNewMethod extends Action {
|
||||
args.add(lda.pop());
|
||||
}
|
||||
ActionScriptObject nobj = new ActionScriptObject();
|
||||
|
||||
((ActionScriptFunction) obj.getMember(methodName)).execute(nobj, args);
|
||||
ActionScriptFunction f = (ActionScriptFunction) obj.getMember(methodName);
|
||||
lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), nobj);
|
||||
lda.stack.push(nobj);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ActionNewObject extends Action {
|
||||
ActionScriptObject obj = new ActionScriptObject();
|
||||
//TODO:check type
|
||||
ActionScriptFunction constructor = (ActionScriptFunction) lda.stage.getMember(objectName);
|
||||
constructor.execute(obj, args);
|
||||
lda.stage.callFunction(constructor.getFunctionOffset(), constructor.getFunctionLength(), args, constructor.getFuncRegNames(), obj);
|
||||
lda.stack.push(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user