mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 09:20:45 +00:00
More documentation.
This commit is contained in:
@@ -30,6 +30,13 @@ public class AppResources {
|
||||
*/
|
||||
private static final ResourceBundle resourceBundle = ResourceBundle.getBundle("com.jpexs.decompiler.flash.locales.AppResources");
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AppResources() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a key
|
||||
*
|
||||
|
||||
@@ -131,6 +131,13 @@ public class ApplicationInfo {
|
||||
loadLibraryVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ApplicationInfo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads library version
|
||||
*/
|
||||
|
||||
@@ -43,4 +43,10 @@ public abstract class BaseLocalData {
|
||||
* Second pass data
|
||||
*/
|
||||
public SecondPassData secondPassData = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BaseLocalData() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BinarySWFBundle implements Bundle {
|
||||
* @param is Input stream
|
||||
* @param noCheck Do not check
|
||||
* @param searchMode Search mode
|
||||
* @throws IOException
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public BinarySWFBundle(InputStream is, boolean noCheck, SearchMode searchMode) throws IOException {
|
||||
search = new SWFSearch(new SwfHeaderStreamSearch(is), noCheck, searchMode);
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface Bundle {
|
||||
*
|
||||
* @param key Key
|
||||
* @return Openable file
|
||||
* @throws IOException
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public SeekableInputStream getOpenable(String key) throws IOException;
|
||||
|
||||
@@ -57,7 +57,7 @@ public interface Bundle {
|
||||
* Gets all openable files in the bundle.
|
||||
*
|
||||
* @return Map from key to seekable input stream
|
||||
* @throws IOException
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public Map<String, SeekableInputStream> getAll() throws IOException;
|
||||
|
||||
@@ -81,7 +81,7 @@ public interface Bundle {
|
||||
* @param key Key
|
||||
* @param is New input stream
|
||||
* @return True if the file was replaced, false otherwise
|
||||
* @throws IOException
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public boolean putOpenable(String key, InputStream is) throws IOException;
|
||||
}
|
||||
|
||||
@@ -74,11 +74,6 @@ public class ClassPath implements Serializable {
|
||||
return packageStr.add(className, namespaceSuffix).toRawString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash code
|
||||
*
|
||||
* @return Hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
@@ -88,12 +83,6 @@ public class ClassPath implements Serializable {
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equals
|
||||
*
|
||||
* @param obj
|
||||
* @return True if equals
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
||||
@@ -913,7 +913,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param arguments Local registers values
|
||||
* @param constants Constant pool
|
||||
* @return Result of the execution
|
||||
* @throws AVM2ExecutionException
|
||||
* @throws AVM2ExecutionException On execution error
|
||||
*/
|
||||
public Object execute(HashMap<Integer, Object> arguments, AVM2ConstantPool constants) throws AVM2ExecutionException {
|
||||
return execute(arguments, constants, null);
|
||||
@@ -926,7 +926,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param constants Constant pool
|
||||
* @param runtimeInfo Runtime information
|
||||
* @return Result of the execution
|
||||
* @throws AVM2ExecutionException
|
||||
* @throws AVM2ExecutionException On execution error
|
||||
*/
|
||||
public Object execute(HashMap<Integer, Object> arguments, AVM2ConstantPool constants, AVM2RuntimeInfo runtimeInfo) throws AVM2ExecutionException {
|
||||
int pos = 0;
|
||||
@@ -1095,7 +1095,7 @@ public class AVM2Code implements Cloneable {
|
||||
*
|
||||
* @param ais ABC input stream
|
||||
* @param body Method body
|
||||
* @throws IOException
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public AVM2Code(ABCInputStream ais, MethodBody body) throws IOException {
|
||||
Map<Long, AVM2Instruction> codeMap = new HashMap<>();
|
||||
@@ -1632,7 +1632,7 @@ public class AVM2Code implements Cloneable {
|
||||
*
|
||||
* @param address Address
|
||||
* @return Instruction or null if not found
|
||||
* @throws ConvertException
|
||||
* @throws ConvertException On convert error
|
||||
*/
|
||||
public AVM2Instruction adr2ins(long address) throws ConvertException {
|
||||
int pos = adr2pos(address, false);
|
||||
@@ -1649,7 +1649,7 @@ public class AVM2Code implements Cloneable {
|
||||
*
|
||||
* @param address Address
|
||||
* @return Position
|
||||
* @throws ConvertException
|
||||
* @throws ConvertException On convert error
|
||||
*/
|
||||
public int adr2pos(long address) throws ConvertException {
|
||||
return adr2pos(address, false);
|
||||
@@ -1661,7 +1661,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param address Address
|
||||
* @param nearest Whether to find nearest position
|
||||
* @return Position
|
||||
* @throws ConvertException
|
||||
* @throws ConvertException On convert error
|
||||
*/
|
||||
public int adr2pos(long address, boolean nearest) throws ConvertException {
|
||||
int ret = adr2posNoEx(address);
|
||||
@@ -1809,12 +1809,43 @@ public class AVM2Code implements Cloneable {
|
||||
*
|
||||
* @param addr Current address
|
||||
* @return New address
|
||||
* @throws ConvertException
|
||||
* @throws ConvertException On convert error
|
||||
*/
|
||||
public long getAddrThroughJumpAndDebugLine(long addr) throws ConvertException {
|
||||
return pos2adr(getIpThroughJumpAndDebugLine(adr2pos(addr, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to source output.
|
||||
* @param switchParts Switch parts
|
||||
* @param callStack Call stack
|
||||
* @param abcIndex ABC indexing
|
||||
* @param setLocalPosToGetLocalPos Set local position to get local position
|
||||
* @param thisHasDefaultToPrimitive Whether this has default to primitive
|
||||
* @param lineStartItem Line start item
|
||||
* @param path Path
|
||||
* @param part Part
|
||||
* @param processJumps Whether to process jumps
|
||||
* @param isStatic Whether is static
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param localRegs Local registers
|
||||
* @param stack Stack
|
||||
* @param scopeStack Scope stack
|
||||
* @param localScopeStack Local scope stack
|
||||
* @param abc ABC
|
||||
* @param body Method body
|
||||
* @param start Start
|
||||
* @param end End
|
||||
* @param localRegNames Local register names
|
||||
* @param localRegTypes Local register types
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @param visited Visited
|
||||
* @param localRegAssigmentIps Local register assignment IPs
|
||||
* @return Convert output
|
||||
* @throws ConvertException On convert error
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public ConvertOutput toSourceOutput(Set<GraphPart> switchParts, List<MethodBody> callStack, AbcIndexing abcIndex, Map<Integer, Set<Integer>> setLocalPosToGetLocalPos, boolean thisHasDefaultToPrimitive, Reference<GraphSourceItem> lineStartItem, String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ScopeStack localScopeStack, ABC abc, MethodBody body, int start, int end, HashMap<Integer, String> localRegNames, HashMap<Integer, GraphTargetItem> localRegTypes, List<DottedChain> fullyQualifiedNames, boolean[] visited, HashMap<Integer, Integer> localRegAssigmentIps) throws ConvertException, InterruptedException {
|
||||
boolean debugMode = DEBUG_MODE;
|
||||
if (debugMode) {
|
||||
@@ -2474,7 +2505,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param staticOperation Static operation
|
||||
* @param localRegAssigmentIps Local register assignment IPs
|
||||
* @return List of GraphTargetItems
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public List<GraphTargetItem> toGraphTargetItems(List<MethodBody> callStack, AbcIndexing abcIndex, boolean thisHasDefaultToPrimitive, ConvertData convertData, String path, int methodIndex, boolean isStatic, int scriptIndex, int classIndex, ABC abc, MethodBody body, HashMap<Integer, String> localRegNames, ScopeStack scopeStack, int initializerType, List<DottedChain> fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps) throws InterruptedException {
|
||||
initToSource();
|
||||
@@ -2755,7 +2786,7 @@ public class AVM2Code implements Cloneable {
|
||||
*
|
||||
* @param path Path
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public void fixJumps(final String path, MethodBody body) throws InterruptedException {
|
||||
if (code.isEmpty()) {
|
||||
@@ -3014,7 +3045,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param isStatic True if static
|
||||
* @param path Path
|
||||
* @return 1
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public int removeTraps(Trait trait, int methodInfo, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException {
|
||||
SWFDecompilerPlugin.fireAvm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body);
|
||||
@@ -3243,7 +3274,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param ip Position
|
||||
* @param lastIp Last position
|
||||
* @param refs Map from position to list of references
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private void visitCode(int ip, int lastIp, HashMap<Integer, List<Integer>> refs) throws InterruptedException {
|
||||
Queue<Integer> toVisit = new LinkedList<>();
|
||||
@@ -3312,7 +3343,7 @@ public class AVM2Code implements Cloneable {
|
||||
*
|
||||
* @param body Method body
|
||||
* @return Map from position to list of references
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public HashMap<Integer, List<Integer>> visitCode(MethodBody body) throws InterruptedException {
|
||||
HashMap<Integer, List<Integer>> refs = new HashMap<>();
|
||||
@@ -3334,7 +3365,7 @@ public class AVM2Code implements Cloneable {
|
||||
* Remove instructions that are marked as ignored.
|
||||
*
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public void removeIgnored(MethodBody body) throws InterruptedException {
|
||||
//System.err.println("removing ignored...");
|
||||
@@ -3352,7 +3383,7 @@ public class AVM2Code implements Cloneable {
|
||||
*
|
||||
* @param body Method body
|
||||
* @return Number of removed instructions
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public int removeDeadCode(MethodBody body) throws InterruptedException {
|
||||
return removeDeadCode(body, new Reference<>(-1));
|
||||
@@ -3365,7 +3396,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param minChangedIpRef Minimum changed instruction position (as
|
||||
* reference)
|
||||
* @return Number of removed instructions
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public int removeDeadCode(MethodBody body, Reference<Integer> minChangedIpRef) throws InterruptedException {
|
||||
HashMap<Integer, List<Integer>> refs = visitCode(body);
|
||||
|
||||
@@ -588,9 +588,9 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
* Converts kind MULTINAME with one namespace to QNAME with that namespace
|
||||
* (must exist in the abc). Ignores others.
|
||||
*
|
||||
* @param cpool
|
||||
* @param index MULTINAME index
|
||||
* @return QNAME index
|
||||
* @param cpool Constant pool
|
||||
* @param index Multiname index
|
||||
* @return QName index
|
||||
*/
|
||||
public int convertToQname(AVM2ConstantPool cpool, int index) {
|
||||
Multiname mx = cpool.getMultiname(index);
|
||||
@@ -859,6 +859,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
* @param kind Kind
|
||||
* @param name Name
|
||||
* @param index Sub index
|
||||
* @param add Whether to add the namespace if it does not exist
|
||||
* @return Namespace id
|
||||
*/
|
||||
public int getNamespaceId(int kind, DottedChain name, int index, boolean add) {
|
||||
|
||||
@@ -23,5 +23,12 @@ package com.jpexs.decompiler.flash.abc.avm2;
|
||||
*/
|
||||
public enum AVM2Runtime {
|
||||
|
||||
UNKNOWN, ADOBE_FLASH
|
||||
/**
|
||||
* Unknown
|
||||
*/
|
||||
UNKNOWN,
|
||||
/**
|
||||
* Adobe Flash
|
||||
*/
|
||||
ADOBE_FLASH
|
||||
}
|
||||
|
||||
+10
-5
@@ -36,7 +36,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerAdapter;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.NotCompileTimeItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
@@ -70,6 +69,12 @@ public class AVM2DeobfuscatorGetSet extends SWFDecompilerAdapter {
|
||||
*/
|
||||
private final int executionLimit = 30000;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorGetSet() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove obfuscation get sets
|
||||
*
|
||||
@@ -80,7 +85,7 @@ public class AVM2DeobfuscatorGetSet extends SWFDecompilerAdapter {
|
||||
* @param body Method body
|
||||
* @param inlineIns Inline instructions
|
||||
* @return True if removed
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected boolean removeObfuscationGetSets(int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, List<AVM2Instruction> inlineIns) throws InterruptedException {
|
||||
AVM2Code code = body.getCode();
|
||||
@@ -124,7 +129,7 @@ public class AVM2DeobfuscatorGetSet extends SWFDecompilerAdapter {
|
||||
*
|
||||
* @param code AVM2 code
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected void removeUnreachableInstructions(AVM2Code code, MethodBody body) throws InterruptedException {
|
||||
code.removeDeadCode(body);
|
||||
@@ -186,7 +191,7 @@ public class AVM2DeobfuscatorGetSet extends SWFDecompilerAdapter {
|
||||
* @param localData AVM2 local data
|
||||
* @param idx Index
|
||||
* @param endIdx End index
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private void executeInstructions(MethodBody body, AVM2Code code, AVM2LocalData localData, int idx, int endIdx) throws InterruptedException {
|
||||
List<GraphTargetItem> output = new ArrayList<>();
|
||||
@@ -283,7 +288,7 @@ public class AVM2DeobfuscatorGetSet extends SWFDecompilerAdapter {
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
|
||||
+9
-1
@@ -36,6 +36,14 @@ import java.util.Map;
|
||||
*/
|
||||
public class AVM2DeobfuscatorGroupParts extends SWFDecompilerAdapter {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorGroupParts() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
blk_1
|
||||
jump A
|
||||
@@ -112,7 +120,7 @@ C: blk_4
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
|
||||
+8
-1
@@ -36,6 +36,13 @@ import java.util.Map;
|
||||
*/
|
||||
public class AVM2DeobfuscatorJumps extends SWFDecompilerAdapter {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorJumps() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes jumps/ifs targeting other jumps.
|
||||
*
|
||||
@@ -47,7 +54,7 @@ public class AVM2DeobfuscatorJumps extends SWFDecompilerAdapter {
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
|
||||
+12
-4
@@ -63,6 +63,14 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorRegisters() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets registers used in the code.
|
||||
*
|
||||
@@ -104,7 +112,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
@@ -186,7 +194,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
* @param trait Trait
|
||||
* @param minfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private void replaceSingleUseRegisters(Map<Integer, GraphTargetItem> singleRegisters, List<AVM2Instruction> setInss, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException {
|
||||
AVM2Code code = body.getCode();
|
||||
@@ -224,7 +232,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
* @param ignoredRegisters Ignored registers
|
||||
* @param ignoredGets Ignored gets
|
||||
* @return first register id
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private int getFirstRegisterSetter(Reference<AVM2Instruction> assignment, MethodBody body, ABC abc, Set<Integer> ignoredRegisters, Set<Integer> ignoredGets) throws InterruptedException {
|
||||
AVM2Code code = body.getCode();
|
||||
@@ -250,7 +258,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
* @param ignored Ignored
|
||||
* @param ignoredGets Ignored gets
|
||||
* @return Register id
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private int visitCode(Reference<AVM2Instruction> assignment, Set<Integer> visited, Stack<Object> stack, MethodBody body, ABC abc, AVM2Code code, int idx, int endIdx, Set<Integer> ignored, Set<Integer> ignoredGets) throws InterruptedException {
|
||||
LocalDataArea localData = new LocalDataArea();
|
||||
|
||||
+11
-3
@@ -60,6 +60,14 @@ import java.util.Set;
|
||||
*/
|
||||
public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorRegistersOld() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all register ids.
|
||||
*
|
||||
@@ -101,7 +109,7 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
@@ -182,7 +190,7 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
* @param ignoredRegisters Ignored registers
|
||||
* @param ignoredGets Ignored gets
|
||||
* @return Register id
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private int getFirstRegisterSetter(Reference<AVM2Instruction> assignment, int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, Set<Integer> ignoredRegisters, Set<Integer> ignoredGets) throws InterruptedException {
|
||||
AVM2Code code = body.getCode();
|
||||
@@ -257,7 +265,7 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
* @param ignored Ignored
|
||||
* @param ignoredGets Ignored gets
|
||||
* @return Register id
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private int visitCode(Reference<AVM2Instruction> assignment, Set<Integer> visited, TranslateStack stack, int classIndex, boolean isStatic, MethodBody body, int scriptIndex, ABC abc, AVM2Code code, int idx, int endIdx, Set<Integer> ignored, Set<Integer> ignoredGets) throws InterruptedException {
|
||||
|
||||
|
||||
+10
-3
@@ -95,6 +95,13 @@ public class AVM2DeobfuscatorSimple extends AVM2DeobfuscatorZeroJumpsNullPushes
|
||||
*/
|
||||
private final int executionLimit = 30000;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorSimple() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes obfuscation ifs.
|
||||
*
|
||||
@@ -105,7 +112,7 @@ public class AVM2DeobfuscatorSimple extends AVM2DeobfuscatorZeroJumpsNullPushes
|
||||
* @param body Method body
|
||||
* @param inlineIns Inline instruction
|
||||
* @return True if code was modified
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected boolean removeObfuscationIfs(int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, AVM2Instruction inlineIns) throws InterruptedException {
|
||||
AVM2Code code = body.getCode();
|
||||
@@ -174,7 +181,7 @@ public class AVM2DeobfuscatorSimple extends AVM2DeobfuscatorZeroJumpsNullPushes
|
||||
* @param result Execution result
|
||||
* @param inlineIns Inline instruction
|
||||
* @return True if code was modified
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private boolean executeInstructions(Map<Integer, Object> staticRegs, MethodBody body, ABC abc, AVM2Code code, LocalDataArea localData, int idx, int endIdx, ExecutionResult result, AVM2Instruction inlineIns) throws InterruptedException {
|
||||
int instructionsProcessed = 0;
|
||||
@@ -398,7 +405,7 @@ public class AVM2DeobfuscatorSimple extends AVM2DeobfuscatorZeroJumpsNullPushes
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
|
||||
+10
-4
@@ -93,7 +93,6 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.NotCompileTimeItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
@@ -130,6 +129,13 @@ public class AVM2DeobfuscatorSimpleOld extends AVM2DeobfuscatorZeroJumpsNullPush
|
||||
*/
|
||||
private final int executionLimit = 30000;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorSimpleOld() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a push instruction from a graph target item.
|
||||
*
|
||||
@@ -170,7 +176,7 @@ public class AVM2DeobfuscatorSimpleOld extends AVM2DeobfuscatorZeroJumpsNullPush
|
||||
* @param body Method body
|
||||
* @param inlineIns Inline instructions
|
||||
* @return True if removed, false otherwise
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected boolean removeObfuscationIfs(int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, List<AVM2Instruction> inlineIns) throws InterruptedException {
|
||||
AVM2Code code = body.getCode();
|
||||
@@ -289,7 +295,7 @@ public class AVM2DeobfuscatorSimpleOld extends AVM2DeobfuscatorZeroJumpsNullPush
|
||||
* @param jumpTargets Jump targets
|
||||
* @param minChangedIpRef Minimal changed IP reference
|
||||
* @return True if executed, false otherwise
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private boolean executeInstructions(Set<Long> importantOffsets, Map<Integer, GraphTargetItem> staticRegs, MethodBody body, ABC abc, AVM2Code code, AVM2LocalData localData, int idx, int endIdx, ExecutionResult result, List<AVM2Instruction> inlineIns, List<Integer> jumpTargets, Reference<Integer> minChangedIpRef) throws InterruptedException {
|
||||
List<GraphTargetItem> output = new ArrayList<>();
|
||||
@@ -611,7 +617,7 @@ public class AVM2DeobfuscatorSimpleOld extends AVM2DeobfuscatorZeroJumpsNullPush
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
|
||||
+11
-4
@@ -47,13 +47,20 @@ import java.util.Set;
|
||||
*/
|
||||
public class AVM2DeobfuscatorZeroJumpsNullPushes extends SWFDecompilerAdapter {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AVM2DeobfuscatorZeroJumpsNullPushes() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes zero jumps from the code.
|
||||
*
|
||||
* @param code AVM2 code
|
||||
* @param body Method body
|
||||
* @return True if any zero jumps were removed
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected boolean removeZeroJumps(AVM2Code code, MethodBody body) throws InterruptedException {
|
||||
return removeZeroJumps(code, body, new Reference<>(-1));
|
||||
@@ -67,7 +74,7 @@ public class AVM2DeobfuscatorZeroJumpsNullPushes extends SWFDecompilerAdapter {
|
||||
* @param minChangedIpRef Reference to the minimum changed instruction
|
||||
* pointer
|
||||
* @return True if any zero jumps were removed
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected boolean removeZeroJumps(AVM2Code code, MethodBody body, Reference<Integer> minChangedIpRef) throws InterruptedException {
|
||||
boolean result = false;
|
||||
@@ -119,7 +126,7 @@ public class AVM2DeobfuscatorZeroJumpsNullPushes extends SWFDecompilerAdapter {
|
||||
* @param code AVM2 code
|
||||
* @param body Method body
|
||||
* @return True if any null pushes were removed
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected boolean removeNullPushes(AVM2Code code, MethodBody body) throws InterruptedException {
|
||||
boolean result = false;
|
||||
@@ -180,7 +187,7 @@ public class AVM2DeobfuscatorZeroJumpsNullPushes extends SWFDecompilerAdapter {
|
||||
* @param trait Trait
|
||||
* @param methodInfo Method info
|
||||
* @param body Method body
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class AVM2ExecutionException extends Exception {
|
||||
/**
|
||||
* Constructs new AVM2ExecutionException with the specified detail message.
|
||||
*
|
||||
* @param message
|
||||
* @param message The detail message
|
||||
*/
|
||||
public AVM2ExecutionException(String message) {
|
||||
super(message);
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ public class AVM2InstructionItem {
|
||||
/**
|
||||
* Set container last instructions.
|
||||
*
|
||||
* @param lastInstructions
|
||||
* @param lastInstructions List of instruction items
|
||||
*/
|
||||
public void setContainerLastInstructions(List<AVM2InstructionItem> lastInstructions) {
|
||||
removeContainerLastInstructions();
|
||||
|
||||
@@ -239,7 +239,7 @@ public class AVM2Graph extends Graph {
|
||||
* @param path Path
|
||||
* @param allParts All parts
|
||||
* @param throwStates Throw states
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
protected void beforeGetLoops(BaseLocalData localData, String path, Set<GraphPart> allParts, List<ThrowState> throwStates) throws InterruptedException {
|
||||
@@ -276,7 +276,7 @@ public class AVM2Graph extends Graph {
|
||||
* @param localData Local data
|
||||
* @param path Path
|
||||
* @param allParts All parts
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
protected void afterGetLoops(BaseLocalData localData, String path, Set<GraphPart> allParts) throws InterruptedException {
|
||||
@@ -288,7 +288,7 @@ public class AVM2Graph extends Graph {
|
||||
*
|
||||
* @param localData Local data
|
||||
* @param allParts All parts
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private void getIgnoredSwitches(AVM2LocalData localData, Set<GraphPart> allParts) throws InterruptedException {
|
||||
|
||||
@@ -736,7 +736,7 @@ public class AVM2Graph extends Graph {
|
||||
* @param localRegAssigmentIps Local register assignment IPs
|
||||
* @param thisHasDefaultToPrimitive This has default to primitive
|
||||
* @return List of graph target items
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public static List<GraphTargetItem> translateViaGraph(SecondPassData secondPassData, List<MethodBody> callStack, AbcIndexing abcIndex, String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, HashMap<Integer, String> localRegNames, HashMap<Integer, GraphTargetItem> localRegTypes, List<DottedChain> fullyQualifiedNames, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, boolean thisHasDefaultToPrimitive) throws InterruptedException {
|
||||
ScopeStack localScopeStack = new ScopeStack();
|
||||
@@ -1086,7 +1086,7 @@ public class AVM2Graph extends Graph {
|
||||
* @param path Path
|
||||
* @param recursionLevel Recursion level
|
||||
* @return True if try is found
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private boolean checkTry(List<GraphTargetItem> currentRet, List<GotoItem> foundGotos, Map<GraphPart, List<GraphTargetItem>> partCodes, Map<GraphPart, Integer> partCodePos, Set<GraphPart> visited, AVM2LocalData localData, GraphPart part, List<GraphPart> stopPart, List<StopPartKind> stopPartKind, List<Loop> loops, List<ThrowState> throwStates, Set<GraphPart> allParts, TranslateStack stack, int staticOperation, String path, int recursionLevel) throws InterruptedException {
|
||||
if (localData.parsedExceptions == null) {
|
||||
@@ -1647,7 +1647,7 @@ public class AVM2Graph extends Graph {
|
||||
* @param path Path
|
||||
* @param recursionLevel Recursion level
|
||||
* @return True to stop processing. False to continue.
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkPartOutput(List<GraphTargetItem> currentRet, List<GotoItem> foundGotos,
|
||||
@@ -1689,7 +1689,7 @@ public class AVM2Graph extends Graph {
|
||||
* @param path Path
|
||||
* @return List of GraphTargetItems to replace current output and stop
|
||||
* further processing. Null to continue.
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
protected List<GraphTargetItem> check(List<GraphTargetItem> currentRet, List<GotoItem> foundGotos,
|
||||
@@ -2421,7 +2421,7 @@ public class AVM2Graph extends Graph {
|
||||
* @param level Level
|
||||
* @param localData Local data
|
||||
* @param path Path
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
@@ -2775,14 +2775,6 @@ public class AVM2Graph extends Graph {
|
||||
super.finalProcess(list, level, localData, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets data for final process.
|
||||
*
|
||||
* @param localData
|
||||
* @param loops
|
||||
* @param throwStates
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected FinalProcessLocalData getFinalData(BaseLocalData localData, List<Loop> loops, List<ThrowState> throwStates) {
|
||||
FinalProcessLocalData finalProcess = new AVM2FinalProcessLocalData(loops, ((AVM2LocalData) localData).localRegNames, ((AVM2LocalData) localData).setLocalPosToGetLocalPos);
|
||||
@@ -2790,12 +2782,6 @@ public class AVM2Graph extends Graph {
|
||||
return finalProcess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares local data for branch.
|
||||
*
|
||||
* @param localData Local data
|
||||
* @return Local data for a branch
|
||||
*/
|
||||
@Override
|
||||
public AVM2LocalData prepareBranchLocalData(BaseLocalData localData) {
|
||||
AVM2LocalData aLocalData = (AVM2LocalData) localData;
|
||||
|
||||
@@ -197,7 +197,7 @@ public class AVM2GraphSource extends GraphSource {
|
||||
* @param staticOperation Unused
|
||||
* @param path Path
|
||||
* @return List of graph target items
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public List<GraphTargetItem> translatePart(Graph graph, GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
|
||||
|
||||
+1
-1
@@ -586,7 +586,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
|
||||
* @param output Output list
|
||||
* @param staticOperation Unused
|
||||
* @param path Path
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
public void translate(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, int staticOperation, String path) throws InterruptedException {
|
||||
|
||||
+24
@@ -22,12 +22,36 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum AVM2InstructionFlag {
|
||||
/**
|
||||
* Undocumented instruction
|
||||
*/
|
||||
UNDOCUMENTED,
|
||||
/**
|
||||
* The stack handling is unknown
|
||||
*/
|
||||
UNKNOWN_STACK,
|
||||
/**
|
||||
* Requires ES4 numerics minor version
|
||||
*/
|
||||
ES4_NUMERICS_MINOR,
|
||||
/**
|
||||
* Requires Float major version
|
||||
*/
|
||||
FLOAT_MAJOR,
|
||||
/**
|
||||
* Operands are unknown
|
||||
*/
|
||||
UNKNOWN_OPERANDS,
|
||||
/**
|
||||
* Do not work in standard flash player
|
||||
*/
|
||||
NO_FLASH_PLAYER,
|
||||
/**
|
||||
* Deprecated instruction
|
||||
*/
|
||||
DEPRECATED,
|
||||
/**
|
||||
* Works with domain memory
|
||||
*/
|
||||
DOMAIN_MEMORY
|
||||
}
|
||||
|
||||
+637
File diff suppressed because it is too large
Load Diff
+3
@@ -25,5 +25,8 @@ import com.jpexs.decompiler.graph.DottedChain;
|
||||
*/
|
||||
public interface AlchemyTypeIns {
|
||||
|
||||
/**
|
||||
* Alchemy package name
|
||||
*/
|
||||
public static final DottedChain ALCHEMY_PACKAGE = new DottedChain(new String[]{"avm2", "intrinsics", "memory"});
|
||||
}
|
||||
|
||||
+4
@@ -64,6 +64,10 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target type
|
||||
* @return Target type
|
||||
*/
|
||||
public String getTargetType() {
|
||||
return "*";
|
||||
}
|
||||
|
||||
@@ -37,8 +37,14 @@ import java.util.Objects;
|
||||
*/
|
||||
public class ApplyTypeAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Object
|
||||
*/
|
||||
public GraphTargetItem object;
|
||||
|
||||
/**
|
||||
* Parameters
|
||||
*/
|
||||
public List<GraphTargetItem> params;
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,6 +61,12 @@ import java.util.Stack;
|
||||
*/
|
||||
public class ASM3Parser {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ASM3Parser() {
|
||||
}
|
||||
|
||||
private static class OffsetItem {
|
||||
|
||||
public String label = "";
|
||||
@@ -211,6 +217,16 @@ public class ASM3Parser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a class.
|
||||
* @param abc ABC
|
||||
* @param reader Reader
|
||||
* @param constants Constant pool
|
||||
* @param tc Trait class
|
||||
* @return True if parsed successfully
|
||||
* @throws IOException On I/O error
|
||||
* @throws AVM2ParseException On parse error
|
||||
*/
|
||||
public static boolean parseClass(ABC abc, Reader reader, AVM2ConstantPool constants, TraitClass tc) throws IOException, AVM2ParseException {
|
||||
Flasm3Lexer lexer = new Flasm3Lexer(reader);
|
||||
return parseClass(abc, lexer, constants, tc);
|
||||
@@ -326,6 +342,16 @@ public class ASM3Parser {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a slot or const.
|
||||
* @param abc ABC
|
||||
* @param reader Reader
|
||||
* @param constants Constant pool
|
||||
* @param tsc Trait slot/const
|
||||
* @return True if parsed successfully
|
||||
* @throws IOException On I/O error
|
||||
* @throws AVM2ParseException On parse error
|
||||
*/
|
||||
public static boolean parseSlotConst(ABC abc, Reader reader, AVM2ConstantPool constants, TraitSlotConst tsc) throws IOException, AVM2ParseException {
|
||||
Flasm3Lexer lexer = new Flasm3Lexer(reader);
|
||||
return parseSlotConst(abc, lexer, constants, tsc);
|
||||
@@ -579,6 +605,14 @@ public class ASM3Parser {
|
||||
return constants.getMultinameId(multiname, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses value.
|
||||
* @param constants Constant pool
|
||||
* @param lexer Lexer
|
||||
* @return Value kind
|
||||
* @throws IOException On I/O error
|
||||
* @throws AVM2ParseException On parse error
|
||||
*/
|
||||
public static ValueKind parseValue(AVM2ConstantPool constants, Flasm3Lexer lexer) throws IOException, AVM2ParseException {
|
||||
ParsedSymbol type = lexer.lex();
|
||||
ParsedSymbol value;
|
||||
@@ -735,10 +769,35 @@ public class ASM3Parser {
|
||||
return new ValueKind(value_index, value_kind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses code.
|
||||
* @param abc ABC
|
||||
* @param reader Reader
|
||||
* @param trait Trait
|
||||
* @param body Method body
|
||||
* @param info Method info
|
||||
* @return AVM2 code
|
||||
* @throws IOException On I/O error
|
||||
* @throws AVM2ParseException On parse error
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public static AVM2Code parse(ABC abc, Reader reader, Trait trait, MethodBody body, MethodInfo info) throws IOException, AVM2ParseException, InterruptedException {
|
||||
return parse(abc, reader, trait, null, body, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses code.
|
||||
* @param abc ABC
|
||||
* @param reader Reader
|
||||
* @param trait Trait
|
||||
* @param missingHandler Missing symbol handler
|
||||
* @param body Method body
|
||||
* @param info Method info
|
||||
* @return AVM2 code
|
||||
* @throws IOException On I/O error
|
||||
* @throws AVM2ParseException On parse error
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
public static AVM2Code parse(ABC abc, Reader reader, Trait trait, MissingSymbolHandler missingHandler, MethodBody body, MethodInfo info) throws IOException, AVM2ParseException, InterruptedException {
|
||||
AVM2ConstantPool constants = abc.constants;
|
||||
AVM2Code code = new AVM2Code();
|
||||
|
||||
+314
@@ -23,210 +23,524 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.pcode;
|
||||
*/
|
||||
public class ParsedSymbol {
|
||||
|
||||
/**
|
||||
* Position
|
||||
*/
|
||||
public int pos;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public int type;
|
||||
|
||||
/**
|
||||
* Value
|
||||
*/
|
||||
public Object value;
|
||||
|
||||
/**
|
||||
* Type: String
|
||||
*/
|
||||
public static final int TYPE_STRING = 1;
|
||||
|
||||
/**
|
||||
* Type: Multiname
|
||||
*/
|
||||
public static final int TYPE_MULTINAME = 2;
|
||||
|
||||
/**
|
||||
* Type: Instruction name
|
||||
*/
|
||||
public static final int TYPE_INSTRUCTION_NAME = 3;
|
||||
|
||||
/**
|
||||
* Type: Integer
|
||||
*/
|
||||
public static final int TYPE_INTEGER = 4;
|
||||
|
||||
/**
|
||||
* Type: Float
|
||||
*/
|
||||
public static final int TYPE_FLOAT = 5;
|
||||
|
||||
/**
|
||||
* Type: Identifier
|
||||
*/
|
||||
public static final int TYPE_IDENTIFIER = 6;
|
||||
|
||||
/**
|
||||
* Type: End of file
|
||||
*/
|
||||
public static final int TYPE_EOF = 7;
|
||||
|
||||
/**
|
||||
* Type: Label
|
||||
*/
|
||||
public static final int TYPE_LABEL = 8;
|
||||
|
||||
/**
|
||||
* Type: Comment
|
||||
*/
|
||||
public static final int TYPE_COMMENT = 9;
|
||||
|
||||
/**
|
||||
* Type: Exception start
|
||||
*/
|
||||
public static final int TYPE_EXCEPTION_START = 10;
|
||||
|
||||
/**
|
||||
* Type: Exception end
|
||||
*/
|
||||
public static final int TYPE_EXCEPTION_END = 11;
|
||||
|
||||
/**
|
||||
* Type: Exception target
|
||||
*/
|
||||
public static final int TYPE_EXCEPTION_TARGET = 12;
|
||||
|
||||
/**
|
||||
* Type: Keyword QName
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_QNAME = 13;
|
||||
|
||||
/**
|
||||
* Type: Keyword QNameA
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_QNAMEA = 14;
|
||||
|
||||
/**
|
||||
* Type: Keyword RTQName
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_RTQNAME = 15;
|
||||
|
||||
/**
|
||||
* Type: Keyword RTQNameA
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_RTQNAMEA = 16;
|
||||
|
||||
/**
|
||||
* Type: Keyword RTQNameL
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_RTQNAMEL = 17;
|
||||
|
||||
/**
|
||||
* Type: Keyword RTQNameLA
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_RTQNAMELA = 18;
|
||||
|
||||
/**
|
||||
* Type: Keyword Multiname
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_MULTINAME = 19;
|
||||
|
||||
/**
|
||||
* Type: Keyword MultinameA
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_MULTINAMEA = 20;
|
||||
|
||||
/**
|
||||
* Type: Keyword MultinameL
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_MULTINAMEL = 21;
|
||||
|
||||
/**
|
||||
* Type: Keyword MultinameLA
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_MULTINAMELA = 22;
|
||||
|
||||
/**
|
||||
* Type: Keyword Typename
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_TYPENAME = 23;
|
||||
|
||||
/**
|
||||
* Type: Parent open
|
||||
*/
|
||||
public static final int TYPE_PARENT_OPEN = 24;
|
||||
|
||||
/**
|
||||
* Type: Parent close
|
||||
*/
|
||||
public static final int TYPE_PARENT_CLOSE = 25;
|
||||
|
||||
/**
|
||||
* Type: Comma
|
||||
*/
|
||||
public static final int TYPE_COMMA = 26;
|
||||
|
||||
/**
|
||||
* Type: Keyword null
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NULL = 27;
|
||||
|
||||
/**
|
||||
* Type: Bracket open
|
||||
*/
|
||||
public static final int TYPE_BRACKET_OPEN = 28;
|
||||
|
||||
/**
|
||||
* Type: Bracket close
|
||||
*/
|
||||
public static final int TYPE_BRACKET_CLOSE = 29;
|
||||
|
||||
/**
|
||||
* Type: Lower than
|
||||
*/
|
||||
public static final int TYPE_LOWERTHAN = 30;
|
||||
|
||||
/**
|
||||
* Type: Greater than
|
||||
*/
|
||||
public static final int TYPE_GREATERTHAN = 31;
|
||||
|
||||
/**
|
||||
* Type: Keyword Namespace
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NAMESPACE = 32;
|
||||
|
||||
/**
|
||||
* Type: Keyword PrivateNamespace
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PRIVATENAMESPACE = 33;
|
||||
|
||||
/**
|
||||
* Type: Keyword PackageNamespace
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PACKAGENAMESPACE = 34;
|
||||
|
||||
/**
|
||||
* Type: Keyword PackageInternalNs
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PACKAGEINTERNALNS = 35;
|
||||
|
||||
/**
|
||||
* Type: Keyword ProtectedNamespace
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PROTECTEDNAMESPACE = 36;
|
||||
|
||||
/**
|
||||
* Type: Keyword ExplicitNamespace
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_EXPLICITNAMESPACE = 37;
|
||||
|
||||
/**
|
||||
* Type: Keyword StaticProtectedNs
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_STATICPROTECTEDNS = 38;
|
||||
|
||||
/**
|
||||
* Type: Keyword try
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_TRY = 39;
|
||||
|
||||
/**
|
||||
* Type: Keyword from
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_FROM = 40;
|
||||
|
||||
/**
|
||||
* Type: Keyword to
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_TO = 41;
|
||||
|
||||
/**
|
||||
* Type: Keyword target
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_TARGET = 42;
|
||||
|
||||
/**
|
||||
* Type: Keyword type
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_TYPE = 43;
|
||||
|
||||
/**
|
||||
* Type: Keyword name
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NAME = 44;
|
||||
|
||||
/**
|
||||
* Type: Keyword flag
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_FLAG = 45;
|
||||
|
||||
/**
|
||||
* Type: Keyword NATIVE
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NATIVE = 46;
|
||||
|
||||
/**
|
||||
* Type: Keyword HAS_OPTIONAL
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_HAS_OPTIONAL = 47;
|
||||
|
||||
/**
|
||||
* Type: Keyword HAS_PARAM_NAMES
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_HAS_PARAM_NAMES = 48;
|
||||
|
||||
/**
|
||||
* Type: Keyword IGNORE_REST
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_IGNORE_REST = 49;
|
||||
|
||||
/**
|
||||
* Type: Keyword NEED_ACTIVATION
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NEED_ACTIVATION = 50;
|
||||
|
||||
/**
|
||||
* Type: Keyword NEED_ARGUMENTS
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NEED_ARGUMENTS = 51;
|
||||
|
||||
/**
|
||||
* Type: Keyword NEED_REST
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NEED_REST = 52;
|
||||
|
||||
|
||||
/**
|
||||
* Type: Keyword SET_DXNS
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_SET_DXNS = 53;
|
||||
|
||||
/**
|
||||
* Type: Keyword param
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PARAM = 54;
|
||||
|
||||
/**
|
||||
* Type: Keyword paramname
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PARAMNAME = 55;
|
||||
|
||||
/**
|
||||
* Type: Keyword optional
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_OPTIONAL = 56;
|
||||
|
||||
/**
|
||||
* Type: Keyword returns
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_RETURNS = 57;
|
||||
|
||||
/**
|
||||
* Type: Keyword body
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_BODY = 58;
|
||||
|
||||
/**
|
||||
* Type: Keyword maxstack
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_MAXSTACK = 59;
|
||||
|
||||
/**
|
||||
* Type: Keyword localcount
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_LOCALCOUNT = 60;
|
||||
|
||||
/**
|
||||
* Type: Keyword initscopedepth
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_INITSCOPEDEPTH = 61;
|
||||
|
||||
/**
|
||||
* Type: Keyword maxscopedepth
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_MAXSCOPEDEPTH = 62;
|
||||
|
||||
/**
|
||||
* Type: Keyword code
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_CODE = 63;
|
||||
|
||||
/**
|
||||
* Type: Keyword Integer
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_INTEGER = 64;
|
||||
|
||||
/**
|
||||
* Type: Keyword UInteger
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_UINTEGER = 65;
|
||||
|
||||
/**
|
||||
* Type: Keyword Double
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_DOUBLE = 66;
|
||||
|
||||
/**
|
||||
* Type: Keyword Decimal
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_DECIMAL = 67;
|
||||
|
||||
/**
|
||||
* Type: Keyword Utf8
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_UTF8 = 68;
|
||||
|
||||
/**
|
||||
* Type: Keyword True
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_TRUE = 69;
|
||||
|
||||
/**
|
||||
* Type: Keyword False
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_FALSE = 70;
|
||||
|
||||
/**
|
||||
* Type: Keyword Void
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_VOID = 71;
|
||||
|
||||
/**
|
||||
* Type: Keyword trait
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_TRAIT = 72;
|
||||
|
||||
/**
|
||||
* Type: Keyword slot
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_SLOT = 73;
|
||||
|
||||
/**
|
||||
* Type: Keyword const
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_CONST = 74;
|
||||
|
||||
/**
|
||||
* Type: Keyword method
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_METHOD = 75;
|
||||
|
||||
/**
|
||||
* Type: Keyword getter
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_GETTER = 76;
|
||||
|
||||
/**
|
||||
* Type: Keyword setter
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_SETTER = 77;
|
||||
|
||||
/**
|
||||
* Type: Keyword class
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_CLASS = 78;
|
||||
|
||||
/**
|
||||
* Type: Keyword function
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_FUNCTION = 79;
|
||||
|
||||
/**
|
||||
* Type: Keyword disp_id
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_DISPID = 80;
|
||||
|
||||
/**
|
||||
* Type: Keyword slot_id
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_SLOTID = 81;
|
||||
|
||||
/**
|
||||
* Type: Keyword value
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_VALUE = 82;
|
||||
|
||||
/**
|
||||
* Type: Keyword FINAL
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_FINAL = 83;
|
||||
|
||||
/**
|
||||
* Type: Keyword METADATA
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_METADATA = 84;
|
||||
|
||||
/**
|
||||
* Type: Keyword OVERRIDE
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_OVERRIDE = 85;
|
||||
|
||||
/**
|
||||
* Type: Keyword metadata
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_METADATA_BLOCK = 86;
|
||||
|
||||
/**
|
||||
* Type: Keyword item
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_ITEM = 87;
|
||||
|
||||
/**
|
||||
* Type: Keyword end
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_END = 88;
|
||||
|
||||
/**
|
||||
* Type: Keyword Unknown
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_UNKNOWN = 89;
|
||||
|
||||
/**
|
||||
* Type: Keyword SEALED
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_SEALED = 90;
|
||||
|
||||
/**
|
||||
* Type: Keyword INTERFACE
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_INTERFACE = 91;
|
||||
|
||||
/**
|
||||
* Type: Keyword PROTECTEDNS
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PROTECTEDNS = 92;
|
||||
|
||||
/**
|
||||
* Type: Keyword NON_NULLABLE
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_NON_NULLABLE = 93;
|
||||
|
||||
/**
|
||||
* Type: Keyword instance
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_INSTANCE = 94;
|
||||
|
||||
/**
|
||||
* Type: Keyword extends
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_EXTENDS = 95;
|
||||
|
||||
/**
|
||||
* Type: Keyword implements
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_IMPLEMENTS = 96;
|
||||
|
||||
/**
|
||||
* Type: Keyword protectedns
|
||||
*/
|
||||
public static final int TYPE_KEYWORD_PROTECTEDNS_BLOCK = 97;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param pos Position
|
||||
* @param type Type
|
||||
* @param value Value
|
||||
*/
|
||||
public ParsedSymbol(int pos, int type, Object value) {
|
||||
this.pos = pos;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param pos Position
|
||||
* @param type Type
|
||||
*/
|
||||
public ParsedSymbol(int pos, int type) {
|
||||
this.pos = pos;
|
||||
this.type = type;
|
||||
|
||||
+403
@@ -124,14 +124,29 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
/**
|
||||
* ABC indexing
|
||||
*/
|
||||
public final AbcIndexing abcIndex;
|
||||
|
||||
/**
|
||||
* Mark - exception start
|
||||
*/
|
||||
public static final int MARK_E_START = 0;
|
||||
|
||||
/**
|
||||
* Mark - exception end
|
||||
*/
|
||||
public static final int MARK_E_END = 1;
|
||||
|
||||
/**
|
||||
* Mark - exception target
|
||||
*/
|
||||
public static final int MARK_E_TARGET = 2;
|
||||
|
||||
/**
|
||||
* Mark - exception finally part
|
||||
*/
|
||||
public static final int MARK_E_FINALLYPART = 3;
|
||||
|
||||
private static int currentFinId = 1;
|
||||
@@ -142,11 +157,23 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
private long uniqLast = 0;
|
||||
|
||||
/**
|
||||
* Generate a new unique id
|
||||
* @return Unique id
|
||||
*/
|
||||
public String uniqId() {
|
||||
uniqLast++;
|
||||
return "" + uniqLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve type.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @param abcIndex ABC indexing
|
||||
* @return Type index
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public static int resolveType(SourceGeneratorLocalData localData, GraphTargetItem item, AbcIndexing abcIndex) throws CompilationException {
|
||||
int name_index = 0;
|
||||
GraphTargetItem typeItem = null;
|
||||
@@ -271,6 +298,11 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return SWFInputStream.BYTE_ARRAY_EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts list of source items to list of instructions
|
||||
* @param items List of source items
|
||||
* @return List of instructions
|
||||
*/
|
||||
public ArrayList<AVM2Instruction> toInsList(List<GraphSourceItem> items) {
|
||||
ArrayList<AVM2Instruction> ret = new ArrayList<>();
|
||||
for (GraphSourceItem s : items) {
|
||||
@@ -373,6 +405,17 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate for (each) in loop.
|
||||
* @param localData Local data
|
||||
* @param loop Loop
|
||||
* @param collection Collection
|
||||
* @param assignable Assignable
|
||||
* @param commands Commands
|
||||
* @param each Each
|
||||
* @return List of source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generateForIn(SourceGeneratorLocalData localData, Loop loop, GraphTargetItem collection, AssignableAVM2Item assignable, List<GraphTargetItem> commands, final boolean each) throws CompilationException {
|
||||
localData.openedLoops.add(loop.id);
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
@@ -452,38 +495,83 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return toInsList(command.toSource(localData, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets register variables.
|
||||
* @param localData Local data
|
||||
* @return Register variables
|
||||
*/
|
||||
public HashMap<String, Integer> getRegisterVars(SourceGeneratorLocalData localData) {
|
||||
return localData.registerVars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets register variables.
|
||||
* @param localData Local data
|
||||
* @param value Value
|
||||
*/
|
||||
public void setRegisterVars(SourceGeneratorLocalData localData, HashMap<String, Integer> value) {
|
||||
localData.registerVars = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets in function.
|
||||
* @param localData Local data
|
||||
* @param value Value
|
||||
*/
|
||||
public void setInFunction(SourceGeneratorLocalData localData, int value) {
|
||||
localData.inFunction = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets in function.
|
||||
* @param localData Local data
|
||||
* @return In function
|
||||
*/
|
||||
public int isInFunction(SourceGeneratorLocalData localData) {
|
||||
return localData.inFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if in method.
|
||||
* @param localData Local data
|
||||
* @return True if in method
|
||||
*/
|
||||
public boolean isInMethod(SourceGeneratorLocalData localData) {
|
||||
return localData.inMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets in method.
|
||||
* @param localData Local data
|
||||
* @param value Value
|
||||
*/
|
||||
public void setInMethod(SourceGeneratorLocalData localData, boolean value) {
|
||||
localData.inMethod = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets for in level.
|
||||
* @param localData Local data
|
||||
* @return For in level
|
||||
*/
|
||||
public int getForInLevel(SourceGeneratorLocalData localData) {
|
||||
return localData.forInLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets for in level.
|
||||
* @param localData Local data
|
||||
* @param value Value
|
||||
*/
|
||||
public void setForInLevel(SourceGeneratorLocalData localData, int value) {
|
||||
localData.forInLevel = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets temp register.
|
||||
* @param localData Local data
|
||||
* @return Temp register
|
||||
*/
|
||||
public int getTempRegister(SourceGeneratorLocalData localData) {
|
||||
HashMap<String, Integer> registerVars = getRegisterVars(localData);
|
||||
int tmpReg = 0;
|
||||
@@ -496,6 +584,10 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return tmpReg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
*/
|
||||
public AVM2SourceGenerator(AbcIndexing abc) {
|
||||
this.abcIndex = abc;
|
||||
}
|
||||
@@ -503,6 +595,33 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
/*public ABC getABC() {
|
||||
return abc;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Generate class.
|
||||
* @param importedClasses Imported classes
|
||||
* @param cinitVariables Cinit variables
|
||||
* @param cinitNeedsActivation Cinit needs activation
|
||||
* @param cinit Cinit
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param namespace Namespace
|
||||
* @param initScope Init scope
|
||||
* @param pkg Package
|
||||
* @param classInfo Class info
|
||||
* @param instanceInfo Instance info
|
||||
* @param localData Local data
|
||||
* @param isInterface Is interface
|
||||
* @param baseClassName Base class name
|
||||
* @param superName Super name
|
||||
* @param extendsVal Extends value
|
||||
* @param implementsStr Implements
|
||||
* @param iinit Instance initializer
|
||||
* @param iinitVariables Instance initializer variables
|
||||
* @param iinitNeedsActivation Instance initializer needs activation
|
||||
* @param traitItems Trait items
|
||||
* @param class_index Class index
|
||||
* @throws AVM2ParseException On parse error
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public void generateClass(List<DottedChain> importedClasses, List<AssignableAVM2Item> cinitVariables, boolean cinitNeedsActivation, List<GraphTargetItem> cinit, List<NamespaceItem> openedNamespaces, int namespace, int initScope, DottedChain pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String baseClassName, String superName, GraphTargetItem extendsVal, List<GraphTargetItem> implementsStr, GraphTargetItem iinit, List<AssignableAVM2Item> iinitVariables, boolean iinitNeedsActivation, List<GraphTargetItem> traitItems, Reference<Integer> class_index) throws AVM2ParseException, CompilationException {
|
||||
localData.currentClassBaseName = baseClassName;
|
||||
localData.pkg = pkg;
|
||||
@@ -715,6 +834,20 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates class.
|
||||
* @param namespace Namespace
|
||||
* @param ci Class info
|
||||
* @param ii Instance info
|
||||
* @param initScope Init scope
|
||||
* @param pkg Package
|
||||
* @param localData Local data
|
||||
* @param cls Class
|
||||
* @param class_index Class index
|
||||
* @return Class index
|
||||
* @throws AVM2ParseException On parse error
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public int generateClass(int namespace, ClassInfo ci, InstanceInfo ii, int initScope, DottedChain pkg, SourceGeneratorLocalData localData, AVM2Item cls, Reference<Integer> class_index) throws AVM2ParseException, CompilationException {
|
||||
/*ClassInfo ci = new ClassInfo();
|
||||
InstanceInfo ii = new InstanceInfo();
|
||||
@@ -755,10 +888,23 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return abcIndex.getSelectedAbc().instance_info.size() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets trait name.
|
||||
* @param namespace Namespace
|
||||
* @param var Variable
|
||||
* @return Multiname index
|
||||
*/
|
||||
public int traitName(int namespace, String var) {
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, str(var), namespace), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets type name.
|
||||
* @param localData Local data
|
||||
* @param type Type
|
||||
* @return Multiname index
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public int typeName(SourceGeneratorLocalData localData, GraphTargetItem type) throws CompilationException {
|
||||
if (type.equals(TypeItem.UNBOUNDED)) {
|
||||
return 0;
|
||||
@@ -787,6 +933,11 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets identifier from name.
|
||||
* @param name Name
|
||||
* @return Identifier
|
||||
*/
|
||||
public int ident(GraphTargetItem name) {
|
||||
if (name instanceof NameAVM2Item) {
|
||||
return str(((NameAVM2Item) name).getVariableName());
|
||||
@@ -794,14 +945,30 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
throw new RuntimeException("no ident"); //FIXME
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets namespace.
|
||||
* @param nsKind Namespace kind
|
||||
* @param name Name
|
||||
* @return Namespace index
|
||||
*/
|
||||
public int namespace(int nsKind, String name) {
|
||||
return abcIndex.getSelectedAbc().constants.getNamespaceId(nsKind, str(name), 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets string
|
||||
* @param name Name
|
||||
* @return String index
|
||||
*/
|
||||
public int str(String name) {
|
||||
return abcIndex.getSelectedAbc().constants.getStringId(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets property name.
|
||||
* @param name Name
|
||||
* @return Multiname index
|
||||
*/
|
||||
public int propertyName(GraphTargetItem name) {
|
||||
if (name instanceof NameAVM2Item) {
|
||||
NameAVM2Item va = (NameAVM2Item) name;
|
||||
@@ -810,6 +977,11 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
throw new RuntimeException("no prop"); //FIXME
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets free register.
|
||||
* @param localData Local data
|
||||
* @return Register
|
||||
*/
|
||||
public int getFreeRegister(SourceGeneratorLocalData localData) {
|
||||
for (int i = 0;; i++) {
|
||||
if (!localData.registerVars.containsValue(i)) {
|
||||
@@ -819,6 +991,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kills register.
|
||||
* @param localData Local data
|
||||
* @param i Register
|
||||
* @return True if register was killed
|
||||
*/
|
||||
public boolean killRegister(SourceGeneratorLocalData localData, int i) {
|
||||
String key = null;
|
||||
for (String k : localData.registerVars.keySet()) {
|
||||
@@ -834,6 +1012,32 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets method.
|
||||
* @param isStatic Is static
|
||||
* @param name_index Name index
|
||||
* @param subMethod Sub method
|
||||
* @param isInterface Is interface
|
||||
* @param isNative Is native
|
||||
* @param callStack Call stack
|
||||
* @param pkg Package
|
||||
* @param needsActivation Needs activation
|
||||
* @param subvariables Subvariables
|
||||
* @param initScope Init scope
|
||||
* @param hasRest Has rest
|
||||
* @param line Line
|
||||
* @param classBaseName Class base name
|
||||
* @param superType Super type
|
||||
* @param constructor Constructor
|
||||
* @param localData Local data
|
||||
* @param paramTypes Parameter types
|
||||
* @param paramNames Parameter names
|
||||
* @param paramValues Parameter values
|
||||
* @param body Body
|
||||
* @param retType Return type
|
||||
* @return Method index
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public int method(boolean isStatic, int name_index, boolean subMethod, boolean isInterface, boolean isNative, List<MethodBody> callStack, DottedChain pkg, boolean needsActivation, List<AssignableAVM2Item> subvariables, int initScope, boolean hasRest, int line, String classBaseName, String superType, boolean constructor, SourceGeneratorLocalData localData, List<GraphTargetItem> paramTypes, List<String> paramNames, List<GraphTargetItem> paramValues, List<GraphTargetItem> body, GraphTargetItem retType) throws CompilationException {
|
||||
//Reference<Boolean> hasArgs = new Reference<>(Boolean.FALSE);
|
||||
//calcRegisters(localData,needsActivation,paramNames,subvariables,body, hasArgs);
|
||||
@@ -1301,6 +1505,14 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return mindex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets value kind.
|
||||
* @param ns Namespace
|
||||
* @param type Type
|
||||
* @param val Value
|
||||
* @param generatedNs Generated namespace
|
||||
* @return Value kind
|
||||
*/
|
||||
public ValueKind getValueKind(int ns, GraphTargetItem type, GraphTargetItem val, boolean generatedNs) {
|
||||
|
||||
if (val instanceof BooleanAVM2Item) {
|
||||
@@ -1358,6 +1570,16 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ns.getCpoolIndex(abcIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates traits phase 2.
|
||||
* @param importedClasses Imported classes
|
||||
* @param pkg Package
|
||||
* @param items Items
|
||||
* @param traits Traits
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param localData Local data
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public void generateTraitsPhase2(List<DottedChain> importedClasses, DottedChain pkg, List<GraphTargetItem> items, Trait[] traits, List<NamespaceItem> openedNamespaces, SourceGeneratorLocalData localData) throws CompilationException {
|
||||
for (int k = 0; k < items.size(); k++) {
|
||||
GraphTargetItem item = items.get(k);
|
||||
@@ -1407,6 +1629,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates traits phase 3.
|
||||
* @param items Items
|
||||
* @param traits Traits
|
||||
* @param localData Local data
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public void generateTraitsPhase3(List<GraphTargetItem> items, Trait[] traits, SourceGeneratorLocalData localData) throws CompilationException {
|
||||
for (int k = 0; k < items.size(); k++) {
|
||||
GraphTargetItem item = items.get(k);
|
||||
@@ -1473,6 +1702,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets super interface name.
|
||||
* @param localData Local data
|
||||
* @param un Unresolved item
|
||||
* @return Multiname index
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public int superIntName(SourceGeneratorLocalData localData, GraphTargetItem un) throws CompilationException {
|
||||
if (un instanceof UnresolvedAVM2Item) {
|
||||
((UnresolvedAVM2Item) un).resolve(localData, localData.getFullClass(), null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
|
||||
@@ -1488,6 +1724,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates metadata
|
||||
* @param metadata Metadata
|
||||
* @param abc ABC
|
||||
* @return Metadata indices
|
||||
*/
|
||||
public int[] generateMetadata(List<Map.Entry<String, Map<String, String>>> metadata, ABC abc) {
|
||||
List<Integer> retList = new ArrayList<>();
|
||||
for (int i = 0; i < metadata.size(); i++) {
|
||||
@@ -1514,6 +1756,25 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates traits phase 4.
|
||||
* @param importedClasses Imported classes
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param methodInitScope Method init scope
|
||||
* @param isInterface Is interface
|
||||
* @param className Class name
|
||||
* @param superName Super name
|
||||
* @param generateStatic Generate static
|
||||
* @param localData Local data
|
||||
* @param items Items
|
||||
* @param ts Traits
|
||||
* @param traits Traits
|
||||
* @param initScopes Init scopes
|
||||
* @param class_index Class index
|
||||
* @param isScriptTraits Is script traits
|
||||
* @throws AVM2ParseException On parse error
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public void generateTraitsPhase4(List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, int methodInitScope, boolean isInterface, String className, String superName, boolean generateStatic, SourceGeneratorLocalData localData, List<GraphTargetItem> items, Traits ts, Trait[] traits, Map<Trait, Integer> initScopes, Reference<Integer> class_index, boolean isScriptTraits) throws AVM2ParseException, CompilationException {
|
||||
|
||||
//Note: Names must be generated first before accesed in inner subs
|
||||
@@ -1651,6 +1912,22 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return abcIndex.getSelectedAbc().constants.getStringId(sb.toString(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates traits phase 1.
|
||||
* @param importedClasses Imported classes
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param className Class name
|
||||
* @param superName Super name
|
||||
* @param generateStatic Generate static
|
||||
* @param localData Local data
|
||||
* @param items Items
|
||||
* @param ts Traits
|
||||
* @param classIndex Class index
|
||||
* @param isScriptTraits Is script traits
|
||||
* @return Traits
|
||||
* @throws AVM2ParseException On parse error
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public Trait[] generateTraitsPhase1(List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, String className, String superName, boolean generateStatic, SourceGeneratorLocalData localData, List<GraphTargetItem> items, Traits ts, Reference<Integer> classIndex, boolean isScriptTraits) throws AVM2ParseException, CompilationException {
|
||||
Trait[] traits = new Trait[items.size()];
|
||||
int slot_id = 1;
|
||||
@@ -1801,6 +2078,17 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates script info.
|
||||
* @param scriptIndex Script index
|
||||
* @param scriptInfo Script info
|
||||
* @param allOpenedNamespaces All opened namespaces
|
||||
* @param localData Local data
|
||||
* @param commands Commands
|
||||
* @param classPos Class position
|
||||
* @throws AVM2ParseException On parse error
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public void generateScriptInfo(int scriptIndex, ScriptInfo scriptInfo, List<List<NamespaceItem>> allOpenedNamespaces, SourceGeneratorLocalData localData, List<GraphTargetItem> commands, int classPos) throws AVM2ParseException, CompilationException {
|
||||
Reference<Integer> class_index = new Reference<>(classPos);
|
||||
localData.currentScript = scriptInfo;
|
||||
@@ -1925,6 +2213,14 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent names add names.
|
||||
* @param abc ABC
|
||||
* @param name_index Name index
|
||||
* @param indices Indices
|
||||
* @param names Names
|
||||
* @param namespaces Namespaces
|
||||
*/
|
||||
public static void parentNamesAddNames(AbcIndexing abc, int name_index, List<Integer> indices, List<String> names, List<String> namespaces) {
|
||||
List<Integer> cindices = new ArrayList<>();
|
||||
|
||||
@@ -1947,6 +2243,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets trait return type.
|
||||
* @param abc ABC
|
||||
* @param t Trait
|
||||
* @return Trait return type
|
||||
*/
|
||||
public static GraphTargetItem getTraitReturnType(AbcIndexing abc, Trait t) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
@@ -1974,6 +2276,28 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches prototype chain.
|
||||
* @param namespaceSuffix Namespace suffix
|
||||
* @param otherNs Other namespaces
|
||||
* @param privateNs Private namespace
|
||||
* @param protectedNs Protected namespace
|
||||
* @param instanceOnly Instance only
|
||||
* @param abc ABC
|
||||
* @param pkg Package
|
||||
* @param obj Object
|
||||
* @param propertyName Property name
|
||||
* @param outName Out name
|
||||
* @param outNs Out namespace
|
||||
* @param outPropNs Out property namespace
|
||||
* @param outPropNsKind Out property namespace kind
|
||||
* @param outPropNsIndex Out property namespace index
|
||||
* @param outPropType Out property type
|
||||
* @param outPropValue Out property value
|
||||
* @param outPropValueAbc Out property value ABC
|
||||
* @param isType Is type
|
||||
* @return True if found
|
||||
*/
|
||||
public static boolean searchPrototypeChain(Integer namespaceSuffix, List<Integer> otherNs, int privateNs, int protectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference<String> outName, Reference<DottedChain> outNs, Reference<DottedChain> outPropNs, Reference<Integer> outPropNsKind, Reference<Integer> outPropNsIndex, Reference<GraphTargetItem> outPropType, Reference<ValueKind> outPropValue, Reference<ABC> outPropValueAbc, Reference<Boolean> isType) {
|
||||
// private and protected namespaces first so we find overriding functions before overridden functions
|
||||
if (namespaceSuffix != null) {
|
||||
@@ -2025,6 +2349,15 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent names.
|
||||
* @param abc ABC
|
||||
* @param name_index Name index
|
||||
* @param indices Indices
|
||||
* @param names Names
|
||||
* @param namespaces Namespaces
|
||||
* @param outABCs Out ABCs
|
||||
*/
|
||||
public static void parentNames(AbcIndexing abc, int name_index, List<Integer> indices, List<String> names, List<String> namespaces, List<ABC> outABCs) {
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc().constants, true /*FIXME!!*/)), null, null/*FIXME?*/);
|
||||
while (ci != null) {
|
||||
@@ -2047,6 +2380,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.PushTrue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates GetDescendants.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, GetDescendantsAVM2Item item) throws CompilationException {
|
||||
|
||||
AVM2ConstantPool constants = abcIndex.getSelectedAbc().constants;
|
||||
@@ -2096,6 +2436,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates XMLFilter.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, XMLFilterAVM2Item item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
final Reference<Integer> counterReg = new Reference<>(0);
|
||||
@@ -2206,10 +2553,24 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates for each in loop.
|
||||
* @param localData Local data
|
||||
* @param item Loop item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ForEachInAVM2Item item) throws CompilationException {
|
||||
return generateForIn(localData, item.loop, item.expression.collection, (AssignableAVM2Item) item.expression.object, item.commands, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates for in loop.
|
||||
* @param localData Local data
|
||||
* @param item Loop item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ForInAVM2Item item) throws CompilationException {
|
||||
return generateForIn(localData, item.loop, item.expression.collection, (AssignableAVM2Item) item.expression.object, item.commands, false);
|
||||
}
|
||||
@@ -2249,6 +2610,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates with statement.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, WithAVM2Item item) throws CompilationException {
|
||||
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
@@ -2442,6 +2810,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates function.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, FunctionAVM2Item item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
int scope = 0;
|
||||
@@ -2464,6 +2839,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates try-catch-finally.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TryAVM2Item item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
|
||||
@@ -2822,6 +3204,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates return value.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ReturnValueAVM2Item item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
ret.addAll(item.value.toSource(localData, this));
|
||||
@@ -2852,6 +3241,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates return void.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ReturnVoidAVM2Item item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
if (!localData.finallyCatches.isEmpty()) {
|
||||
@@ -2878,6 +3274,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates throw.
|
||||
* @param localData Local data
|
||||
* @param item Item
|
||||
* @return Source items
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ThrowAVM2Item item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
ret.addAll(item.value.toSource(localData, this));
|
||||
|
||||
+93
@@ -37,8 +37,17 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Assigned value
|
||||
*/
|
||||
protected GraphTargetItem assignedValue;
|
||||
|
||||
/**
|
||||
* Makes coerced.
|
||||
* @param assignedValue Assigned value
|
||||
* @param targetType Target type
|
||||
* @return Coerced value
|
||||
*/
|
||||
protected GraphTargetItem makeCoerced(GraphTargetItem assignedValue, GraphTargetItem targetType) {
|
||||
if (assignedValue instanceof OrItem) {
|
||||
OrItem oi = (OrItem) assignedValue;
|
||||
@@ -48,27 +57,63 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
return new CoerceAVM2Item(null, null, assignedValue, targetType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AssignableAVM2Item() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copis assignable.
|
||||
* @return Copied assignable
|
||||
*/
|
||||
public abstract AssignableAVM2Item copy();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param storeValue Store value
|
||||
*/
|
||||
public AssignableAVM2Item(GraphTargetItem storeValue) {
|
||||
super(null, null, PRECEDENCE_PRIMARY);
|
||||
this.assignedValue = storeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* To source with change (post/pre increment, decrement).
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param post Post
|
||||
* @param decrement Decrement
|
||||
* @param needsReturn Needs return
|
||||
* @return Source change
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public abstract List<GraphSourceItem> toSourceChange(SourceGeneratorLocalData localData, SourceGenerator generator, boolean post, boolean decrement, boolean needsReturn) throws CompilationException;
|
||||
|
||||
/**
|
||||
* Gets assigned value.
|
||||
* @return Assigned value
|
||||
*/
|
||||
public GraphTargetItem getAssignedValue() {
|
||||
return assignedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets assigned value.
|
||||
* @param storeValue Store value
|
||||
*/
|
||||
public void setAssignedValue(GraphTargetItem storeValue) {
|
||||
this.assignedValue = storeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicated and set temp register.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param register Register
|
||||
* @return Source
|
||||
*/
|
||||
public static List<GraphSourceItem> dupSetTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference<Integer> register) {
|
||||
register.setVal(getFreeRegister(localData, generator));
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
@@ -77,6 +122,13 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets temp register.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param register Register
|
||||
* @return Source
|
||||
*/
|
||||
public static List<GraphSourceItem> setTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference<Integer> register) {
|
||||
register.setVal(getFreeRegister(localData, generator));
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
@@ -84,6 +136,13 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets temp register.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param register Register
|
||||
* @return Source
|
||||
*/
|
||||
public static List<GraphSourceItem> getTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference<Integer> register) {
|
||||
if (register.getVal() < 0) {
|
||||
return new ArrayList<>();
|
||||
@@ -100,6 +159,14 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
ret.add(ins(AVM2Instructions.Kill, register.getVal()));
|
||||
return ret;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Kills temp register.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param registers Registers
|
||||
* @return Source
|
||||
*/
|
||||
public static List<GraphSourceItem> killTemp(SourceGeneratorLocalData localData, SourceGenerator generator, List<Reference<Integer>> registers) {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
for (Reference<Integer> register : registers) {
|
||||
@@ -113,6 +180,11 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate set local.
|
||||
* @param regNumber Register number
|
||||
* @return Instruction
|
||||
*/
|
||||
public static AVM2Instruction generateSetLoc(int regNumber) {
|
||||
switch (regNumber) {
|
||||
case -1:
|
||||
@@ -130,6 +202,11 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate get local.
|
||||
* @param regNumber Register number
|
||||
* @return Instruction
|
||||
*/
|
||||
public static AVM2Instruction generateGetLoc(int regNumber) {
|
||||
switch (regNumber) {
|
||||
case -1:
|
||||
@@ -147,6 +224,12 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate get slot.
|
||||
* @param slotScope Slot scope
|
||||
* @param slotNumber Slot number
|
||||
* @return Source
|
||||
*/
|
||||
public static List<GraphSourceItem> generateGetSlot(int slotScope, int slotNumber) {
|
||||
if (slotNumber == -1) {
|
||||
return null;
|
||||
@@ -157,6 +240,16 @@ public abstract class AssignableAVM2Item extends AVM2Item {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate set slot.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param val Value
|
||||
* @param slotScope Slot scope
|
||||
* @param slotNumber Slot number
|
||||
* @return Source
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public static List<GraphSourceItem> generateSetSlot(SourceGeneratorLocalData localData, SourceGenerator generator, GraphTargetItem val, int slotScope, int slotNumber) throws CompilationException {
|
||||
if (slotNumber == -1) {
|
||||
return null;
|
||||
|
||||
+8
@@ -27,10 +27,18 @@ public class BreakJumpIns extends JumpIns {
|
||||
|
||||
private final long loopId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param loopId Loop id
|
||||
*/
|
||||
public BreakJumpIns(long loopId) {
|
||||
this.loopId = loopId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets loop id.
|
||||
* @return Loop id
|
||||
*/
|
||||
public long getLoopId() {
|
||||
return loopId;
|
||||
}
|
||||
|
||||
+31
@@ -42,16 +42,39 @@ import java.util.List;
|
||||
*/
|
||||
public class CallAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
public GraphTargetItem name;
|
||||
|
||||
/**
|
||||
* Arguments
|
||||
*/
|
||||
public List<GraphTargetItem> arguments;
|
||||
|
||||
/**
|
||||
* Line
|
||||
*/
|
||||
public int line;
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* ABC indexing
|
||||
*/
|
||||
private AbcIndexing abcIndex;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param line Line
|
||||
* @param name Name
|
||||
* @param arguments Arguments
|
||||
* @param abcIndex ABC indexing
|
||||
*/
|
||||
public CallAVM2Item(List<NamespaceItem> openedNamespaces, int line, GraphTargetItem name, List<GraphTargetItem> arguments, AbcIndexing abcIndex) {
|
||||
super(null, null, NOPRECEDENCE);
|
||||
this.openedNamespaces = openedNamespaces;
|
||||
@@ -66,6 +89,14 @@ public class CallAVM2Item extends AVM2Item {
|
||||
return writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to source.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param needsReturn Needs return
|
||||
* @return Source
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
|
||||
+67
@@ -36,36 +36,84 @@ import java.util.Map;
|
||||
*/
|
||||
public class ClassAVM2Item extends AVM2Item implements Block {
|
||||
|
||||
/**
|
||||
* Traits
|
||||
*/
|
||||
public List<GraphTargetItem> traits;
|
||||
|
||||
/**
|
||||
* Extends
|
||||
*/
|
||||
public GraphTargetItem extendsOp;
|
||||
|
||||
/**
|
||||
* Implements
|
||||
*/
|
||||
public List<GraphTargetItem> implementsOp;
|
||||
|
||||
/**
|
||||
* Class base name
|
||||
*/
|
||||
public String classBaseName;
|
||||
|
||||
/**
|
||||
* Instance initializer
|
||||
*/
|
||||
public GraphTargetItem iinit;
|
||||
|
||||
/**
|
||||
* Is dynamic
|
||||
*/
|
||||
public boolean isDynamic;
|
||||
|
||||
/**
|
||||
* Is final
|
||||
*/
|
||||
public boolean isFinal;
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Static initializer
|
||||
*/
|
||||
public List<GraphTargetItem> staticInit;
|
||||
|
||||
/**
|
||||
* Static initializer activation
|
||||
*/
|
||||
public boolean cinitActivation;
|
||||
|
||||
/**
|
||||
* Instance initializer activation
|
||||
*/
|
||||
public boolean iinitActivation;
|
||||
|
||||
/**
|
||||
* Static initializer variables
|
||||
*/
|
||||
public List<AssignableAVM2Item> cinitVariables;
|
||||
|
||||
/**
|
||||
* Imported classes
|
||||
*/
|
||||
public List<DottedChain> importedClasses;
|
||||
|
||||
/**
|
||||
* Package
|
||||
*/
|
||||
public NamespaceItem pkg;
|
||||
|
||||
/**
|
||||
* Instance initializer variables
|
||||
*/
|
||||
public List<AssignableAVM2Item> iinitVariables;
|
||||
|
||||
/**
|
||||
* Metadata
|
||||
*/
|
||||
public List<Map.Entry<String, Map<String, String>>> metadata;
|
||||
|
||||
@Override
|
||||
@@ -82,6 +130,25 @@ public class ClassAVM2Item extends AVM2Item implements Block {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param metadata Metadata
|
||||
* @param importedClasses Imported classes
|
||||
* @param pkg Package
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param isFinal Is final
|
||||
* @param isDynamic Is dynamic
|
||||
* @param className Class name
|
||||
* @param extendsOp Extends
|
||||
* @param implementsOp Implements
|
||||
* @param cinit Static initializer
|
||||
* @param staticInitActivation Static initializer activation
|
||||
* @param cinitVariables Static initializer variables
|
||||
* @param iinit Instance initializer
|
||||
* @param iinitVariables Instance initializer variables
|
||||
* @param traits Traits
|
||||
* @param iinitActivation Instance initializer activation
|
||||
*/
|
||||
public ClassAVM2Item(List<Map.Entry<String, Map<String, String>>> metadata, List<DottedChain> importedClasses, NamespaceItem pkg, List<NamespaceItem> openedNamespaces, boolean isFinal, boolean isDynamic, String className, GraphTargetItem extendsOp, List<GraphTargetItem> implementsOp, List<GraphTargetItem> cinit, boolean staticInitActivation, List<AssignableAVM2Item> cinitVariables, GraphTargetItem iinit, List<AssignableAVM2Item> iinitVariables, List<GraphTargetItem> traits, boolean iinitActivation) {
|
||||
super(null, null, NOPRECEDENCE);
|
||||
this.metadata = metadata;
|
||||
|
||||
+40
@@ -30,26 +30,66 @@ import java.util.Map;
|
||||
*/
|
||||
public class ConstAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Is static
|
||||
*/
|
||||
private final boolean isStatic;
|
||||
|
||||
/**
|
||||
* Variable name
|
||||
*/
|
||||
public String var;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public GraphTargetItem type;
|
||||
|
||||
/**
|
||||
* Custom namespace
|
||||
*/
|
||||
public String customNamespace;
|
||||
|
||||
/**
|
||||
* Metadata
|
||||
*/
|
||||
public List<Map.Entry<String, Map<String, String>>> metadata;
|
||||
|
||||
/**
|
||||
* Line
|
||||
*/
|
||||
public int line;
|
||||
|
||||
/**
|
||||
* Package
|
||||
*/
|
||||
public NamespaceItem pkg;
|
||||
|
||||
/**
|
||||
* Generated namespace
|
||||
*/
|
||||
public boolean generatedNs;
|
||||
|
||||
/**
|
||||
* Check if is static
|
||||
* @return Is static
|
||||
*/
|
||||
public boolean isStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param metadata Metadata
|
||||
* @param pkg Package
|
||||
* @param customNamespace Custom namespace
|
||||
* @param isStatic Is static
|
||||
* @param var Variable name
|
||||
* @param type Type
|
||||
* @param value Value
|
||||
* @param line Line
|
||||
* @param generatedNs Generated namespace
|
||||
*/
|
||||
public ConstAVM2Item(List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, String customNamespace, boolean isStatic, String var, GraphTargetItem type, GraphTargetItem value, int line, boolean generatedNs) {
|
||||
|
||||
super(null, null, NOPRECEDENCE, value);
|
||||
|
||||
+11
@@ -33,8 +33,19 @@ import java.util.List;
|
||||
*/
|
||||
public class ConstructSomethingAVM2Item extends CallAVM2Item {
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param line Line
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param name Name
|
||||
* @param arguments Arguments
|
||||
* @param abcIndex ABC index
|
||||
*/
|
||||
public ConstructSomethingAVM2Item(int line, List<NamespaceItem> openedNamespaces, GraphTargetItem name, List<GraphTargetItem> arguments, AbcIndexing abcIndex) {
|
||||
super(openedNamespaces, line, name, arguments, abcIndex);
|
||||
this.openedNamespaces = openedNamespaces;
|
||||
|
||||
+11
@@ -25,12 +25,23 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
*/
|
||||
public class ContinueJumpIns extends JumpIns {
|
||||
|
||||
/**
|
||||
* Loop id
|
||||
*/
|
||||
private final long loopId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param loopId Loop id
|
||||
*/
|
||||
public ContinueJumpIns(long loopId) {
|
||||
this.loopId = loopId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets loop id.
|
||||
* @return Loop id
|
||||
*/
|
||||
public long getLoopId() {
|
||||
return loopId;
|
||||
}
|
||||
|
||||
+11
@@ -26,10 +26,21 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
*/
|
||||
public class ExceptionMarkAVM2Instruction extends AVM2Instruction {
|
||||
|
||||
/**
|
||||
* Mark type
|
||||
*/
|
||||
public int markType;
|
||||
|
||||
/**
|
||||
* Exception id
|
||||
*/
|
||||
public int exceptionId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param exceptionId Exception id
|
||||
* @param markType Mark type
|
||||
*/
|
||||
public ExceptionMarkAVM2Instruction(int exceptionId, int markType) {
|
||||
super(0, null, null);
|
||||
this.markType = markType;
|
||||
|
||||
+4
@@ -27,6 +27,10 @@ public class ExceptionMarkIns extends InstructionDefinition {
|
||||
|
||||
private static final ExceptionMarkIns instance = new ExceptionMarkIns();
|
||||
|
||||
/**
|
||||
* Gets the instance of this class.
|
||||
* @return The instance of this class
|
||||
*/
|
||||
public static final ExceptionMarkIns getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
+11
@@ -25,12 +25,23 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
*/
|
||||
public class FinallyJumpIns extends JumpIns {
|
||||
|
||||
/**
|
||||
* Finally clause id
|
||||
*/
|
||||
private final long finallyClauseId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param finallyClauseId Finally clause id
|
||||
*/
|
||||
public FinallyJumpIns(long finallyClauseId) {
|
||||
this.finallyClauseId = finallyClauseId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets clause id.
|
||||
* @return Clause id
|
||||
*/
|
||||
public long getClauseId() {
|
||||
return finallyClauseId;
|
||||
}
|
||||
|
||||
+63
-1
@@ -35,37 +35,99 @@ import java.util.Map;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FunctionAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Calculated function name
|
||||
*/
|
||||
public String calculatedFunctionName;
|
||||
|
||||
/**
|
||||
* Function name
|
||||
*/
|
||||
public String functionName;
|
||||
|
||||
/**
|
||||
* Parameter names
|
||||
*/
|
||||
public List<String> paramNames;
|
||||
|
||||
/**
|
||||
* Body
|
||||
*/
|
||||
public List<GraphTargetItem> body;
|
||||
|
||||
/**
|
||||
* Subvariables
|
||||
*/
|
||||
public List<AssignableAVM2Item> subvariables;
|
||||
|
||||
/**
|
||||
* Parameter types
|
||||
*/
|
||||
public List<GraphTargetItem> paramTypes;
|
||||
|
||||
/**
|
||||
* Parameter values
|
||||
*/
|
||||
public List<GraphTargetItem> paramValues;
|
||||
|
||||
/**
|
||||
* Return type
|
||||
*/
|
||||
public GraphTargetItem retType;
|
||||
|
||||
/**
|
||||
* Line
|
||||
*/
|
||||
public int line;
|
||||
|
||||
/**
|
||||
* Has rest
|
||||
*/
|
||||
public boolean hasRest;
|
||||
|
||||
/**
|
||||
* Needs activation
|
||||
*/
|
||||
public boolean needsActivation;
|
||||
|
||||
/**
|
||||
* Is interface
|
||||
*/
|
||||
public boolean isInterface;
|
||||
|
||||
/**
|
||||
* Is native
|
||||
*/
|
||||
public boolean isNative;
|
||||
|
||||
/**
|
||||
* Package
|
||||
*/
|
||||
public NamespaceItem pkg;
|
||||
|
||||
/**
|
||||
* Metadata
|
||||
*/
|
||||
public List<Map.Entry<String, Map<String, String>>> metadata;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param metadata Metadata
|
||||
* @param pkg Package
|
||||
* @param isInterface Is interface
|
||||
* @param isNative Is native
|
||||
* @param needsActivation Needs activation
|
||||
* @param hasRest Has rest
|
||||
* @param line Line
|
||||
* @param functionName Function name
|
||||
* @param paramTypes Parameter types
|
||||
* @param paramNames Parameter names
|
||||
* @param paramValues Parameter values
|
||||
* @param body Body
|
||||
* @param subvariables Subvariables
|
||||
* @param retType Return type
|
||||
*/
|
||||
public FunctionAVM2Item(List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, boolean isNative, boolean needsActivation, boolean hasRest, int line, String functionName, List<GraphTargetItem> paramTypes, List<String> paramNames, List<GraphTargetItem> paramValues, List<GraphTargetItem> body, List<AssignableAVM2Item> subvariables, GraphTargetItem retType) {
|
||||
|
||||
super(null, null, NOPRECEDENCE);
|
||||
|
||||
+24
@@ -27,6 +27,30 @@ import java.util.Map;
|
||||
*/
|
||||
public class GetterAVM2Item extends MethodAVM2Item {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param allOpenedNamespaces All opened namespaces
|
||||
* @param outsidePackage Outside package
|
||||
* @param isPrivate Is private
|
||||
* @param metadata Metadata
|
||||
* @param pkg Package
|
||||
* @param isInterface Is interface
|
||||
* @param isNative Is native
|
||||
* @param customNamespace Custom namespace
|
||||
* @param needsActivation Needs activation
|
||||
* @param hasRest Has rest
|
||||
* @param line Line
|
||||
* @param override Override
|
||||
* @param isFinal Is final
|
||||
* @param isStatic Is static
|
||||
* @param methodName Method name
|
||||
* @param paramTypes Parameter types
|
||||
* @param paramNames Parameter names
|
||||
* @param paramValues Parameter values
|
||||
* @param body Body
|
||||
* @param subvariables Subvariables
|
||||
* @param retType Return type
|
||||
*/
|
||||
public GetterAVM2Item(List<List<NamespaceItem>> allOpenedNamespaces, boolean outsidePackage, boolean isPrivate, List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, boolean isNative, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, String methodName, List<GraphTargetItem> paramTypes, List<String> paramNames, List<GraphTargetItem> paramValues, List<GraphTargetItem> body, List<AssignableAVM2Item> subvariables, GraphTargetItem retType) {
|
||||
super(allOpenedNamespaces, outsidePackage, isPrivate, metadata, pkg, isInterface, isNative, customNamespace, needsActivation, hasRest, line, override, isFinal, isStatic, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType);
|
||||
}
|
||||
|
||||
+15
@@ -39,8 +39,15 @@ import java.util.List;
|
||||
*/
|
||||
public class ImportedSlotConstItem extends AssignableAVM2Item {
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public TypeItem type;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param type Type
|
||||
*/
|
||||
public ImportedSlotConstItem(TypeItem type) {
|
||||
this.type = type;
|
||||
}
|
||||
@@ -65,6 +72,14 @@ public class ImportedSlotConstItem extends AssignableAVM2Item {
|
||||
return new ImportedSlotConstItem(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to source.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param needsReturn Needs return
|
||||
* @return Source
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
int propertyId = ((AVM2SourceGenerator) generator).typeName(localData, type);
|
||||
Object obj = new FindPropertyAVM2Item(null, null, type);
|
||||
|
||||
+32
@@ -40,14 +40,34 @@ import java.util.Objects;
|
||||
*/
|
||||
public class IndexAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
private final List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Object
|
||||
*/
|
||||
public GraphTargetItem object;
|
||||
|
||||
/**
|
||||
* Index
|
||||
*/
|
||||
public GraphTargetItem index;
|
||||
|
||||
/**
|
||||
* Attribute
|
||||
*/
|
||||
public boolean attr;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param attr Attribute
|
||||
* @param object Object
|
||||
* @param index Index
|
||||
* @param storeValue Store value
|
||||
* @param openedNamespaces Opened namespaces
|
||||
*/
|
||||
public IndexAVM2Item(boolean attr, GraphTargetItem object, GraphTargetItem index, GraphTargetItem storeValue, List<NamespaceItem> openedNamespaces) {
|
||||
super(storeValue);
|
||||
this.object = object;
|
||||
@@ -110,6 +130,18 @@ public class IndexAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to source.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param needsReturn Needs return
|
||||
* @param call Call
|
||||
* @param callargs Call arguments
|
||||
* @param delete Delete
|
||||
* @param construct Construct
|
||||
* @return Source
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn, boolean call, List<GraphTargetItem> callargs, boolean delete, boolean construct) throws CompilationException {
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createMultinameL(attr, allNsSet(g.abcIndex)), true);
|
||||
|
||||
+35
@@ -32,22 +32,57 @@ import java.util.Map;
|
||||
*/
|
||||
public class InterfaceAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Base name
|
||||
*/
|
||||
public String baseName;
|
||||
|
||||
/**
|
||||
* Super interfaces
|
||||
*/
|
||||
public List<GraphTargetItem> superInterfaces;
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
public List<GraphTargetItem> methods;
|
||||
|
||||
/**
|
||||
* Is final
|
||||
*/
|
||||
public boolean isFinal;
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Package
|
||||
*/
|
||||
public NamespaceItem pkg;
|
||||
|
||||
/**
|
||||
* Imported classes
|
||||
*/
|
||||
public List<DottedChain> importedClasses;
|
||||
|
||||
/**
|
||||
* Metadata
|
||||
*/
|
||||
public List<Map.Entry<String, Map<String, String>>> metadata;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param metadata Metadata
|
||||
* @param importedClasses Imported classes
|
||||
* @param pkg Package
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param isFinal Is final
|
||||
* @param name Name
|
||||
* @param superInterfaces Super interfaces
|
||||
* @param traits Traits
|
||||
*/
|
||||
public InterfaceAVM2Item(List<Map.Entry<String, Map<String, String>>> metadata, List<DottedChain> importedClasses, NamespaceItem pkg, List<NamespaceItem> openedNamespaces, boolean isFinal, String name, List<GraphTargetItem> superInterfaces, List<GraphTargetItem> traits) {
|
||||
super(null, null, NOPRECEDENCE);
|
||||
this.metadata = metadata;
|
||||
|
||||
+7
@@ -27,6 +27,9 @@ import java.util.List;
|
||||
*/
|
||||
public class LexBufferer implements LexListener {
|
||||
|
||||
/**
|
||||
* List of stored symbols
|
||||
*/
|
||||
private final List<ParsedSymbol> items = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
@@ -41,6 +44,10 @@ public class LexBufferer implements LexListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes all stored symbols back to lexer
|
||||
* @param lexer Lexer
|
||||
*/
|
||||
public void pushAllBack(ActionScriptLexer lexer) {
|
||||
for (int i = items.size() - 1; i >= 0; i--) {
|
||||
lexer.pushback(items.get(i));
|
||||
|
||||
+8
@@ -23,7 +23,15 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
|
||||
*/
|
||||
public interface LexListener {
|
||||
|
||||
/**
|
||||
* Called when a symbol is parsed.
|
||||
* @param s Parsed symbol
|
||||
*/
|
||||
public void onLex(ParsedSymbol s);
|
||||
|
||||
/**
|
||||
* Called when a symbol is pushed back.
|
||||
* @param s Parsed symbol
|
||||
*/
|
||||
public void onPushBack(ParsedSymbol s);
|
||||
}
|
||||
|
||||
+46
-2
@@ -39,15 +39,48 @@ public class MethodAVM2Item extends FunctionAVM2Item {
|
||||
|
||||
public final boolean outsidePackage;
|
||||
|
||||
/**
|
||||
* Is private method.
|
||||
* @return Is private method.
|
||||
*/
|
||||
public boolean isPrivate() {
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom namespace
|
||||
*/
|
||||
public String customNamespace;
|
||||
|
||||
/**
|
||||
* All opened namespaces
|
||||
*/
|
||||
public List<List<NamespaceItem>> allOpenedNamespaces;
|
||||
|
||||
//public boolean isInterface;
|
||||
/**
|
||||
* Constructor.
|
||||
* @param allOpenedNamespaces All opened namespaces
|
||||
* @param outsidePackage Is outside package
|
||||
* @param isPrivate Is private
|
||||
* @param metadata Metadata
|
||||
* @param pkg Package
|
||||
* @param isInterface Is interface
|
||||
* @param isNative Is native
|
||||
* @param customNamespace Custom namespace
|
||||
* @param needsActivation Needs activation
|
||||
* @param hasRest Has rest
|
||||
* @param line Line
|
||||
* @param override Override
|
||||
* @param isFinal Is final
|
||||
* @param isStatic Is static
|
||||
* @param methodName Method name
|
||||
* @param paramTypes Param types
|
||||
* @param paramNames Param names
|
||||
* @param paramValues Param values
|
||||
* @param body Body
|
||||
* @param subvariables Subvariables
|
||||
* @param retType Return type
|
||||
*/
|
||||
public MethodAVM2Item(List<List<NamespaceItem>> allOpenedNamespaces, boolean outsidePackage, boolean isPrivate, List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, boolean isNative, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, String methodName, List<GraphTargetItem> paramTypes, List<String> paramNames, List<GraphTargetItem> paramValues, List<GraphTargetItem> body, List<AssignableAVM2Item> subvariables, GraphTargetItem retType) {
|
||||
super(metadata, pkg, isInterface, isNative, needsActivation, hasRest, line, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType);
|
||||
this.outsidePackage = outsidePackage;
|
||||
@@ -57,17 +90,28 @@ public class MethodAVM2Item extends FunctionAVM2Item {
|
||||
this.isFinal = isFinal;
|
||||
this.isPrivate = isPrivate;
|
||||
this.customNamespace = customNamespace;
|
||||
//this.isInterface = this.isInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is override.
|
||||
* @return Is override
|
||||
*/
|
||||
public boolean isOverride() {
|
||||
return override;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is static.
|
||||
* @return Is static
|
||||
*/
|
||||
public boolean isStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is final.
|
||||
* @return Is final
|
||||
*/
|
||||
public boolean isFinal() {
|
||||
return isFinal;
|
||||
}
|
||||
|
||||
+108
@@ -57,22 +57,37 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
private int nsKind = -1;
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Line
|
||||
*/
|
||||
public int line;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public GraphTargetItem type;
|
||||
|
||||
private GraphTargetItem ns = null;
|
||||
|
||||
private int regNumber = -1;
|
||||
|
||||
/**
|
||||
* Unresolved
|
||||
*/
|
||||
public boolean unresolved = false;
|
||||
|
||||
private int slotNumber = -1;
|
||||
|
||||
private int slotScope = 0;
|
||||
|
||||
/**
|
||||
* Redirect
|
||||
*/
|
||||
public GraphTargetItem redirect;
|
||||
|
||||
private AbcIndexing abcIndex;
|
||||
@@ -89,66 +104,138 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is attribute.
|
||||
* @return Is attribute
|
||||
*/
|
||||
public boolean isAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets slot scope.
|
||||
* @param slotScope Slot scope
|
||||
*/
|
||||
public void setSlotScope(int slotScope) {
|
||||
this.slotScope = slotScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets slot scope.
|
||||
* @return Slot scope
|
||||
*/
|
||||
public int getSlotScope() {
|
||||
return slotScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets namespace.
|
||||
* @param ns Namespace
|
||||
*/
|
||||
public void setNs(GraphTargetItem ns) {
|
||||
this.ns = ns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets register number.
|
||||
* @param regNumber Register number
|
||||
*/
|
||||
public void setRegNumber(int regNumber) {
|
||||
this.regNumber = regNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets slot number.
|
||||
* @return Slot number
|
||||
*/
|
||||
public int getSlotNumber() {
|
||||
return slotNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets slot number.
|
||||
* @param slotNumber Slot number
|
||||
*/
|
||||
public void setSlotNumber(int slotNumber) {
|
||||
this.slotNumber = slotNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets register number.
|
||||
* @return Register number
|
||||
*/
|
||||
public int getRegNumber() {
|
||||
return regNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets namespace.
|
||||
* @return Namespace
|
||||
*/
|
||||
public GraphTargetItem getNs() {
|
||||
return ns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends name.
|
||||
* @param name Name
|
||||
*/
|
||||
public void appendName(String name) {
|
||||
this.variableName += "." + name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets definition.
|
||||
* @param definition Definition
|
||||
*/
|
||||
public void setDefinition(boolean definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets namespace kind.
|
||||
* @param nsKind Namespace kind
|
||||
*/
|
||||
public void setNsKind(int nsKind) {
|
||||
this.nsKind = nsKind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets namespace kind.
|
||||
* @return Namespace kind
|
||||
*/
|
||||
public int getNsKind() {
|
||||
return nsKind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets variable name.
|
||||
* @return Variable name
|
||||
*/
|
||||
public String getVariableName() {
|
||||
return variableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get namespace suffix.
|
||||
* @return Namespace suffix
|
||||
*/
|
||||
public String getNamespaceSuffix() {
|
||||
return namespaceSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param type Type
|
||||
* @param line Line
|
||||
* @param attribute Is attribute
|
||||
* @param variableName Variable name
|
||||
* @param namespaceSuffix Namespace suffix
|
||||
* @param storeValue Store value
|
||||
* @param definition Is definition
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param abcIndex ABC index
|
||||
*/
|
||||
public NameAVM2Item(GraphTargetItem type, int line, boolean attribute, String variableName, String namespaceSuffix, GraphTargetItem storeValue, boolean definition, List<NamespaceItem> openedNamespaces, AbcIndexing abcIndex) {
|
||||
super(storeValue);
|
||||
this.attribute = attribute;
|
||||
@@ -162,10 +249,18 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
this.abcIndex = abcIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is definition.
|
||||
* @return Is definition
|
||||
*/
|
||||
public boolean isDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets store value.
|
||||
* @return Store value
|
||||
*/
|
||||
public GraphTargetItem getStoreValue() {
|
||||
return assignedValue;
|
||||
}
|
||||
@@ -175,6 +270,11 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
return writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets default value for a type.
|
||||
* @param type Type
|
||||
* @return Default value
|
||||
*/
|
||||
public static GraphTargetItem getDefaultValue(String type) {
|
||||
switch (type) {
|
||||
case "*":
|
||||
@@ -190,6 +290,14 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates coerce.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param ttype Target type
|
||||
* @return Coerce instruction
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public static AVM2Instruction generateCoerce(SourceGeneratorLocalData localData, SourceGenerator generator, GraphTargetItem ttype) throws CompilationException {
|
||||
if (ttype instanceof UnresolvedAVM2Item) {
|
||||
ttype = ((UnresolvedAVM2Item) ttype).resolved;
|
||||
|
||||
+56
@@ -35,28 +35,58 @@ import java.util.Objects;
|
||||
*/
|
||||
public class NamespaceItem {
|
||||
|
||||
/**
|
||||
* Custom namespace.
|
||||
*/
|
||||
public static final int KIND_NAMESPACE_CUSTOM = -2;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
public DottedChain name;
|
||||
|
||||
/**
|
||||
* Kind
|
||||
*/
|
||||
public int kind;
|
||||
|
||||
/**
|
||||
* Namespace index
|
||||
*/
|
||||
private int nsIndex = -1;
|
||||
|
||||
/**
|
||||
* Force resolves namespace.
|
||||
* @param abcIndex ABC indexing
|
||||
*/
|
||||
public void forceResolve(AbcIndexing abcIndex) {
|
||||
nsIndex = abcIndex.getSelectedAbc().constants.getNamespaceId(kind, name, 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param name Name
|
||||
* @param kind Kind
|
||||
*/
|
||||
public NamespaceItem(DottedChain name, int kind) {
|
||||
this.name = name;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param name Name
|
||||
* @param kind Kind
|
||||
*/
|
||||
public NamespaceItem(String name, int kind) {
|
||||
this.name = DottedChain.parseWithSuffix(name);
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param nsIndex Namespace index
|
||||
*/
|
||||
public NamespaceItem(int nsIndex) {
|
||||
this.nsIndex = nsIndex;
|
||||
}
|
||||
@@ -87,6 +117,15 @@ public class NamespaceItem {
|
||||
return (this.kind == other.kind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves custom namespace.
|
||||
* @param abcIndex ABC indexing
|
||||
* @param importedClasses Imported classes
|
||||
* @param pkg Package
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param localData Local data
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public void resolveCustomNs(AbcIndexing abcIndex, List<DottedChain> importedClasses, DottedChain pkg, List<NamespaceItem> openedNamespaces, SourceGeneratorLocalData localData) throws CompilationException {
|
||||
if (nsIndex > -1) { //already resolved
|
||||
return;
|
||||
@@ -139,10 +178,20 @@ public class NamespaceItem {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if namespace is resolved.
|
||||
* @return True if namespace is resolved
|
||||
*/
|
||||
public boolean isResolved() {
|
||||
return nsIndex > -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets constant pool index.
|
||||
* @param abcIndex ABC indexing
|
||||
* @return Constant pool index
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public int getCpoolIndex(AbcIndexing abcIndex) throws CompilationException {
|
||||
if (nsIndex > -1) {
|
||||
return nsIndex;
|
||||
@@ -154,6 +203,13 @@ public class NamespaceItem {
|
||||
return nsIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets namespace set index.
|
||||
* @param abcIndex ABC indexing
|
||||
* @param namespaces Namespaces
|
||||
* @return Namespace set index
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public static int getCpoolSetIndex(AbcIndexing abcIndex, List<NamespaceItem> namespaces) throws CompilationException {
|
||||
int[] nssa = new int[namespaces.size()];
|
||||
for (int i = 0; i < nssa.length; i++) {
|
||||
|
||||
+40
@@ -42,18 +42,46 @@ import java.util.Objects;
|
||||
*/
|
||||
public class NamespacedAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
public GraphTargetItem ns;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* Name item
|
||||
*/
|
||||
public GraphTargetItem nameItem;
|
||||
|
||||
/**
|
||||
* Object
|
||||
*/
|
||||
public GraphTargetItem obj;
|
||||
|
||||
/**
|
||||
* Attribute
|
||||
*/
|
||||
public boolean attr;
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param ns Namespace
|
||||
* @param name Name
|
||||
* @param nameItem Name item
|
||||
* @param obj Object
|
||||
* @param attr Attribute
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param storeValue Store value
|
||||
*/
|
||||
public NamespacedAVM2Item(GraphTargetItem ns, String name, GraphTargetItem nameItem, GraphTargetItem obj, boolean attr, List<NamespaceItem> openedNamespaces, GraphTargetItem storeValue) {
|
||||
super(storeValue);
|
||||
this.ns = ns;
|
||||
@@ -150,6 +178,18 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to source.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param needsReturn Needs return
|
||||
* @param call Call
|
||||
* @param callargs Call arguments
|
||||
* @param delete Delete
|
||||
* @param construct Construct
|
||||
* @return Source
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn, boolean call, List<GraphTargetItem> callargs, boolean delete, boolean construct) throws CompilationException {
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
Reference<Integer> ns_temp = new Reference<>(-1);
|
||||
|
||||
+15
@@ -32,12 +32,27 @@ import java.util.List;
|
||||
*/
|
||||
public class PackageAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
public List<GraphTargetItem> items;
|
||||
|
||||
/**
|
||||
* Package name
|
||||
*/
|
||||
public DottedChain packageName;
|
||||
|
||||
/**
|
||||
* Imported classes
|
||||
*/
|
||||
public List<DottedChain> importedClasses = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param importedClasses Imported classes
|
||||
* @param packageName Package name
|
||||
* @param items Items
|
||||
*/
|
||||
public PackageAVM2Item(List<DottedChain> importedClasses, DottedChain packageName, List<GraphTargetItem> items) {
|
||||
super(null, null, NOPRECEDENCE);
|
||||
this.importedClasses = importedClasses;
|
||||
|
||||
+25
@@ -23,18 +23,38 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
|
||||
*/
|
||||
public class ParsedSymbol {
|
||||
|
||||
/**
|
||||
* Group
|
||||
*/
|
||||
public SymbolGroup group;
|
||||
|
||||
/**
|
||||
* Value
|
||||
*/
|
||||
public Object value;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public SymbolType type;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param group Group
|
||||
* @param type Type
|
||||
*/
|
||||
public ParsedSymbol(SymbolGroup group, SymbolType type) {
|
||||
this.group = group;
|
||||
this.type = type;
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param group Group
|
||||
* @param type Type
|
||||
* @param value Value
|
||||
*/
|
||||
public ParsedSymbol(SymbolGroup group, SymbolType type, Object value) {
|
||||
this.group = group;
|
||||
this.type = type;
|
||||
@@ -46,6 +66,11 @@ public class ParsedSymbol {
|
||||
return group.toString() + " " + type.toString() + " " + (value != null ? value.toString() : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if type is in types.
|
||||
* @param types Types
|
||||
* @return True if type is in types
|
||||
*/
|
||||
public boolean isType(Object... types) {
|
||||
for (Object t : types) {
|
||||
if (t instanceof SymbolGroup) {
|
||||
|
||||
+69
@@ -56,20 +56,44 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
/**
|
||||
* Attribute
|
||||
*/
|
||||
public boolean attribute;
|
||||
|
||||
/**
|
||||
* Property name
|
||||
*/
|
||||
public String propertyName;
|
||||
|
||||
/**
|
||||
* Object
|
||||
*/
|
||||
public GraphTargetItem object;
|
||||
|
||||
/**
|
||||
* ABC indexing
|
||||
*/
|
||||
public AbcIndexing abcIndex;
|
||||
|
||||
/**
|
||||
* Namespace suffix
|
||||
*/
|
||||
public String namespaceSuffix;
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
private final List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Call stack
|
||||
*/
|
||||
private final List<MethodBody> callStack;
|
||||
|
||||
/**
|
||||
* Scope stack
|
||||
*/
|
||||
public List<GraphTargetItem> scopeStack = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
@@ -78,6 +102,17 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object Object
|
||||
* @param attribute Attribute
|
||||
* @param propertyName Property name
|
||||
* @param namespaceSuffix Namespace suffix
|
||||
* @param abcIndex ABC indexing
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param callStack Call stack
|
||||
*/
|
||||
public PropertyAVM2Item(GraphTargetItem object, boolean attribute, String propertyName, String namespaceSuffix, AbcIndexing abcIndex, List<NamespaceItem> openedNamespaces, List<MethodBody> callStack) {
|
||||
this.attribute = attribute;
|
||||
this.propertyName = propertyName;
|
||||
@@ -102,6 +137,18 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
return abc.getSelectedAbc().constants.getNamespaceSetId(nssa, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves property.
|
||||
* @param mustExist Must exist
|
||||
* @param localData Local data
|
||||
* @param isType Is type
|
||||
* @param objectType Object type
|
||||
* @param propertyType Property type
|
||||
* @param propertyIndex Property index
|
||||
* @param propertyValue Property value
|
||||
* @param propertyValueABC Property value ABC
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public void resolve(boolean mustExist, SourceGeneratorLocalData localData, Reference<Boolean> isType, Reference<GraphTargetItem> objectType, Reference<GraphTargetItem> propertyType, Reference<Integer> propertyIndex, Reference<ValueKind> propertyValue, Reference<ABC> propertyValueABC) throws CompilationException {
|
||||
Integer namespaceSuffixInt = null;
|
||||
if (!"".equals(namespaceSuffix)) {
|
||||
@@ -365,6 +412,12 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
objectType.setVal(objType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves property.
|
||||
* @param localData Local data
|
||||
* @return Property index
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public int resolveProperty(SourceGeneratorLocalData localData) throws CompilationException {
|
||||
Reference<GraphTargetItem> objType = new Reference<>(null);
|
||||
Reference<GraphTargetItem> propType = new Reference<>(null);
|
||||
@@ -395,6 +448,14 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to source.
|
||||
* @param localData Local data
|
||||
* @param generator Source generator
|
||||
* @param needsReturn Needs return
|
||||
* @return Source
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
|
||||
Reference<GraphTargetItem> objType = new Reference<>(null);
|
||||
@@ -460,6 +521,14 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves object.
|
||||
* @param localData Local data
|
||||
* @param generator Source generator
|
||||
* @param mustExist Must exist
|
||||
* @return Object
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public Object resolveObject(SourceGeneratorLocalData localData, SourceGenerator generator, boolean mustExist) throws CompilationException {
|
||||
Object obj = object;
|
||||
|
||||
|
||||
+24
@@ -27,6 +27,30 @@ import java.util.Map;
|
||||
*/
|
||||
public class SetterAVM2Item extends MethodAVM2Item {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param allOpenedNamespaces All opened namespaces
|
||||
* @param outsidePackage Is outside package
|
||||
* @param isPrivate Is private
|
||||
* @param metadata Metadata
|
||||
* @param pkg Package
|
||||
* @param isInterface Is interface
|
||||
* @param isNative Is native
|
||||
* @param customNamespace Custom namespace
|
||||
* @param needsActivation Needs activation
|
||||
* @param hasRest Has rest
|
||||
* @param line Line
|
||||
* @param override Override
|
||||
* @param isFinal Is final
|
||||
* @param isStatic Is static
|
||||
* @param methodName Method name
|
||||
* @param paramTypes Parameter types
|
||||
* @param paramNames Parameter names
|
||||
* @param paramValues Parameter values
|
||||
* @param body Body
|
||||
* @param subvariables Subvariables
|
||||
* @param retType Return type
|
||||
*/
|
||||
public SetterAVM2Item(List<List<NamespaceItem>> allOpenedNamespaces, boolean outsidePackage, boolean isPrivate, List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, boolean isNative, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, String methodName, List<GraphTargetItem> paramTypes, List<String> paramNames, List<GraphTargetItem> paramValues, List<GraphTargetItem> body, List<AssignableAVM2Item> subvariables, GraphTargetItem retType) {
|
||||
super(allOpenedNamespaces, outsidePackage, isPrivate, metadata, pkg, isInterface, isNative, customNamespace, needsActivation, hasRest, line, override, isFinal, isStatic, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType);
|
||||
}
|
||||
|
||||
+36
@@ -30,24 +30,60 @@ import java.util.Map;
|
||||
*/
|
||||
public class SlotAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Is static
|
||||
*/
|
||||
private final boolean isStatic;
|
||||
|
||||
/**
|
||||
* Variable
|
||||
*/
|
||||
public String var;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public GraphTargetItem type;
|
||||
|
||||
/**
|
||||
* Custom namespace
|
||||
*/
|
||||
public String customNamespace;
|
||||
|
||||
/**
|
||||
* Line
|
||||
*/
|
||||
public int line;
|
||||
|
||||
/**
|
||||
* Metadata
|
||||
*/
|
||||
public List<Map.Entry<String, Map<String, String>>> metadata;
|
||||
|
||||
/**
|
||||
* Package
|
||||
*/
|
||||
public NamespaceItem pkg;
|
||||
|
||||
/**
|
||||
* Is static.
|
||||
* @return Is static
|
||||
*/
|
||||
public boolean isStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param metadata Metadata
|
||||
* @param pkg Package
|
||||
* @param customNamespace Custom namespace
|
||||
* @param isStatic Is static
|
||||
* @param var Variable
|
||||
* @param type Type
|
||||
* @param value Value
|
||||
* @param line Line
|
||||
*/
|
||||
public SlotAVM2Item(List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, String customNamespace, boolean isStatic, String var, GraphTargetItem type, GraphTargetItem value, int line) {
|
||||
super(null, null, NOPRECEDENCE, value);
|
||||
this.metadata = metadata;
|
||||
|
||||
+42
-1
@@ -23,19 +23,60 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
|
||||
*/
|
||||
public enum SymbolGroup {
|
||||
|
||||
/**
|
||||
* Operator
|
||||
*/
|
||||
OPERATOR,
|
||||
/**
|
||||
* Keyword
|
||||
*/
|
||||
KEYWORD,
|
||||
/**
|
||||
* Separator
|
||||
*/
|
||||
STRING,
|
||||
/**
|
||||
* Comment
|
||||
*/
|
||||
COMMENT,
|
||||
/**
|
||||
* XML
|
||||
*/
|
||||
XML,
|
||||
/**
|
||||
* Identifier
|
||||
*/
|
||||
IDENTIFIER,
|
||||
/**
|
||||
* Integer
|
||||
*/
|
||||
INTEGER,
|
||||
/**
|
||||
* Double
|
||||
*/
|
||||
DOUBLE,
|
||||
/**
|
||||
* Type name
|
||||
*/
|
||||
TYPENAME,
|
||||
/**
|
||||
* End of file
|
||||
*/
|
||||
EOF,
|
||||
//GLOBALFUNC,
|
||||
/**
|
||||
* Global constant
|
||||
*/
|
||||
GLOBALCONST,
|
||||
/**
|
||||
* Preprocessor directive
|
||||
*/
|
||||
PREPROCESSOR,
|
||||
/**
|
||||
* Regular expression
|
||||
*/
|
||||
REGEXP,
|
||||
/**
|
||||
* Namespace suffix
|
||||
*/
|
||||
NAMESPACESUFFIX
|
||||
}
|
||||
|
||||
+439
-51
@@ -24,196 +24,572 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum SymbolType {
|
||||
//Keywords
|
||||
|
||||
/**
|
||||
* Keyword: break
|
||||
*/
|
||||
BREAK,
|
||||
/**
|
||||
* Keyword: case
|
||||
*/
|
||||
CASE,
|
||||
/**
|
||||
* Keyword: continue
|
||||
*/
|
||||
CONTINUE,
|
||||
/**
|
||||
* Keyword: default
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* Keyword: do
|
||||
*/
|
||||
DO,
|
||||
/**
|
||||
* Keyword: while
|
||||
*/
|
||||
WHILE,
|
||||
/**
|
||||
* Keyword: else
|
||||
*/
|
||||
ELSE,
|
||||
/**
|
||||
* Keyword: for
|
||||
*/
|
||||
FOR,
|
||||
/**
|
||||
* Keyword: each
|
||||
*/
|
||||
EACH,
|
||||
/**
|
||||
* Keyword: in
|
||||
*/
|
||||
IN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Keyword: if
|
||||
*/
|
||||
IF,
|
||||
/**
|
||||
* Keyword: return
|
||||
*/
|
||||
RETURN,
|
||||
/**
|
||||
* Keyword: super
|
||||
*/
|
||||
SUPER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Keyword: switch
|
||||
*/
|
||||
SWITCH,
|
||||
/**
|
||||
* Keyword: throw
|
||||
*/
|
||||
THROW,
|
||||
/**
|
||||
* Keyword: try
|
||||
*/
|
||||
TRY,
|
||||
/**
|
||||
* Keyword: catch
|
||||
*/
|
||||
CATCH,
|
||||
/**
|
||||
* Keyword: finally
|
||||
*/
|
||||
FINALLY,
|
||||
/**
|
||||
* Keyword: with
|
||||
*/
|
||||
WITH,
|
||||
/**
|
||||
* Keyword: dynamic
|
||||
*/
|
||||
DYNAMIC,
|
||||
/**
|
||||
* Keyword: internal
|
||||
*/
|
||||
INTERNAL,
|
||||
/**
|
||||
* Keyword: override
|
||||
*/
|
||||
OVERRIDE,
|
||||
/**
|
||||
* Keyword: private
|
||||
*/
|
||||
PRIVATE,
|
||||
/**
|
||||
* Keyword: protected
|
||||
*/
|
||||
PROTECTED,
|
||||
/**
|
||||
* Keyword: public
|
||||
*/
|
||||
PUBLIC,
|
||||
/**
|
||||
* Keyword: static
|
||||
*/
|
||||
STATIC,
|
||||
/**
|
||||
* Keyword: class
|
||||
*/
|
||||
CLASS,
|
||||
/**
|
||||
* Keyword: const
|
||||
*/
|
||||
CONST,
|
||||
/**
|
||||
* Keyword: extends
|
||||
*/
|
||||
EXTENDS,
|
||||
/**
|
||||
* Keyword: function
|
||||
*/
|
||||
FUNCTION(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Keyword: get
|
||||
*/
|
||||
GET,
|
||||
/**
|
||||
* Keyword: implements
|
||||
*/
|
||||
IMPLEMENTS,
|
||||
/**
|
||||
* Keyword: interface
|
||||
*/
|
||||
INTERFACE,
|
||||
/**
|
||||
* Keyword: namespace
|
||||
*/
|
||||
NAMESPACE,
|
||||
/**
|
||||
* Keyword: package
|
||||
*/
|
||||
PACKAGE,
|
||||
/**
|
||||
* Keyword: set
|
||||
*/
|
||||
SET,
|
||||
/**
|
||||
* Keyword: var
|
||||
*/
|
||||
VAR,
|
||||
/**
|
||||
* Keyword: import
|
||||
*/
|
||||
IMPORT,
|
||||
/**
|
||||
* Keyword: use
|
||||
*/
|
||||
USE,
|
||||
/**
|
||||
* Keyword: false
|
||||
*/
|
||||
FALSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Keyword: null
|
||||
*/
|
||||
NULL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Keyword: this
|
||||
*/
|
||||
THIS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Keyword: true
|
||||
*/
|
||||
TRUE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//Operators
|
||||
|
||||
/**
|
||||
* Operator: (
|
||||
*/
|
||||
PARENT_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
|
||||
/**
|
||||
* Operator: )
|
||||
*/
|
||||
PARENT_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
|
||||
/**
|
||||
* Operator: {
|
||||
*/
|
||||
CURLY_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
|
||||
/**
|
||||
* Operator: }
|
||||
*/
|
||||
CURLY_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
|
||||
/**
|
||||
* Operator: [
|
||||
*/
|
||||
BRACKET_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
|
||||
/**
|
||||
* Operator: ]
|
||||
*/
|
||||
BRACKET_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
|
||||
/**
|
||||
* Operator: ;
|
||||
*/
|
||||
SEMICOLON,
|
||||
|
||||
/**
|
||||
* Operator: ,
|
||||
*/
|
||||
COMMA(GraphTargetItem.PRECEDENCE_COMMA, false),
|
||||
|
||||
/**
|
||||
* Operator: ...
|
||||
*/
|
||||
REST,
|
||||
|
||||
/**
|
||||
* Operator: .
|
||||
*/
|
||||
DOT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Operator: =
|
||||
*/
|
||||
ASSIGN(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: >
|
||||
*/
|
||||
GREATER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Operator: <
|
||||
*/
|
||||
LOWER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Operator: !
|
||||
*/
|
||||
NOT(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
/**
|
||||
* Operator: ~
|
||||
*/
|
||||
NEGATE(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
/**
|
||||
* Operator: ?
|
||||
*/
|
||||
TERNAR(GraphTargetItem.PRECEDENCE_CONDITIONAL, true, true), /*!! ternar !!!*/
|
||||
/**
|
||||
* Operator: :
|
||||
*/
|
||||
COLON(GraphTargetItem.PRECEDENCE_CONDITIONAL, false), /*!! ternar !!!*/
|
||||
/**
|
||||
* Operator: ==
|
||||
*/
|
||||
EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
/**
|
||||
* Operator: ===
|
||||
*/
|
||||
STRICT_EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
/**
|
||||
* Operator: <=
|
||||
*/
|
||||
LOWER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Operator: >=
|
||||
*/
|
||||
GREATER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Operator: !=
|
||||
*/
|
||||
NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
/**
|
||||
* Operator: !==
|
||||
*/
|
||||
STRICT_NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
/**
|
||||
* Operator: &&
|
||||
*/
|
||||
AND(GraphTargetItem.PRECEDENCE_LOGICALAND, true),
|
||||
/**
|
||||
* Operator: ||
|
||||
*/
|
||||
OR(GraphTargetItem.PRECEDENCE_LOGICALOR, true),
|
||||
/**
|
||||
* Operator: ++
|
||||
*/
|
||||
INCREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false), //OR Unary
|
||||
/**
|
||||
* Operator: --
|
||||
*/
|
||||
DECREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false), //OR Unary
|
||||
/**
|
||||
* Operator: +
|
||||
*/
|
||||
PLUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true),
|
||||
/**
|
||||
* Operator: -
|
||||
*/
|
||||
MINUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true), //OR Unary
|
||||
/**
|
||||
* Operator: *
|
||||
*/
|
||||
MULTIPLY(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
|
||||
/**
|
||||
* Operator: /
|
||||
*/
|
||||
DIVIDE(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
|
||||
/**
|
||||
* Operator: &
|
||||
*/
|
||||
BITAND(GraphTargetItem.PRECEDENCE_BITWISEAND, true),
|
||||
/**
|
||||
* Operator: |
|
||||
*/
|
||||
BITOR(GraphTargetItem.PRECEDENCE_BITWISEOR, true),
|
||||
/**
|
||||
* Operator: ^
|
||||
*/
|
||||
XOR(GraphTargetItem.PRECEDENCE_BITWISEXOR, true),
|
||||
/**
|
||||
* Operator: %
|
||||
*/
|
||||
MODULO(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
|
||||
/**
|
||||
* Operator: <<
|
||||
*/
|
||||
SHIFT_LEFT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
/**
|
||||
* Operator: >>
|
||||
*/
|
||||
SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
/**
|
||||
* Operator: >>>
|
||||
*/
|
||||
USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
/**
|
||||
* Operator: +=
|
||||
*/
|
||||
ASSIGN_PLUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: -=
|
||||
*/
|
||||
ASSIGN_MINUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: *=
|
||||
*/
|
||||
ASSIGN_MULTIPLY(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: /=
|
||||
*/
|
||||
ASSIGN_DIVIDE(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: &=
|
||||
*/
|
||||
ASSIGN_BITAND(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: |=
|
||||
*/
|
||||
ASSIGN_BITOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: ^=
|
||||
*/
|
||||
ASSIGN_XOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: %=
|
||||
*/
|
||||
ASSIGN_MODULO(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: <<=
|
||||
*/
|
||||
ASSIGN_SHIFT_LEFT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: >>=
|
||||
*/
|
||||
ASSIGN_SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: >>>=
|
||||
*/
|
||||
ASSIGN_USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: &&=
|
||||
*/
|
||||
ASSIGN_AND(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: ||=
|
||||
*/
|
||||
ASSIGN_OR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
/**
|
||||
* Operator: as
|
||||
*/
|
||||
AS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Operator: delete
|
||||
*/
|
||||
DELETE(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
/**
|
||||
* Operator: instanceof
|
||||
*/
|
||||
INSTANCEOF(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Operator: is
|
||||
*/
|
||||
IS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
/**
|
||||
* Operator: ::
|
||||
*/
|
||||
NAMESPACE_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Operator: new
|
||||
*/
|
||||
NEW(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Operator: typeof
|
||||
*/
|
||||
TYPEOF(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
/**
|
||||
* Operator: void
|
||||
*/
|
||||
VOID,
|
||||
/**
|
||||
* Operator: @
|
||||
*/
|
||||
ATTRIBUTE,
|
||||
//Other
|
||||
/**
|
||||
* Other: String
|
||||
*/
|
||||
STRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: Comment
|
||||
*/
|
||||
COMMENT,
|
||||
//XML,
|
||||
/**
|
||||
* Other: Identifier
|
||||
*/
|
||||
IDENTIFIER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: Integer
|
||||
*/
|
||||
INTEGER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: Double
|
||||
*/
|
||||
DOUBLE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: Type name
|
||||
*/
|
||||
TYPENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: End of file
|
||||
*/
|
||||
EOF,
|
||||
//TRACE,
|
||||
//GETURL,
|
||||
//GOTOANDSTOP,
|
||||
//NEXTFRAME,
|
||||
//PLAY,
|
||||
//PREVFRAME,
|
||||
//TELLTARGET,
|
||||
//STOP,
|
||||
//STOPALLSOUNDS,
|
||||
//TOGGLEHIGHQUALITY,
|
||||
//ORD,
|
||||
//CHR,
|
||||
//DUPLICATEMOVIECLIP,
|
||||
//STOPDRAG,
|
||||
//GETTIMER,
|
||||
//LOADVARIABLES,
|
||||
//LOADMOVIE,
|
||||
//GOTOANDPLAY,
|
||||
//MBORD,
|
||||
//MBCHR,
|
||||
//MBLENGTH,
|
||||
//MBSUBSTRING,
|
||||
//RANDOM,
|
||||
//REMOVEMOVIECLIP,
|
||||
//STARTDRAG,
|
||||
//SUBSTR,
|
||||
//LENGTH, //string.length
|
||||
INT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//TARGETPATH,
|
||||
/**
|
||||
* Other: Number op
|
||||
*/
|
||||
NUMBER_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: String op
|
||||
*/
|
||||
STRING_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//IFFRAMELOADED,
|
||||
/**
|
||||
* Other: Infinity
|
||||
*/
|
||||
INFINITY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//EVAL,
|
||||
/**
|
||||
* Other: undefined
|
||||
*/
|
||||
UNDEFINED(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//NEWLINE,
|
||||
/**
|
||||
* Other: NaN
|
||||
*/
|
||||
NAN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//GETVERSION,
|
||||
//CALL,
|
||||
//LOADMOVIENUM,
|
||||
//LOADVARIABLESNUM,
|
||||
//PRINT,
|
||||
//PRINTNUM,
|
||||
//PRINTASBITMAP,
|
||||
//PRINTASBITMAPNUM,
|
||||
//UNLOADMOVIE,
|
||||
//UNLOADMOVIENUM,
|
||||
/**
|
||||
* Keyword: final
|
||||
*/
|
||||
FINAL,
|
||||
/**
|
||||
* XML: Start tag
|
||||
*/
|
||||
XML_STARTTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <xxx
|
||||
/**
|
||||
* XML: Start variable tag
|
||||
*/
|
||||
XML_STARTVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <{
|
||||
/**
|
||||
* XML: Start tag end
|
||||
*/
|
||||
XML_STARTTAG_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // >
|
||||
/**
|
||||
* XML: Finish variable tag
|
||||
*/
|
||||
XML_FINISHVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // </{
|
||||
/**
|
||||
* XML: Finish tag
|
||||
*/
|
||||
XML_FINISHTAG(GraphTargetItem.PRECEDENCE_PRIMARY, false), // </xxx>
|
||||
/**
|
||||
* XML: Start finish tag end
|
||||
*/
|
||||
XML_STARTFINISHTAG_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // />
|
||||
/**
|
||||
* XML: Comment
|
||||
*/
|
||||
XML_COMMENT(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <!-- ... -->
|
||||
/**
|
||||
* XML: CDATA
|
||||
*/
|
||||
XML_CDATA(GraphTargetItem.PRECEDENCE_PRIMARY, false), //<![CDATA[ ... ]]>
|
||||
/**
|
||||
* XML: Processing instruction
|
||||
*/
|
||||
XML_INSTR(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?xxx a b c ?>
|
||||
//XML_INSTR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?xxx
|
||||
//XML_INSTR_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // ?>
|
||||
/**
|
||||
* XML: variable begin
|
||||
*/
|
||||
XML_VAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {
|
||||
/**
|
||||
* XML: attribute name
|
||||
*/
|
||||
XML_ATTRIBUTENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa=
|
||||
/**
|
||||
* XML: attribute value
|
||||
*/
|
||||
XML_ATTRIBUTEVALUE(GraphTargetItem.PRECEDENCE_PRIMARY, false), // "vvv"
|
||||
/**
|
||||
* XML: text
|
||||
*/
|
||||
XML_TEXT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* XML: variable attribute name begin
|
||||
*/
|
||||
XML_ATTRNAMEVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {...}=
|
||||
/**
|
||||
* XML: variable attribute value end
|
||||
*/
|
||||
XML_ATTRVALVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa={
|
||||
/**
|
||||
* XML: end
|
||||
*/
|
||||
XML_END(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* XML: whitespace
|
||||
*/
|
||||
XML_WHITESPACE(GraphTargetItem.PRECEDENCE_PRIMARY, false), //only when enabled - for example for XML
|
||||
//XML_INSTRATTRNAMEVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {...}=
|
||||
// XML_INSTRATTRVALVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa={
|
||||
//XML_INSTRVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?{
|
||||
/**
|
||||
* Operator: .(
|
||||
*/
|
||||
FILTER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Operator: ..
|
||||
*/
|
||||
DESCENDANTS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Keyword: native
|
||||
*/
|
||||
NATIVE,
|
||||
/**
|
||||
* Operator: §§
|
||||
*/
|
||||
PREPROCESSOR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: regular expression
|
||||
*/
|
||||
REGEXP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: namespace suffix
|
||||
*/
|
||||
NAMESPACESUFFIX;
|
||||
|
||||
private int precedence = GraphTargetItem.NOPRECEDENCE;
|
||||
@@ -222,14 +598,26 @@ public enum SymbolType {
|
||||
|
||||
private boolean rightAssociative = false;
|
||||
|
||||
/**
|
||||
* Checks if the symbol is binary operator.
|
||||
* @return True if the symbol is binary operator
|
||||
*/
|
||||
public boolean isBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the symbol is right associative.
|
||||
* @return True if the symbol is right associative
|
||||
*/
|
||||
public boolean isRightAssociative() {
|
||||
return rightAssociative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the precedence of the symbol.
|
||||
* @return Precedence of the symbol
|
||||
*/
|
||||
public int getPrecedence() {
|
||||
return precedence;
|
||||
}
|
||||
|
||||
+123
-8
@@ -54,25 +54,54 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
private int nsKind = -1;
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Line
|
||||
*/
|
||||
public int line;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public GraphTargetItem type;
|
||||
|
||||
//private GraphTargetItem ns = null;
|
||||
/**
|
||||
* Resolved
|
||||
*/
|
||||
public GraphTargetItem resolved;
|
||||
|
||||
/**
|
||||
* Resolved root
|
||||
*/
|
||||
public GraphTargetItem resolvedRoot;
|
||||
|
||||
/**
|
||||
* Must be type
|
||||
*/
|
||||
private final boolean mustBeType;
|
||||
|
||||
/**
|
||||
* Imported classes
|
||||
*/
|
||||
public List<DottedChain> importedClasses;
|
||||
|
||||
/**
|
||||
* Scope stack
|
||||
*/
|
||||
public List<GraphTargetItem> scopeStack = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Subtypes
|
||||
*/
|
||||
public List<GraphTargetItem> subtypes;
|
||||
|
||||
/**
|
||||
* ABC index
|
||||
*/
|
||||
private AbcIndexing abcIndex;
|
||||
|
||||
@Override
|
||||
@@ -84,12 +113,20 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets slot scope.
|
||||
* @param slotScope Slot scope
|
||||
*/
|
||||
public void setSlotScope(int slotScope) {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
((NameAVM2Item) resolved).setSlotScope(slotScope);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets slot scope.
|
||||
* @return Slot scope
|
||||
*/
|
||||
public int getSlotScope() {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
return ((NameAVM2Item) resolved).getSlotScope();
|
||||
@@ -97,15 +134,20 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*public void setNs(GraphTargetItem ns) {
|
||||
this.ns = ns;
|
||||
}*/
|
||||
/**
|
||||
* Sets reg number.
|
||||
* @param regNumber Reg number
|
||||
*/
|
||||
public void setRegNumber(int regNumber) {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
((NameAVM2Item) resolved).setRegNumber(regNumber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets slot number.
|
||||
* @return Slot number
|
||||
*/
|
||||
public int getSlotNumber() {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
return ((NameAVM2Item) resolved).getSlotNumber();
|
||||
@@ -113,12 +155,20 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets slot number.
|
||||
* @param slotNumber Slot number
|
||||
*/
|
||||
public void setSlotNumber(int slotNumber) {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
((NameAVM2Item) resolved).setSlotNumber(slotNumber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets reg number.
|
||||
* @return Reg number
|
||||
*/
|
||||
public int getRegNumber() {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
return ((NameAVM2Item) resolved).getRegNumber();
|
||||
@@ -126,25 +176,36 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
public GraphTargetItem getNs() {
|
||||
return ns;
|
||||
}
|
||||
/**
|
||||
* Appends name.
|
||||
* @param name Name
|
||||
*/
|
||||
public void appendName(String name) {
|
||||
this.name = this.name.addWithSuffix(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets definition.
|
||||
* @param definition Definition
|
||||
*/
|
||||
public void setDefinition(boolean definition) {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
((NameAVM2Item) resolved).setDefinition(definition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets namespace kind.
|
||||
* @param nsKind Namespace kind
|
||||
*/
|
||||
public void setNsKind(int nsKind) {
|
||||
this.nsKind = nsKind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets namespace kind.
|
||||
* @return Namespace kind
|
||||
*/
|
||||
public int getNsKind() {
|
||||
return nsKind;
|
||||
}
|
||||
@@ -154,14 +215,34 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
this.assignedValue = storeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets variable name.
|
||||
* @return Variable name
|
||||
*/
|
||||
public DottedChain getVariableName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets variable name.
|
||||
* @param name Variable name
|
||||
*/
|
||||
public void setVariableName(DottedChain name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param subtypes Subtypes
|
||||
* @param importedClasses Imported classes
|
||||
* @param mustBeType Must be type
|
||||
* @param type Type
|
||||
* @param line Line
|
||||
* @param name Name
|
||||
* @param storeValue Store value
|
||||
* @param openedNamespaces Opened namespaces
|
||||
* @param abcIndex ABC index
|
||||
*/
|
||||
public UnresolvedAVM2Item(List<GraphTargetItem> subtypes, List<DottedChain> importedClasses, boolean mustBeType, GraphTargetItem type, int line, DottedChain name, GraphTargetItem storeValue, List<NamespaceItem> openedNamespaces, AbcIndexing abcIndex) {
|
||||
super(storeValue);
|
||||
this.name = name;
|
||||
@@ -175,6 +256,10 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
this.abcIndex = abcIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is definition.
|
||||
* @return True if is definition
|
||||
*/
|
||||
public boolean isDefinition() {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
return ((NameAVM2Item) resolved).isDefinition();
|
||||
@@ -182,6 +267,10 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets store value.
|
||||
* @return Store value
|
||||
*/
|
||||
public GraphTargetItem getStoreValue() {
|
||||
return assignedValue;
|
||||
}
|
||||
@@ -191,6 +280,11 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets default value for type.
|
||||
* @param type Type
|
||||
* @return Default value
|
||||
*/
|
||||
public static GraphTargetItem getDefaultValue(String type) {
|
||||
switch (type) {
|
||||
case "*":
|
||||
@@ -206,6 +300,14 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates coerce.
|
||||
* @param localData Local data
|
||||
* @param generator Generator
|
||||
* @param type Type
|
||||
* @return Coerce instruction
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public static AVM2Instruction generateCoerce(SourceGeneratorLocalData localData, SourceGenerator generator, GraphTargetItem type) throws CompilationException {
|
||||
AVM2Instruction ins;
|
||||
switch (type.toString()) {
|
||||
@@ -288,6 +390,19 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
throw new CompilationException("Cannot assign", line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves.
|
||||
* @param localData Local data
|
||||
* @param currentClassFullName Current class full name
|
||||
* @param thisType This type
|
||||
* @param paramTypes Parameter types
|
||||
* @param paramNames Parameter names
|
||||
* @param abc ABC
|
||||
* @param callStack Call stack
|
||||
* @param variables Variables
|
||||
* @return Resolved item
|
||||
* @throws CompilationException On compilation error
|
||||
*/
|
||||
public GraphTargetItem resolve(SourceGeneratorLocalData localData /*can be null!!!*/, String currentClassFullName, GraphTargetItem thisType, List<GraphTargetItem> paramTypes, List<String> paramNames, AbcIndexing abc, List<MethodBody> callStack, List<AssignableAVM2Item> variables) throws CompilationException {
|
||||
if (scopeStack.isEmpty()) { //Everything is multiname property in with command
|
||||
|
||||
|
||||
+4
@@ -39,6 +39,10 @@ import java.util.List;
|
||||
*/
|
||||
public class XMLAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param value Value
|
||||
*/
|
||||
public XMLAVM2Item(GraphTargetItem value) {
|
||||
super(null, null, PRECEDENCE_PRIMARY, value);
|
||||
}
|
||||
|
||||
+12
@@ -35,10 +35,22 @@ import java.util.List;
|
||||
*/
|
||||
public class XMLFilterAVM2Item extends AVM2Item {
|
||||
|
||||
/**
|
||||
* Opened namespaces
|
||||
*/
|
||||
public List<NamespaceItem> openedNamespaces;
|
||||
|
||||
/**
|
||||
* Object
|
||||
*/
|
||||
public GraphTargetItem object;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param object Object
|
||||
* @param value Value
|
||||
* @param openedNamespaces Opened namespaces
|
||||
*/
|
||||
public XMLFilterAVM2Item(GraphTargetItem object, GraphTargetItem value, List<NamespaceItem> openedNamespaces) {
|
||||
super(null, null, NOPRECEDENCE, value);
|
||||
this.openedNamespaces = openedNamespaces;
|
||||
|
||||
+23
@@ -33,6 +33,14 @@ import java.util.List;
|
||||
*/
|
||||
public class MethodInfoParser {
|
||||
|
||||
/**
|
||||
* Parses slot const.
|
||||
* @param text Text to parse
|
||||
* @param trait Trait to update
|
||||
* @param abc ABC file
|
||||
* @return True if successful
|
||||
* @throws MethodInfoParseException On parse error
|
||||
*/
|
||||
public static boolean parseSlotConst(String text, TraitSlotConst trait, ABC abc) throws MethodInfoParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new java.io.InputStreamReader(new ByteArrayInputStream(text.getBytes())));
|
||||
ParsedSymbol symb;
|
||||
@@ -123,6 +131,13 @@ public class MethodInfoParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses return type.
|
||||
* @param text Text to parse
|
||||
* @param update Method info to update
|
||||
* @return True if successful
|
||||
* @throws MethodInfoParseException On parse error
|
||||
*/
|
||||
public static boolean parseReturnType(String text, MethodInfo update) throws MethodInfoParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new java.io.InputStreamReader(new ByteArrayInputStream(text.getBytes())));
|
||||
ParsedSymbol symb;
|
||||
@@ -148,6 +163,14 @@ public class MethodInfoParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses parameters.
|
||||
* @param text Text to parse
|
||||
* @param update Method info to update
|
||||
* @param abc ABC file
|
||||
* @return True if successful
|
||||
* @throws MethodInfoParseException On parse error
|
||||
*/
|
||||
public static boolean parseParams(String text, MethodInfo update, ABC abc) throws MethodInfoParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new java.io.InputStreamReader(new ByteArrayInputStream(text.getBytes())));
|
||||
List<String> paramNames = new ArrayList<>();
|
||||
|
||||
+82
@@ -23,60 +23,142 @@ package com.jpexs.decompiler.flash.abc.methodinfoparser;
|
||||
*/
|
||||
public class ParsedSymbol {
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public int type;
|
||||
|
||||
/**
|
||||
* Value
|
||||
*/
|
||||
public Object value;
|
||||
|
||||
/**
|
||||
* Type: Integer
|
||||
*/
|
||||
public static final int TYPE_INTEGER = 1;
|
||||
|
||||
/**
|
||||
* Type: Float
|
||||
*/
|
||||
public static final int TYPE_FLOAT = 2;
|
||||
|
||||
/**
|
||||
* Type: True
|
||||
*/
|
||||
public static final int TYPE_TRUE = 3;
|
||||
|
||||
/**
|
||||
* Type: False
|
||||
*/
|
||||
public static final int TYPE_FALSE = 4;
|
||||
|
||||
/**
|
||||
* Type: Null
|
||||
*/
|
||||
public static final int TYPE_NULL = 5;
|
||||
|
||||
/**
|
||||
* Type: Undefined
|
||||
*/
|
||||
public static final int TYPE_UNDEFINED = 6;
|
||||
|
||||
/**
|
||||
* Type: String
|
||||
*/
|
||||
public static final int TYPE_STRING = 7;
|
||||
|
||||
//8-12 namespace prefix
|
||||
|
||||
/**
|
||||
* Type: Private
|
||||
*/
|
||||
public static final int TYPE_PRIVATE = 8;
|
||||
|
||||
/**
|
||||
* Type: Package
|
||||
*/
|
||||
public static final int TYPE_PACKAGE = 9;
|
||||
|
||||
/**
|
||||
* Type: Internal
|
||||
*/
|
||||
public static final int TYPE_INTERNAL = 10;
|
||||
|
||||
/**
|
||||
* Type: Static
|
||||
*/
|
||||
public static final int TYPE_STATIC = 11;
|
||||
|
||||
/**
|
||||
* Type: Explicit
|
||||
*/
|
||||
public static final int TYPE_EXPLICIT = 12;
|
||||
|
||||
/**
|
||||
* Type: Protected
|
||||
*/
|
||||
public static final int TYPE_PROTECTED = 13;
|
||||
|
||||
/**
|
||||
* Type: Namespace
|
||||
*/
|
||||
public static final int TYPE_NAMESPACE = 14;
|
||||
|
||||
/**
|
||||
* Type: Colon
|
||||
*/
|
||||
public static final int TYPE_COLON = 15;
|
||||
|
||||
/**
|
||||
* Type: Comma
|
||||
*/
|
||||
public static final int TYPE_COMMA = 16;
|
||||
|
||||
/**
|
||||
* Type: Dots
|
||||
*/
|
||||
public static final int TYPE_DOTS = 17;
|
||||
|
||||
/**
|
||||
* Type: Multiname
|
||||
*/
|
||||
public static final int TYPE_MULTINAME = 18;
|
||||
|
||||
/**
|
||||
* Type: Identifier
|
||||
*/
|
||||
public static final int TYPE_IDENTIFIER = 19;
|
||||
|
||||
/**
|
||||
* Type: End of file
|
||||
*/
|
||||
public static final int TYPE_EOF = 20;
|
||||
|
||||
/**
|
||||
* Type: Star
|
||||
*/
|
||||
public static final int TYPE_STAR = 21;
|
||||
|
||||
/**
|
||||
* Type: Assign
|
||||
*/
|
||||
public static final int TYPE_ASSIGN = 22;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param type Type
|
||||
* @param value Value
|
||||
*/
|
||||
public ParsedSymbol(int type, Object value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param type Type
|
||||
*/
|
||||
public ParsedSymbol(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
+7
@@ -28,6 +28,13 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio
|
||||
|
||||
private final int classIndex;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param classIndex Class index
|
||||
* @param scriptIndex Script index
|
||||
*/
|
||||
public ClassNameMultinameUsage(ABC abc, int multinameIndex, int classIndex, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.classIndex = classIndex;
|
||||
|
||||
+11
@@ -34,6 +34,17 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public ConstVarMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
|
||||
}
|
||||
|
||||
+11
@@ -26,6 +26,17 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
*/
|
||||
public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage implements DefinitionUsage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public ConstVarNameMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
|
||||
}
|
||||
|
||||
+11
@@ -26,6 +26,17 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
*/
|
||||
public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public ConstVarTypeMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
|
||||
}
|
||||
|
||||
+12
@@ -26,6 +26,18 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
*/
|
||||
public class MethodBodyMultinameUsage extends MethodMultinameUsage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param isInitializer Is initializer
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public MethodBodyMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, isInitializer, traits, parentTraitIndex);
|
||||
}
|
||||
|
||||
+20
@@ -35,11 +35,27 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
|
||||
|
||||
private boolean isInitializer;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param isInitializer Is initializer
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public MethodMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
|
||||
this.isInitializer = isInitializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is initializer.
|
||||
* @return Is initializer
|
||||
*/
|
||||
public boolean isInitializer() {
|
||||
return isInitializer;
|
||||
}
|
||||
@@ -123,6 +139,10 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is static.
|
||||
* @return Is static
|
||||
*/
|
||||
public boolean isStatic() {
|
||||
return traitsType == TRAITS_TYPE_CLASS;
|
||||
}
|
||||
|
||||
+12
@@ -26,6 +26,18 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
*/
|
||||
public class MethodNameMultinameUsage extends MethodMultinameUsage implements DefinitionUsage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param isInitializer Is initializer
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public MethodNameMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, isInitializer, traits, parentTraitIndex);
|
||||
}
|
||||
|
||||
+12
@@ -26,6 +26,18 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
*/
|
||||
public class MethodParamsMultinameUsage extends MethodMultinameUsage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param isInitializer Is initializer
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public MethodParamsMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, isInitializer, traits, parentTraitIndex);
|
||||
}
|
||||
|
||||
+12
@@ -26,6 +26,18 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
*/
|
||||
public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param isInitializer Is initializer
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public MethodReturnTypeMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, isInitializer, traits, parentTraitIndex);
|
||||
}
|
||||
|
||||
+29
@@ -30,12 +30,27 @@ import java.util.Objects;
|
||||
*/
|
||||
public abstract class MultinameUsage implements Usage {
|
||||
|
||||
/**
|
||||
* ABC
|
||||
*/
|
||||
protected final ABC abc;
|
||||
|
||||
/**
|
||||
* Multiname index
|
||||
*/
|
||||
private final int multinameIndex;
|
||||
|
||||
/**
|
||||
* Script index
|
||||
*/
|
||||
protected int scriptIndex;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
*/
|
||||
public MultinameUsage(ABC abc, int multinameIndex, int scriptIndex) {
|
||||
this.abc = abc;
|
||||
this.multinameIndex = multinameIndex;
|
||||
@@ -43,6 +58,10 @@ public abstract class MultinameUsage implements Usage {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets multiname index.
|
||||
* @return Multiname index
|
||||
*/
|
||||
public int getMultinameIndex() {
|
||||
return multinameIndex;
|
||||
}
|
||||
@@ -52,6 +71,11 @@ public abstract class MultinameUsage implements Usage {
|
||||
return abc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this multiname name is the same as other multiname name.
|
||||
* @param other Other multiname usage
|
||||
* @return True if names are the same
|
||||
*/
|
||||
protected boolean sameMultinameName(MultinameUsage other) {
|
||||
Multiname thisM = abc.constants.getMultiname(multinameIndex);
|
||||
Multiname otherM = other.abc.constants.getMultiname(other.multinameIndex);
|
||||
@@ -126,6 +150,11 @@ public abstract class MultinameUsage implements Usage {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this multiname collides with other multiname.
|
||||
* @param other Other multiname usage
|
||||
* @return True if collides
|
||||
*/
|
||||
public abstract boolean collides(MultinameUsage other);
|
||||
|
||||
@Override
|
||||
|
||||
+10
@@ -26,8 +26,18 @@ import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
|
||||
*/
|
||||
public class SuperClassMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
|
||||
|
||||
/**
|
||||
* Class index
|
||||
*/
|
||||
private final int classIndex;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param classIndex Class index
|
||||
* @param scriptIndex Script index
|
||||
*/
|
||||
public SuperClassMultinameUsage(ABC abc, int multinameIndex, int classIndex, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.classIndex = classIndex;
|
||||
|
||||
+10
@@ -26,8 +26,18 @@ import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
|
||||
*/
|
||||
public class SuperInterfaceMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
|
||||
|
||||
/**
|
||||
* Class index
|
||||
*/
|
||||
private final int classIndex;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param classIndex Class index
|
||||
* @param scriptIndex Script index
|
||||
*/
|
||||
public SuperInterfaceMultinameUsage(ABC abc, int multinameIndex, int classIndex, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.classIndex = classIndex;
|
||||
|
||||
+58
@@ -29,24 +29,62 @@ import java.util.Objects;
|
||||
*/
|
||||
public abstract class TraitMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
|
||||
|
||||
/**
|
||||
* Trait index
|
||||
*/
|
||||
protected final int traitIndex;
|
||||
|
||||
/**
|
||||
* Traits type - class
|
||||
*/
|
||||
public static final int TRAITS_TYPE_CLASS = 1;
|
||||
|
||||
/**
|
||||
* Traits type - instance
|
||||
*/
|
||||
public static final int TRAITS_TYPE_INSTANCE = 2;
|
||||
|
||||
/**
|
||||
* Traits type - script
|
||||
*/
|
||||
public static final int TRAITS_TYPE_SCRIPT = 3;
|
||||
|
||||
/**
|
||||
* Traits type
|
||||
*/
|
||||
protected final int traitsType;
|
||||
|
||||
/**
|
||||
* Class index
|
||||
*/
|
||||
protected final int classIndex;
|
||||
|
||||
/**
|
||||
* Script index
|
||||
*/
|
||||
protected final int scriptIndex;
|
||||
|
||||
/**
|
||||
* Traits
|
||||
*/
|
||||
protected final Traits traits;
|
||||
|
||||
/**
|
||||
* Parent trait index
|
||||
*/
|
||||
protected final int parentTraitIndex;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param scriptIndex Script index
|
||||
* @param classIndex Class index
|
||||
* @param traitIndex Trait index
|
||||
* @param traitsType Traits type
|
||||
* @param traits Traits
|
||||
* @param parentTraitIndex Parent trait index
|
||||
*/
|
||||
public TraitMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.scriptIndex = scriptIndex;
|
||||
@@ -126,22 +164,42 @@ public abstract class TraitMultinameUsage extends MultinameUsage implements Insi
|
||||
return classIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets trait index.
|
||||
* @return Trait index
|
||||
*/
|
||||
public int getTraitIndex() {
|
||||
return traitIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets traits type.
|
||||
* @return Traits type
|
||||
*/
|
||||
public int getTraitsType() {
|
||||
return traitsType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class index.
|
||||
* @return Class index
|
||||
*/
|
||||
public int getScriptIndex() {
|
||||
return scriptIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets traits.
|
||||
* @return Traits
|
||||
*/
|
||||
public Traits getTraits() {
|
||||
return traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets parent trait index.
|
||||
* @return Parent trait index
|
||||
*/
|
||||
public int getParentTraitIndex() {
|
||||
return parentTraitIndex;
|
||||
}
|
||||
|
||||
+14
@@ -26,8 +26,18 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class TypeNameMultinameUsage extends MultinameUsage {
|
||||
|
||||
/**
|
||||
* Type name index
|
||||
*/
|
||||
protected int typename_index;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param abc ABC
|
||||
* @param multinameIndex Multiname index
|
||||
* @param typename_index Type name index
|
||||
* @param scriptIndex Script index
|
||||
*/
|
||||
public TypeNameMultinameUsage(ABC abc, int multinameIndex, int typename_index, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.typename_index = typename_index;
|
||||
@@ -71,6 +81,10 @@ public class TypeNameMultinameUsage extends MultinameUsage {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type name index.
|
||||
* @return Type name index
|
||||
*/
|
||||
public int getTypenameIndex() {
|
||||
return typename_index;
|
||||
}
|
||||
|
||||
+13
@@ -23,6 +23,19 @@ package com.jpexs.decompiler.flash.action.deobfuscation;
|
||||
*/
|
||||
public class BrokenScriptDetector {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BrokenScriptDetector() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the code is broken.
|
||||
*
|
||||
* @param code Code
|
||||
* @return True if the code is broken
|
||||
*/
|
||||
public boolean codeIsBroken(String code) {
|
||||
return code.contains("\u00A7\u00A7");
|
||||
}
|
||||
|
||||
+74
@@ -23,54 +23,128 @@ package com.jpexs.decompiler.flash.action.parser.pcode;
|
||||
*/
|
||||
public class ASMParsedSymbol {
|
||||
|
||||
/**
|
||||
* Position
|
||||
*/
|
||||
public int pos;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
public int type;
|
||||
|
||||
/**
|
||||
* Value
|
||||
*/
|
||||
public Object value;
|
||||
|
||||
/**
|
||||
* Type: String
|
||||
*/
|
||||
public static final int TYPE_STRING = 1;
|
||||
|
||||
/**
|
||||
* Type: Block end
|
||||
*/
|
||||
public static final int TYPE_BLOCK_END = 2;
|
||||
|
||||
/**
|
||||
* Type: Instruction name
|
||||
*/
|
||||
public static final int TYPE_INSTRUCTION_NAME = 3;
|
||||
|
||||
/**
|
||||
* Type: Integer
|
||||
*/
|
||||
public static final int TYPE_INTEGER = 4;
|
||||
|
||||
/**
|
||||
* Type: Float
|
||||
*/
|
||||
public static final int TYPE_FLOAT = 5;
|
||||
|
||||
/**
|
||||
* Type: Boolean
|
||||
*/
|
||||
public static final int TYPE_BOOLEAN = 11;
|
||||
|
||||
/**
|
||||
* Type: Identifier
|
||||
*/
|
||||
public static final int TYPE_IDENTIFIER = 6;
|
||||
|
||||
/**
|
||||
* Type: End of file
|
||||
*/
|
||||
public static final int TYPE_EOF = 7;
|
||||
|
||||
/**
|
||||
* Type: Label
|
||||
*/
|
||||
public static final int TYPE_LABEL = 8;
|
||||
|
||||
/**
|
||||
* Type: Comment
|
||||
*/
|
||||
public static final int TYPE_COMMENT = 9;
|
||||
|
||||
/**
|
||||
* Type: Block start
|
||||
*/
|
||||
public static final int TYPE_BLOCK_START = 10;
|
||||
|
||||
/**
|
||||
* Type: Register
|
||||
*/
|
||||
public static final int TYPE_REGISTER = 12;
|
||||
|
||||
/**
|
||||
* Type: Constant
|
||||
*/
|
||||
public static final int TYPE_CONSTANT = 13;
|
||||
|
||||
/**
|
||||
* Type: Null
|
||||
*/
|
||||
public static final int TYPE_NULL = 14;
|
||||
|
||||
/**
|
||||
* Type: Undefined
|
||||
*/
|
||||
public static final int TYPE_UNDEFINED = 15;
|
||||
|
||||
/**
|
||||
* Type: End of line
|
||||
*/
|
||||
public static final int TYPE_EOL = 16;
|
||||
|
||||
/***
|
||||
* Type: Constant literal
|
||||
*/
|
||||
public static final int TYPE_CONSTANT_LITERAL = 17;
|
||||
|
||||
/***
|
||||
* Type: Comma
|
||||
*/
|
||||
public static final int TYPE_COMMA = 18;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param pos Position
|
||||
* @param type Type
|
||||
* @param value Value
|
||||
*/
|
||||
public ASMParsedSymbol(int pos, int type, Object value) {
|
||||
this.pos = pos;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param pos Position
|
||||
* @param type Type
|
||||
*/
|
||||
public ASMParsedSymbol(int pos, int type) {
|
||||
this.pos = pos;
|
||||
this.type = type;
|
||||
|
||||
@@ -146,6 +146,12 @@ public class ASMParser {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ASMParser.class.getName());
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ASMParser() {
|
||||
}
|
||||
|
||||
private static Action parseAction(String instructionName, FlasmLexer lexer, List<String> constantPool, int version, String charset) throws IOException, ActionParseException {
|
||||
Action a = null;
|
||||
if (instructionName.compareToIgnoreCase("GetURL") == 0) {
|
||||
@@ -398,6 +404,20 @@ public class ASMParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses ActionScript 1-2.
|
||||
* @param ignoreNops Ignore NOPs
|
||||
* @param labels Labels
|
||||
* @param lineMap Line map
|
||||
* @param address Address
|
||||
* @param lexer Lexer
|
||||
* @param constantPool Constant pool
|
||||
* @param version Version
|
||||
* @param charset Charset
|
||||
* @return Action list
|
||||
* @throws IOException On I/O error
|
||||
* @throws ActionParseException On parse error
|
||||
*/
|
||||
public static ActionList parse(boolean ignoreNops, List<Label> labels, Map<Action, Integer> lineMap, long address, FlasmLexer lexer, List<String> constantPool, int version, String charset) throws IOException, ActionParseException {
|
||||
ActionList list = new ActionList(charset);
|
||||
Stack<GraphSourceItemContainer> containers = new Stack<>();
|
||||
@@ -467,6 +487,18 @@ public class ASMParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses ActionScript 1-2.
|
||||
* @param address Address
|
||||
* @param ignoreNops Ignore NOPs
|
||||
* @param source Source
|
||||
* @param version Version
|
||||
* @param throwOnError Throw on error
|
||||
* @param charset Charset
|
||||
* @return Action list
|
||||
* @throws IOException On I/O error
|
||||
* @throws ActionParseException On parse error
|
||||
*/
|
||||
public static ActionList parse(long address, boolean ignoreNops, String source, int version, boolean throwOnError, String charset) throws IOException, ActionParseException {
|
||||
FlasmLexer lexer = new FlasmLexer(new StringReader(source));
|
||||
List<Action> list = parseAllActions(lexer, version, charset);
|
||||
|
||||
@@ -50,18 +50,35 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class Amf3InputStream extends InputStream {
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
public static final Logger LOGGER = Logger.getLogger(Amf3InputStream.class.getName());
|
||||
private final MemoryInputStream is;
|
||||
/**
|
||||
* Dump info
|
||||
*/
|
||||
public DumpInfo dumpInfo;
|
||||
private static final String NO_REFERENCE_BIT_TEXT = "not reference";
|
||||
private static final String OBJECT_INDEX_TEXT = "object index";
|
||||
private static final String STRING_INDEX_TEXT = "string index";
|
||||
private static final String TRAIT_INDEX_TEXT = "trait index";
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param is Input stream
|
||||
*/
|
||||
public Amf3InputStream(MemoryInputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
/**
|
||||
* New dump level.
|
||||
* @param name Name
|
||||
* @param type Type
|
||||
* @return Dump info
|
||||
*/
|
||||
public DumpInfo newDumpLevel(String name, String type) {
|
||||
if (dumpInfo != null) {
|
||||
long startByte = is.getPos();
|
||||
@@ -74,10 +91,17 @@ public class Amf3InputStream extends InputStream {
|
||||
return dumpInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends dump level
|
||||
*/
|
||||
public void endDumpLevel() {
|
||||
endDumpLevel(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends dump level
|
||||
* @param value Value
|
||||
*/
|
||||
public void endDumpLevel(Object value) {
|
||||
if (dumpInfo != null) {
|
||||
dumpInfo.lengthBytes = is.getPos() - dumpInfo.startByte;
|
||||
@@ -86,6 +110,10 @@ public class Amf3InputStream extends InputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends dump level until
|
||||
* @param di Dump info
|
||||
*/
|
||||
public void endDumpLevelUntil(DumpInfo di) {
|
||||
if (di != null) {
|
||||
while (dumpInfo != null && dumpInfo != di) {
|
||||
@@ -94,6 +122,12 @@ public class Amf3InputStream extends InputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads U8 (unsigned 8-bit integer) value.
|
||||
* @param name Name
|
||||
* @return U8 value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public int readU8(String name) throws IOException {
|
||||
newDumpLevel(name, "U8");
|
||||
int ret = readInternal();
|
||||
@@ -101,6 +135,12 @@ public class Amf3InputStream extends InputStream {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads U16 (unsigned 16-bit integer) value.
|
||||
* @param name Name
|
||||
* @return U16 value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public int readU16(String name) throws IOException {
|
||||
newDumpLevel(name, "U16");
|
||||
int b1 = readInternal();
|
||||
@@ -110,6 +150,12 @@ public class Amf3InputStream extends InputStream {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads U32 (unsigned 32-bit integer) value.
|
||||
* @param name Name
|
||||
* @return U32 value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public long readU32(String name) throws IOException {
|
||||
newDumpLevel(name, "U32");
|
||||
long ret = readU32Internal();
|
||||
@@ -117,6 +163,11 @@ public class Amf3InputStream extends InputStream {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads U32 (unsigned 32-bit integer) value.
|
||||
* @return U32 value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
private long readU32Internal() throws IOException {
|
||||
int b1 = readInternal();
|
||||
int b2 = readInternal();
|
||||
@@ -126,6 +177,12 @@ public class Amf3InputStream extends InputStream {
|
||||
return ((b1 << 24) + (b2 << 16) + (b3 << 8) + b4) & 0xffffffff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads S32 (signed 32-bit integer) value.
|
||||
* @param name Name
|
||||
* @return S32 value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public long readS32(String name) throws IOException {
|
||||
newDumpLevel(name, "S32");
|
||||
long ret = signExtend(readU32Internal(), 32);
|
||||
@@ -133,6 +190,11 @@ public class Amf3InputStream extends InputStream {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads long value.
|
||||
* @return Long value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
private long readLong() throws IOException {
|
||||
byte[] readBuffer = new byte[8];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
@@ -148,6 +210,12 @@ public class Amf3InputStream extends InputStream {
|
||||
+ ((readBuffer[7] & 0xff)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads double value.
|
||||
* @param name Name
|
||||
* @return Double value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public double readDouble(String name) throws IOException {
|
||||
newDumpLevel(name, "DOUBLE");
|
||||
long lval = readLong();
|
||||
@@ -156,6 +224,13 @@ public class Amf3InputStream extends InputStream {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads U29 (Unsigned 29-bit integer) value.
|
||||
* @param name Name
|
||||
* @return U29 value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
|
||||
public long readU29(String name) throws IOException {
|
||||
newDumpLevel(name, "U29");
|
||||
long val = readU29Internal();
|
||||
@@ -225,6 +300,12 @@ public class Amf3InputStream extends InputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads S29 (Signed 29-bit integer) value.
|
||||
* @param name Name
|
||||
* @return S29 value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public long readS29(String name) throws IOException {
|
||||
newDumpLevel(name, "S29");
|
||||
long val = signExtend(readU29Internal(), 29);
|
||||
@@ -232,7 +313,7 @@ public class Amf3InputStream extends InputStream {
|
||||
return val;
|
||||
}
|
||||
|
||||
public long readU29Internal() throws IOException {
|
||||
private long readU29Internal() throws IOException {
|
||||
long val = 0;
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
int b = readInternal();
|
||||
@@ -274,6 +355,13 @@ public class Amf3InputStream extends InputStream {
|
||||
return retString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads UTF-8 Vr value.
|
||||
* @param name Name
|
||||
* @param stringTable String table
|
||||
* @return UTF-8 Vr value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public String readUtf8Vr(String name, List<String> stringTable) throws IOException {
|
||||
newDumpLevel(name, "UTF-8-vr");
|
||||
long u = readU29("U29S");
|
||||
@@ -313,10 +401,25 @@ public class Amf3InputStream extends InputStream {
|
||||
return is.read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads value.
|
||||
* @param name Name
|
||||
* @return Value
|
||||
* @throws IOException On I/O error
|
||||
* @throws NoSerializerExistsException If no serializer exists
|
||||
*/
|
||||
public Object readValue(String name) throws IOException, NoSerializerExistsException {
|
||||
return readValue(name, new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads value.
|
||||
* @param name Name
|
||||
* @param serializers Serializers
|
||||
* @return Value
|
||||
* @throws IOException On I/O error
|
||||
* @throws NoSerializerExistsException If no serializer exists
|
||||
*/
|
||||
public Object readValue(String name, Map<String, ObjectTypeSerializeHandler> serializers) throws IOException, NoSerializerExistsException {
|
||||
return readValue(name, serializers, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class Amf3OutputStream extends OutputStream {
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
public static final Logger LOGGER = Logger.getLogger(Amf3OutputStream.class.getName());
|
||||
|
||||
private final OutputStream os;
|
||||
@@ -50,14 +53,29 @@ public class Amf3OutputStream extends OutputStream {
|
||||
private static final int TRAIT_EXT_FLAG = 4;
|
||||
private static final int DYNAMIC_FLAG = 8;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param os Output stream
|
||||
*/
|
||||
public Amf3OutputStream(OutputStream os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes U8 (unsigned 8-bit integer).
|
||||
* @param v Value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public void writeU8(int v) throws IOException {
|
||||
write(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes U16 (unsigned 16-bit integer).
|
||||
* @param v Value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public void writeU16(int v) throws IOException {
|
||||
int b1 = (v >> 8) & 0xff;
|
||||
int b2 = v & 0xff;
|
||||
@@ -65,6 +83,11 @@ public class Amf3OutputStream extends OutputStream {
|
||||
write(b2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes long.
|
||||
* @param value Value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
private void writeLong(long value) throws IOException {
|
||||
byte[] writeBuffer = new byte[8];
|
||||
writeBuffer[0] = (byte) (value >>> 56);
|
||||
@@ -78,6 +101,11 @@ public class Amf3OutputStream extends OutputStream {
|
||||
write(writeBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes U32 (unsigned 32-bit integer).
|
||||
* @param v Value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public void writeU32(long v) throws IOException {
|
||||
int b1 = (int) ((v >> 24) & 0xff);
|
||||
int b2 = (int) ((v >> 16) & 0xff);
|
||||
@@ -90,14 +118,29 @@ public class Amf3OutputStream extends OutputStream {
|
||||
write(b4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes double.
|
||||
* @param v Value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public void writeDouble(double v) throws IOException {
|
||||
writeLong(Double.doubleToLongBits(v));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes bytes.
|
||||
* @param data Data
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public void writeBytes(byte[] data) throws IOException {
|
||||
os.write(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes U29 (unsigned 29-bit integer).
|
||||
* @param v Value
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
public void writeU29(long v) throws IOException {
|
||||
v = v & 0x3FFFFFFF; //make unsigned
|
||||
|
||||
@@ -133,6 +176,12 @@ public class Amf3OutputStream extends OutputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes UTF-8 Vr.
|
||||
* @param val Value
|
||||
* @param stringTable String table
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
private void writeUtf8Vr(String val, List<String> stringTable) throws IOException {
|
||||
int stringIndex = stringTable.indexOf(val);
|
||||
if (stringIndex == -1) {
|
||||
@@ -147,6 +196,12 @@ public class Amf3OutputStream extends OutputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes byte array.
|
||||
* @param val Value
|
||||
* @param objectTable Object table
|
||||
* @throws IOException On I/O error
|
||||
*/
|
||||
private void writeByteArray(ByteArrayType val, List<Object> objectTable) throws IOException {
|
||||
int objectIndex = objectTable.indexOf(val);
|
||||
if (objectIndex == -1) {
|
||||
@@ -260,10 +315,23 @@ public class Amf3OutputStream extends OutputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes value.
|
||||
* @param object Object
|
||||
* @throws IOException On I/O error
|
||||
* @throws NoSerializerExistsException If no serializer exists
|
||||
*/
|
||||
public void writeValue(Object object) throws IOException, NoSerializerExistsException {
|
||||
writeValue(object, new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes value.
|
||||
* @param object Object
|
||||
* @param serializers Serializers
|
||||
* @throws IOException On I/O error
|
||||
* @throws NoSerializerExistsException If no serializer exists
|
||||
*/
|
||||
public void writeValue(Object object, Map<String, ObjectTypeSerializeHandler> serializers) throws IOException, NoSerializerExistsException {
|
||||
writeValue(object, serializers, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
|
||||
@@ -34,14 +34,27 @@ public class Amf3Value {
|
||||
@Multiline
|
||||
private String data = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Amf3Value() {
|
||||
setValue(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param value Value
|
||||
*/
|
||||
public Amf3Value(Object value) {
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value.
|
||||
*
|
||||
* @param value Value
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
if (!isValueValid(value)) {
|
||||
throw new IllegalArgumentException("Invalid Amf value: " + value.getClass().getSimpleName());
|
||||
@@ -49,6 +62,11 @@ public class Amf3Value {
|
||||
this.data = value == null ? "" : Amf3Exporter.amfToString(value, " ", "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if value is valid.
|
||||
* @param value Value
|
||||
* @return True if value is valid
|
||||
*/
|
||||
public static boolean isValueValid(Object value) {
|
||||
if (value == null) {
|
||||
return true;
|
||||
@@ -71,6 +89,10 @@ public class Amf3Value {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets value.
|
||||
* @return Value
|
||||
*/
|
||||
public Object getValue() {
|
||||
Amf3Importer imp = new Amf3Importer();
|
||||
try {
|
||||
|
||||
@@ -151,6 +151,11 @@ public class ListMap<K, V> implements Map<K, V> {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry implementation
|
||||
* @param <K> Key type
|
||||
* @param <V> Value type
|
||||
*/
|
||||
public static class MyEntry<K, V> implements Entry<K, V> {
|
||||
|
||||
private K key;
|
||||
|
||||
@@ -31,10 +31,18 @@ public class ListSet<E> implements Set<E> {
|
||||
|
||||
private final List<E> list = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ListSet() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param c Collection
|
||||
*/
|
||||
public ListSet(Collection<? extends E> c) {
|
||||
addAll(c);
|
||||
}
|
||||
|
||||
@@ -21,22 +21,76 @@ package com.jpexs.decompiler.flash.amf.amf3;
|
||||
*/
|
||||
public class Marker {
|
||||
|
||||
/**
|
||||
* Undefined
|
||||
*/
|
||||
public static final int UNDEFINED = 0x00;
|
||||
/**
|
||||
* Null
|
||||
*/
|
||||
public static final int NULL = 0x01;
|
||||
/**
|
||||
* False
|
||||
*/
|
||||
public static final int FALSE = 0x02;
|
||||
/**
|
||||
* True
|
||||
*/
|
||||
public static final int TRUE = 0x03;
|
||||
/**
|
||||
* Integer
|
||||
*/
|
||||
public static final int INTEGER = 0x04;
|
||||
/**
|
||||
* Double
|
||||
*/
|
||||
public static final int DOUBLE = 0x05;
|
||||
/**
|
||||
* String
|
||||
*/
|
||||
public static final int STRING = 0x06;
|
||||
/**
|
||||
* XML document
|
||||
*/
|
||||
public static final int XML_DOC = 0x07;
|
||||
/**
|
||||
* Date
|
||||
*/
|
||||
public static final int DATE = 0x08;
|
||||
/**
|
||||
* Array
|
||||
*/
|
||||
public static final int ARRAY = 0x09;
|
||||
/**
|
||||
* Object
|
||||
*/
|
||||
public static final int OBJECT = 0x0A;
|
||||
/**
|
||||
* XML
|
||||
*/
|
||||
public static final int XML = 0x0B;
|
||||
/**
|
||||
* Byte array
|
||||
*/
|
||||
public static final int BYTE_ARRAY = 0x0C;
|
||||
/**
|
||||
* Vector of integers
|
||||
*/
|
||||
public static final int VECTOR_INT = 0x0D;
|
||||
/**
|
||||
* Vector of unsigned integers
|
||||
*/
|
||||
public static final int VECTOR_UINT = 0x0E;
|
||||
/**
|
||||
* Vector of doubles
|
||||
*/
|
||||
public static final int VECTOR_DOUBLE = 0x0F;
|
||||
/**
|
||||
* Vector of objects
|
||||
*/
|
||||
public static final int VECTOR_OBJECT = 0x10;
|
||||
/**
|
||||
* Dictionary
|
||||
*/
|
||||
public static final int DICTIONARY = 0x11;
|
||||
}
|
||||
|
||||
+14
-3
@@ -24,19 +24,30 @@ public class NoSerializerExistsException extends Exception {
|
||||
private final String className;
|
||||
private final Object incompleteData;
|
||||
|
||||
/*public NoSerializerExistsException(String className, Object incompleteData) {
|
||||
this(className, incompleteData, null);
|
||||
}*/
|
||||
/**
|
||||
* Constructor.
|
||||
* @param className Class name
|
||||
* @param incompleteData Incomplete data
|
||||
* @param cause Cause
|
||||
*/
|
||||
public NoSerializerExistsException(String className, Object incompleteData, Throwable cause) {
|
||||
super("Cannot read AMF - no deserializer defined for class \"" + className + "\".", cause);
|
||||
this.className = className;
|
||||
this.incompleteData = incompleteData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the class name.
|
||||
* @return Class name
|
||||
*/
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the incomplete data.
|
||||
* @return Incomplete data
|
||||
*/
|
||||
public Object getIncompleteData() {
|
||||
return incompleteData;
|
||||
}
|
||||
|
||||
@@ -28,32 +28,62 @@ public class Traits {
|
||||
private boolean dynamic;
|
||||
private Set<String> sealedMemberNames;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param className Class name
|
||||
* @param dynamic Dynamic
|
||||
* @param sealedMemberNames
|
||||
*/
|
||||
public Traits(String className, boolean dynamic, Collection<? extends String> sealedMemberNames) {
|
||||
this.className = className;
|
||||
this.dynamic = dynamic;
|
||||
this.sealedMemberNames = new ListSet<>(sealedMemberNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class name.
|
||||
* @return Class name
|
||||
*/
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if dynamic.
|
||||
* @return True if dynamic
|
||||
*/
|
||||
public boolean isDynamic() {
|
||||
return dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sealed member names.
|
||||
* @return Sealed member names
|
||||
*/
|
||||
public Set<String> getSealedMemberNames() {
|
||||
return new ListSet<>(sealedMemberNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets class name.
|
||||
* @param className Class name
|
||||
*/
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dynamic.
|
||||
* @param dynamic Dynamic
|
||||
*/
|
||||
public void setDynamic(boolean dynamic) {
|
||||
this.dynamic = dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets sealed member names.
|
||||
* @param sealedMemberNames Sealed member names
|
||||
*/
|
||||
public void setSealedMemberNames(Collection<? extends String> sealedMemberNames) {
|
||||
this.sealedMemberNames = new ListSet<>(sealedMemberNames);
|
||||
}
|
||||
|
||||
+16
@@ -24,20 +24,36 @@ public class UnsupportedValueTypeException extends RuntimeException {
|
||||
private Integer marker = null;
|
||||
private Class cls = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param cls Unsupported class.
|
||||
*/
|
||||
public UnsupportedValueTypeException(Class cls) {
|
||||
super("Unsupported type of value - class: " + cls.getSimpleName());
|
||||
this.cls = cls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param marker Unsupported marker.
|
||||
*/
|
||||
public UnsupportedValueTypeException(int marker) {
|
||||
super("Unsupported type of value - marker: 0x" + Integer.toHexString(marker));
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets marker.
|
||||
* @return Marker.
|
||||
*/
|
||||
public Integer getMarker() {
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets unsupported class.
|
||||
* @return Unsupported class.
|
||||
*/
|
||||
public Class getUnsupportedClass() {
|
||||
return this.cls;
|
||||
}
|
||||
|
||||
@@ -33,47 +33,97 @@ public class ArrayType implements WithSubValues, Amf3ValueType {
|
||||
private List<Object> denseValues;
|
||||
private Map<String, Object> associativeValues;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param associativeValues Associative values
|
||||
*/
|
||||
public ArrayType(Map<? extends String, ? extends Object> associativeValues) {
|
||||
this(new ArrayList<>(), associativeValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param denseValues Dense values
|
||||
*/
|
||||
public ArrayType(List<Object> denseValues) {
|
||||
this(denseValues, new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ArrayType() {
|
||||
this(new ArrayList<>(), new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param denseValues Dense values
|
||||
* @param associativeValues Associative values
|
||||
*/
|
||||
public ArrayType(List<Object> denseValues, Map<? extends String, ? extends Object> associativeValues) {
|
||||
this.denseValues = new ArrayList<>(denseValues);
|
||||
this.associativeValues = new ListMap<>(associativeValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dense values.
|
||||
* @return Dense values
|
||||
*/
|
||||
public List<Object> getDenseValues() {
|
||||
return new ArrayList<>(denseValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dense values.
|
||||
* @param denseValues Dense values
|
||||
*/
|
||||
public void setDenseValues(List<Object> denseValues) {
|
||||
this.denseValues = new ArrayList<>(denseValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dense value.
|
||||
* @param key Key
|
||||
* @param value Value
|
||||
* @return Previous value
|
||||
*/
|
||||
public Object setDense(int key, Object value) {
|
||||
return denseValues.set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts associative value.
|
||||
* @param key Key
|
||||
* @param value Value
|
||||
* @return Previous value
|
||||
*/
|
||||
public Object putAssociative(String key, Object value) {
|
||||
return associativeValues.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets associative values.
|
||||
* @return Associative values
|
||||
*/
|
||||
public Map<String, Object> getAssociativeValues() {
|
||||
return new ListMap<>(associativeValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets associative value.
|
||||
* @param key Key
|
||||
* @return Value
|
||||
*/
|
||||
public Object getAssociative(String key) {
|
||||
return associativeValues.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dense value.
|
||||
* @param index Index
|
||||
* @return Value
|
||||
*/
|
||||
public Object getDense(int index) {
|
||||
if (index >= 0 && index < denseValues.size()) {
|
||||
return denseValues.get(index);
|
||||
@@ -81,6 +131,10 @@ public class ArrayType implements WithSubValues, Amf3ValueType {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets associative key set.
|
||||
* @return Associative key set
|
||||
*/
|
||||
public Set<String> associativeKeySet() {
|
||||
return associativeValues.keySet();
|
||||
}
|
||||
@@ -99,6 +153,10 @@ public class ArrayType implements WithSubValues, Amf3ValueType {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets associative values.
|
||||
* @param associativeValues Associative values
|
||||
*/
|
||||
public void setAssociativeValues(Map<String, Object> associativeValues) {
|
||||
this.associativeValues = new ListMap<>(associativeValues);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ package com.jpexs.decompiler.flash.amf.amf3.types;
|
||||
* Basic AMF3 types.
|
||||
*/
|
||||
public enum BasicType implements Amf3ValueType {
|
||||
/**
|
||||
* Null
|
||||
*/
|
||||
NULL {
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -27,6 +30,9 @@ public enum BasicType implements Amf3ValueType {
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* Undefined
|
||||
*/
|
||||
UNDEFINED {
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -34,7 +40,9 @@ public enum BasicType implements Amf3ValueType {
|
||||
}
|
||||
|
||||
},
|
||||
//Special types for errors while reading
|
||||
/**
|
||||
* Unknown - Special type for errors while reading
|
||||
*/
|
||||
UNKNOWN {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -25,10 +25,18 @@ public class ByteArrayType {
|
||||
|
||||
private byte[] data;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param data Byte array data
|
||||
*/
|
||||
public ByteArrayType(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets byte array data.
|
||||
* @return Byte array data
|
||||
*/
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -26,14 +26,26 @@ public class DateType implements Amf3ValueType {
|
||||
|
||||
private double val;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param val Date value
|
||||
*/
|
||||
public DateType(double val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets date value.
|
||||
* @return Date value
|
||||
*/
|
||||
public double getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets date value.
|
||||
* @param val Date value
|
||||
*/
|
||||
public void setVal(double val) {
|
||||
this.val = val;
|
||||
}
|
||||
@@ -43,6 +55,10 @@ public class DateType implements Amf3ValueType {
|
||||
return Amf3Exporter.amfToString(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this to date.
|
||||
* @return Date
|
||||
*/
|
||||
public Date toDate() {
|
||||
return new Date((long) val);
|
||||
}
|
||||
|
||||
@@ -29,12 +29,24 @@ import java.util.Map;
|
||||
*/
|
||||
public class DictionaryType extends ListMap<Object, Object> implements WithSubValues, Amf3ValueType {
|
||||
|
||||
/**
|
||||
* True if keys are weak
|
||||
*/
|
||||
private final boolean weakKeys;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param weakKeys True if keys are weak
|
||||
*/
|
||||
public DictionaryType(boolean weakKeys) {
|
||||
this(weakKeys, new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param weakKeys True if keys are weak
|
||||
* @param entries Entries
|
||||
*/
|
||||
public DictionaryType(boolean weakKeys, Map<Object, Object> entries) {
|
||||
super(true /*IdentityMap*/, entries);
|
||||
this.weakKeys = weakKeys; //TODO? Really make the Map weak - something like WeakIdentityMap - but is it neccessary for serialization?
|
||||
@@ -53,6 +65,10 @@ public class DictionaryType extends ListMap<Object, Object> implements WithSubVa
|
||||
return Amf3Exporter.amfToString(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if keys are weak.
|
||||
* @return True if keys are weak
|
||||
*/
|
||||
public boolean hasWeakKeys() {
|
||||
return weakKeys;
|
||||
}
|
||||
|
||||
@@ -41,14 +41,28 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
private boolean serialized;
|
||||
private Traits traits;
|
||||
|
||||
/**
|
||||
* Checks if the object is serialized.
|
||||
* @return True if the object is serialized.
|
||||
*/
|
||||
public boolean isSerialized() {
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the traits of the object.
|
||||
* @return The traits of the object.
|
||||
*/
|
||||
public Traits getTraits() {
|
||||
return traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param traits The traits of the object.
|
||||
* @param serializedData The serialized data.
|
||||
* @param serializedMembers The serialized members.
|
||||
*/
|
||||
public ObjectType(Traits traits, byte[] serializedData, Map<String, Object> serializedMembers) {
|
||||
this.traits = traits;
|
||||
this.serializedData = serializedData;
|
||||
@@ -58,10 +72,20 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
this.serialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param traits The traits of the object.
|
||||
*/
|
||||
public ObjectType(Traits traits) {
|
||||
this(traits, new HashMap<>(), new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param traits The traits of the object.
|
||||
* @param sealedMembers The sealed members.
|
||||
* @param dynamicMembers The dynamic members.
|
||||
*/
|
||||
public ObjectType(Traits traits, Map<String, Object> sealedMembers, Map<String, Object> dynamicMembers) {
|
||||
this.sealedMembers = new ListMap<>(sealedMembers);
|
||||
this.dynamicMembers = new ListMap<>(dynamicMembers);
|
||||
@@ -70,10 +94,18 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
this.traits = traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the object is dynamic.
|
||||
* @return True if the object is dynamic.
|
||||
*/
|
||||
public boolean isDynamic() {
|
||||
return traits.isDynamic();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the class name of the object.
|
||||
* @return The class name of the object.
|
||||
*/
|
||||
public String getClassName() {
|
||||
return traits.getClassName();
|
||||
}
|
||||
@@ -97,28 +129,52 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return Amf3Exporter.amfToString(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the serialized data.
|
||||
* @param serializedData The serialized data.
|
||||
*/
|
||||
public void setSerializedData(byte[] serializedData) {
|
||||
this.serializedData = serializedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the serialized data.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public byte[] getSerializedData() {
|
||||
return serializedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the serialized members.
|
||||
* @param serializedMembers The serialized members.
|
||||
*/
|
||||
public void setSerializedMembers(Map<String, Object> serializedMembers) {
|
||||
this.serializedMembers = new ListMap<>(serializedMembers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the serialized members.
|
||||
* @return The serialized members.
|
||||
*/
|
||||
public Map<String, Object> getSerializedMembers() {
|
||||
return new ListMap<>(serializedMembers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sealed members.
|
||||
* @param sealedMembers The sealed members.
|
||||
*/
|
||||
public void setSealedMembers(Map<String, Object> sealedMembers) {
|
||||
this.sealedMembers = new ListMap<>(sealedMembers);
|
||||
}
|
||||
|
||||
public void setDynamicMembers(Map<String, Object> sealedMembers) {
|
||||
this.dynamicMembers = new ListMap<>(sealedMembers);
|
||||
/**
|
||||
* Sets the dynamic members.
|
||||
* @param dynamicMembers The dynamic members.
|
||||
*/
|
||||
public void setDynamicMembers(Map<String, Object> dynamicMembers) {
|
||||
this.dynamicMembers = new ListMap<>(dynamicMembers);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,14 +182,26 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return keySet().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of the sealed members.
|
||||
* @return The size of the sealed members.
|
||||
*/
|
||||
public int sealedMembersSize() {
|
||||
return sealedMembers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of the dynamic members.
|
||||
* @return The size of the dynamic members.
|
||||
*/
|
||||
public int dynamicMembersSize() {
|
||||
return dynamicMembers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of the serialized members.
|
||||
* @return The size of the serialized members.
|
||||
*/
|
||||
public int serializedMembersSize() {
|
||||
return serializedMembers.size();
|
||||
}
|
||||
@@ -152,14 +220,29 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return containsDynamicMember(keyString) || containsSealedMember(keyString) || containsSerializedMember(keyString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the object contains a sealed member.
|
||||
* @param name The name of the member.
|
||||
* @return True if the object contains a sealed member.
|
||||
*/
|
||||
public boolean containsSealedMember(String name) {
|
||||
return sealedMembers.containsKey(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the object contains a dynamic member.
|
||||
* @param name The name of the member.
|
||||
* @return True if the object contains a dynamic member.
|
||||
*/
|
||||
public boolean containsDynamicMember(String name) {
|
||||
return dynamicMembers.containsKey(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the object contains a serialized member.
|
||||
* @param name The name of the member.
|
||||
* @return True if the object contains a serialized member.
|
||||
*/
|
||||
public boolean containsSerializedMember(String name) {
|
||||
return serializedMembers.containsKey(name);
|
||||
}
|
||||
@@ -188,6 +271,11 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sealed member.
|
||||
* @param key The key of the member.
|
||||
* @return The sealed member.
|
||||
*/
|
||||
public Object getSealedMember(Object key) {
|
||||
if (!(key instanceof String)) {
|
||||
return null;
|
||||
@@ -197,6 +285,11 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return sealedMembers.get(stringKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a dynamic member.
|
||||
* @param key The key of the member.
|
||||
* @return The dynamic member.
|
||||
*/
|
||||
public Object getDynamicMember(Object key) {
|
||||
if (!(key instanceof String)) {
|
||||
return null;
|
||||
@@ -206,6 +299,11 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return dynamicMembers.get(stringKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a serialized member.
|
||||
* @param key The key of the member.
|
||||
* @return The serialized member.
|
||||
*/
|
||||
public Object getSerializedMember(Object key) {
|
||||
if (!(key instanceof String)) {
|
||||
return null;
|
||||
@@ -220,16 +318,34 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return putDynamicMember(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a dynamic member.
|
||||
* @param key The key of the member.
|
||||
* @param value The value of the member.
|
||||
* @return The previous value of the member.
|
||||
*/
|
||||
public Object putDynamicMember(String key, Object value) {
|
||||
remove(key);
|
||||
return dynamicMembers.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a sealed member.
|
||||
* @param key The key of the member.
|
||||
* @param value The value of the member.
|
||||
* @return The previous value of the member.
|
||||
*/
|
||||
public Object putSealedMember(String key, Object value) {
|
||||
remove(key);
|
||||
return sealedMembers.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a serialized member.
|
||||
* @param key The key of the member.
|
||||
* @param value The value of the member.
|
||||
* @return The previous value of the member.
|
||||
*/
|
||||
public Object putSerializedMember(String key, Object value) {
|
||||
remove(key);
|
||||
return serializedMembers.put(key, value);
|
||||
@@ -260,18 +376,30 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all dynamic members.
|
||||
* @param m The map of dynamic members.
|
||||
*/
|
||||
public void putAllDynamicMember(Map<? extends String, ? extends Object> m) {
|
||||
for (Map.Entry<? extends String, ? extends Object> e : m.entrySet()) {
|
||||
putDynamicMember(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all sealed members.
|
||||
* @param m The map of sealed members.
|
||||
*/
|
||||
public void putAllSealedMember(Map<? extends String, ? extends Object> m) {
|
||||
for (Map.Entry<? extends String, ? extends Object> e : m.entrySet()) {
|
||||
putSealedMember(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all serialized members.
|
||||
* @param m The map of serialized members.
|
||||
*/
|
||||
public void putAllSerializedMember(Map<? extends String, ? extends Object> m) {
|
||||
for (Map.Entry<? extends String, ? extends Object> e : m.entrySet()) {
|
||||
putSerializedMember(e.getKey(), e.getValue());
|
||||
@@ -285,14 +413,23 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
clearSerializedMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all dynamic members.
|
||||
*/
|
||||
public void clearDynamicMembers() {
|
||||
dynamicMembers.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all sealed members.
|
||||
*/
|
||||
public void clearSealedMembers() {
|
||||
sealedMembers.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all serialized members.
|
||||
*/
|
||||
public void clearSerializedMembers() {
|
||||
serializedMembers.clear();
|
||||
}
|
||||
@@ -306,14 +443,26 @@ public class ObjectType implements WithSubValues, Amf3ValueType, Map<String, Obj
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key set of the sealed members.
|
||||
* @return The key set of the sealed members.
|
||||
*/
|
||||
public Set<String> sealedMembersKeySet() {
|
||||
return new ListSet<>(sealedMembers.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key set of the dynamic members.
|
||||
* @return The key set of the dynamic members.
|
||||
*/
|
||||
public Set<String> dynamicMembersKeySet() {
|
||||
return new ListSet<>(dynamicMembers.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key set of the serialized members.
|
||||
* @return The key set of the serialized members.
|
||||
*/
|
||||
public Set<String> serializedMembersKeySet() {
|
||||
return new ListSet<>(serializedMembers.keySet());
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ import java.util.List;
|
||||
*/
|
||||
public class VectorDoubleType extends AbstractVectorType<Double> {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param fixed Fixed size
|
||||
* @param values Values
|
||||
*/
|
||||
public VectorDoubleType(boolean fixed, List<Double> values) {
|
||||
super(fixed, values);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ import java.util.List;
|
||||
*/
|
||||
public class VectorIntType extends AbstractVectorType<Long> {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param fixed Fixed size
|
||||
* @param values Values
|
||||
*/
|
||||
public VectorIntType(boolean fixed, List<Long> values) {
|
||||
super(fixed, values);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,17 @@ import java.util.List;
|
||||
*/
|
||||
public class VectorObjectType extends AbstractVectorType<Object> {
|
||||
|
||||
/**
|
||||
* Type name
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param fixed Fixed size
|
||||
* @param typeName Type name
|
||||
* @param values Values
|
||||
*/
|
||||
public VectorObjectType(boolean fixed, String typeName, List<Object> values) {
|
||||
super(fixed, values);
|
||||
this.typeName = typeName;
|
||||
|
||||
@@ -23,6 +23,11 @@ import java.util.List;
|
||||
*/
|
||||
public class VectorUIntType extends AbstractVectorType<Long> {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param fixed Fixed size
|
||||
* @param values Values
|
||||
*/
|
||||
public VectorUIntType(boolean fixed, List<Long> values) {
|
||||
super(fixed, values);
|
||||
}
|
||||
|
||||
@@ -23,14 +23,26 @@ public class XmlDocType implements Amf3ValueType {
|
||||
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param data Data
|
||||
*/
|
||||
public XmlDocType(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets data.
|
||||
* @return Data
|
||||
*/
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets data.
|
||||
* @param data Data
|
||||
*/
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user