mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 15:30:45 +00:00
Separated FFDec core library and the rest (GUI).
FFDec Library is now LGPLv3, others stay GPLv3. Version changed to 3.0.0 for FFDec, 1.0.0 for FFDec Library.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,482 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.Decimal;
|
||||
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.ValueKind;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
|
||||
import com.jpexs.helpers.MemoryInputStream;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ABCInputStream implements AutoCloseable {
|
||||
|
||||
private static final int CLASS_PROTECTED_NS = 8;
|
||||
private static final int ATTR_METADATA = 4;
|
||||
private final MemoryInputStream is;
|
||||
private long bytesRead = 0;
|
||||
private ByteArrayOutputStream bufferOs = null;
|
||||
public static final boolean DEBUG_READ = false;
|
||||
public DumpInfo dumpInfo;
|
||||
|
||||
public void startBuffer() {
|
||||
if (bufferOs == null) {
|
||||
bufferOs = new ByteArrayOutputStream();
|
||||
} else {
|
||||
bufferOs.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] stopBuffer() {
|
||||
if (bufferOs == null) {
|
||||
return new byte[0];
|
||||
}
|
||||
byte[] ret = bufferOs.toByteArray();
|
||||
bufferOs.reset();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ABCInputStream(MemoryInputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets position in bytes in the stream
|
||||
*
|
||||
* @param pos Number of bytes
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void seek(long pos) throws IOException {
|
||||
is.seek(pos);
|
||||
}
|
||||
|
||||
public DumpInfo newDumpLevel(String name, String type) {
|
||||
if (dumpInfo != null) {
|
||||
long startByte = is.getPos();
|
||||
DumpInfo di = new DumpInfo(name, type, null, startByte, 0, 0, 0);
|
||||
di.parent = dumpInfo;
|
||||
dumpInfo.getChildInfos().add(di);
|
||||
dumpInfo = di;
|
||||
}
|
||||
|
||||
return dumpInfo;
|
||||
}
|
||||
|
||||
public void endDumpLevel() {
|
||||
endDumpLevel(null);
|
||||
}
|
||||
|
||||
public void endDumpLevel(Object value) {
|
||||
if (dumpInfo != null) {
|
||||
dumpInfo.lengthBytes = is.getPos() - dumpInfo.startByte;
|
||||
dumpInfo.previewValue = value;
|
||||
dumpInfo = dumpInfo.parent;
|
||||
}
|
||||
}
|
||||
|
||||
private int readInternal() throws IOException {
|
||||
bytesRead++;
|
||||
int i = is.read();
|
||||
if (DEBUG_READ) {
|
||||
System.out.println("Read:0x" + Integer.toHexString(i));
|
||||
}
|
||||
if (bufferOs != null) {
|
||||
if (i != -1) {
|
||||
bufferOs.write(i);
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public int read(String name) throws IOException {
|
||||
newDumpLevel(name, "byte");
|
||||
int ret = readInternal();
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int read(byte[] b) throws IOException {
|
||||
int currBytesRead = is.read(b);
|
||||
bytesRead += currBytesRead;
|
||||
if (DEBUG_READ) {
|
||||
StringBuilder sb = new StringBuilder("Read[");
|
||||
sb.append(currBytesRead);
|
||||
sb.append('/');
|
||||
sb.append(b.length);
|
||||
sb.append("]: ");
|
||||
for (int jj = 0; jj < currBytesRead; jj++) {
|
||||
sb.append("0x");
|
||||
sb.append(Integer.toHexString(b[jj]));
|
||||
sb.append(' ');
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
if (bufferOs != null) {
|
||||
if (currBytesRead > 0) {
|
||||
bufferOs.write(b, 0, currBytesRead);
|
||||
}
|
||||
}
|
||||
return currBytesRead;
|
||||
}
|
||||
|
||||
public int readU8(String name) throws IOException {
|
||||
newDumpLevel(name, "U8");
|
||||
int ret = readInternal();
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private long readU32Internal() throws IOException {
|
||||
int i;
|
||||
long ret = 0;
|
||||
int bytePos = 0;
|
||||
int byteCount = 0;
|
||||
boolean nextByte;
|
||||
do {
|
||||
i = readInternal();
|
||||
nextByte = (i >> 7) == 1;
|
||||
i &= 0x7f;
|
||||
ret += (((long) i) << bytePos);
|
||||
byteCount++;
|
||||
bytePos += 7;
|
||||
} while (nextByte);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public long readU32(String name) throws IOException {
|
||||
newDumpLevel(name, "U32");
|
||||
long ret = readU32Internal();
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int readU30Internal() throws IOException {
|
||||
return (int) readU32Internal();
|
||||
}
|
||||
|
||||
public int readU30(String name) throws IOException {
|
||||
newDumpLevel(name, "U30");
|
||||
int ret = readU30Internal();
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int readS24(String name) throws IOException {
|
||||
newDumpLevel(name, "S24");
|
||||
int ret = (readInternal()) + (readInternal() << 8) + (readInternal() << 16);
|
||||
|
||||
if ((ret >> 23) == 1) {
|
||||
ret |= 0xff000000;
|
||||
}
|
||||
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int readU16(String name) throws IOException {
|
||||
newDumpLevel(name, "U16");
|
||||
int ret = (readInternal()) + (readInternal() << 8);
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public long readS32(String name) throws IOException {
|
||||
int i;
|
||||
long ret = 0;
|
||||
int bytePos = 0;
|
||||
int byteCount = 0;
|
||||
boolean nextByte;
|
||||
newDumpLevel(name, "S32");
|
||||
do {
|
||||
i = readInternal();
|
||||
nextByte = (i >> 7) == 1;
|
||||
i &= 0x7f;
|
||||
ret += (i << bytePos);
|
||||
byteCount++;
|
||||
bytePos += 7;
|
||||
if (bytePos == 35) {
|
||||
if ((ret >> 31) == 1) {
|
||||
ret = -(ret & 0x7fffffff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (nextByte);
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
return is.available();
|
||||
}
|
||||
|
||||
private final long readLong() throws IOException {
|
||||
byte[] readBuffer = safeRead(8);
|
||||
return (((long) readBuffer[7] << 56)
|
||||
+ ((long) (readBuffer[6] & 255) << 48)
|
||||
+ ((long) (readBuffer[5] & 255) << 40)
|
||||
+ ((long) (readBuffer[4] & 255) << 32)
|
||||
+ ((long) (readBuffer[3] & 255) << 24)
|
||||
+ ((readBuffer[2] & 255) << 16)
|
||||
+ ((readBuffer[1] & 255) << 8)
|
||||
+ ((readBuffer[0] & 255)));
|
||||
}
|
||||
|
||||
public double readDouble(String name) throws IOException {
|
||||
newDumpLevel(name, "Double");
|
||||
long el = readLong();
|
||||
double ret = Double.longBitsToDouble(el);
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private byte[] safeRead(int count) throws IOException {
|
||||
byte[] ret = new byte[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
ret[i] = (byte) readInternal();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Namespace readNamespace(String name) throws IOException {
|
||||
newDumpLevel(name, "Namespace");
|
||||
int kind = read("kind");
|
||||
int name_index = 0;
|
||||
for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) {
|
||||
if (Namespace.nameSpaceKinds[k] == kind) {
|
||||
name_index = readU30("name_index");
|
||||
break;
|
||||
}
|
||||
}
|
||||
endDumpLevel();
|
||||
return new Namespace(kind, name_index);
|
||||
}
|
||||
|
||||
public Multiname readMultiname(String name) throws IOException {
|
||||
int kind = readU8("kind");
|
||||
int namespace_index = 0;
|
||||
int name_index = 0;
|
||||
int namespace_set_index = 0;
|
||||
int qname_index = 0;
|
||||
List<Integer> params = new ArrayList<>();
|
||||
|
||||
newDumpLevel(name, "Multiname");
|
||||
if ((kind == Multiname.QNAME) || (kind == Multiname.QNAMEA)) {
|
||||
namespace_index = readU30("namespace_index");
|
||||
name_index = readU30("name_index");
|
||||
} else if ((kind == Multiname.RTQNAME) || (kind == Multiname.RTQNAMEA)) {
|
||||
name_index = readU30("name_index");
|
||||
} else if ((kind == Multiname.RTQNAMEL) || (kind == Multiname.RTQNAMELA)) {
|
||||
|
||||
} else if ((kind == Multiname.MULTINAME) || (kind == Multiname.MULTINAMEA)) {
|
||||
name_index = readU30("name_index");
|
||||
namespace_set_index = readU30("namespace_set_index");
|
||||
} else if ((kind == Multiname.MULTINAMEL) || (kind == Multiname.MULTINAMELA)) {
|
||||
namespace_set_index = readU30("namespace_set_index");
|
||||
} else if (kind == Multiname.TYPENAME) {
|
||||
qname_index = readU30("qname_index"); //Multiname index!!!
|
||||
int paramsLength = readU30("paramsLength");
|
||||
for (int i = 0; i < paramsLength; i++) {
|
||||
params.add(readU30("param")); //multiname indices!
|
||||
}
|
||||
} else {
|
||||
throw new IOException("Unknown kind of Multiname:0x" + Integer.toHexString(kind));
|
||||
}
|
||||
|
||||
endDumpLevel();
|
||||
return new Multiname(kind, name_index, namespace_index, namespace_set_index, qname_index, params);
|
||||
}
|
||||
|
||||
public MethodInfo readMethodInfo(String name) throws IOException {
|
||||
newDumpLevel(name, "method_info");
|
||||
int param_count = readU30("param_count");
|
||||
int ret_type = readU30("ret_type");
|
||||
int[] param_types = new int[param_count];
|
||||
for (int i = 0; i < param_count; i++) {
|
||||
param_types[i] = readU30("param_type");
|
||||
}
|
||||
int name_index = readU30("name_index");
|
||||
int flags = read("flags");
|
||||
|
||||
//// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames
|
||||
ValueKind[] optional = new ValueKind[0];
|
||||
if ((flags & 8) == 8) { //if has_optional
|
||||
int optional_count = readU30("optional_count");
|
||||
optional = new ValueKind[optional_count];
|
||||
for (int i = 0; i < optional_count; i++) {
|
||||
optional[i] = new ValueKind(readU30("value_index"), read("value_kind"));
|
||||
}
|
||||
}
|
||||
|
||||
int[] param_names = new int[param_count];
|
||||
if ((flags & 128) == 128) { //if has_paramnames
|
||||
for (int i = 0; i < param_count; i++) {
|
||||
param_names[i] = readU30("param_name");
|
||||
}
|
||||
}
|
||||
|
||||
endDumpLevel();
|
||||
return new MethodInfo(param_types, ret_type, name_index, flags, optional, param_names);
|
||||
}
|
||||
|
||||
public Trait readTrait(String name) throws IOException {
|
||||
newDumpLevel(name, "Trait");
|
||||
long pos = getPosition();
|
||||
startBuffer();
|
||||
int name_index = readU30("name_index");
|
||||
int kind = read("kind");
|
||||
int kindType = 0xf & kind;
|
||||
int kindFlags = kind >> 4;
|
||||
Trait trait;
|
||||
|
||||
switch (kindType) {
|
||||
case 0: //slot
|
||||
case 6: //const
|
||||
TraitSlotConst t1 = new TraitSlotConst();
|
||||
t1.slot_id = readU30("slot_id");
|
||||
t1.type_index = readU30("type_index");
|
||||
t1.value_index = readU30("value_index");
|
||||
if (t1.value_index != 0) {
|
||||
t1.value_kind = read("value_kind");
|
||||
}
|
||||
trait = t1;
|
||||
break;
|
||||
case 1: //method
|
||||
case 2: //getter
|
||||
case 3: //setter
|
||||
TraitMethodGetterSetter t2 = new TraitMethodGetterSetter();
|
||||
t2.disp_id = readU30("disp_id");
|
||||
t2.method_info = readU30("method_info");
|
||||
trait = t2;
|
||||
break;
|
||||
case 4: //class
|
||||
TraitClass t3 = new TraitClass();
|
||||
t3.slot_id = readU30("slot_id");
|
||||
t3.class_info = readU30("class_info");
|
||||
trait = t3;
|
||||
break;
|
||||
case 5: //function
|
||||
TraitFunction t4 = new TraitFunction();
|
||||
t4.slot_id = readU30("slot_id");
|
||||
t4.method_info = readU30("method_info");
|
||||
trait = t4;
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown trait kind:" + kind);
|
||||
}
|
||||
trait.fileOffset = pos;
|
||||
trait.kindType = kindType;
|
||||
trait.kindFlags = kindFlags;
|
||||
trait.name_index = name_index;
|
||||
if ((kindFlags & ATTR_METADATA) != 0) {
|
||||
int metadata_count = readU30("metadata_count");
|
||||
trait.metadata = new int[metadata_count];
|
||||
for (int i = 0; i < metadata_count; i++) {
|
||||
trait.metadata[i] = readU30("metadata");
|
||||
}
|
||||
}
|
||||
trait.bytes = stopBuffer();
|
||||
endDumpLevel();
|
||||
return trait;
|
||||
}
|
||||
|
||||
public Traits readTraits(String name) throws IOException {
|
||||
newDumpLevel(name, "Traits");
|
||||
int count = readU30("count");
|
||||
Traits traits = new Traits();
|
||||
traits.traits = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
traits.traits.add(readTrait("trait"));
|
||||
}
|
||||
endDumpLevel();
|
||||
return traits;
|
||||
}
|
||||
|
||||
private byte[] readBytesInternal(int count) throws IOException {
|
||||
byte[] ret = new byte[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
ret[i] = (byte) readInternal();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte[] readBytes(int count, String name) throws IOException {
|
||||
newDumpLevel(name, "Bytes");
|
||||
byte[] ret = readBytesInternal(count);
|
||||
endDumpLevel();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Decimal readDecimal(String name) throws IOException {
|
||||
newDumpLevel(name, "Decimal");
|
||||
byte[] data = readBytesInternal(16);
|
||||
endDumpLevel();
|
||||
return new Decimal(data);
|
||||
}
|
||||
|
||||
public InstanceInfo readInstanceInfo(String name) throws IOException {
|
||||
newDumpLevel(name, "instance_info");
|
||||
InstanceInfo ret = new InstanceInfo();
|
||||
ret.name_index = readU30("name_index");
|
||||
ret.super_index = readU30("super_index");
|
||||
ret.flags = readInternal();
|
||||
if ((ret.flags & CLASS_PROTECTED_NS) != 0) {
|
||||
ret.protectedNS = readU30("protectedNS");
|
||||
}
|
||||
int interfaces_count = readU30("interfaces_count");
|
||||
ret.interfaces = new int[interfaces_count];
|
||||
for (int i = 0; i < interfaces_count; i++) {
|
||||
ret.interfaces[i] = readU30("interface");
|
||||
}
|
||||
ret.iinit_index = readU30("iinit_index");
|
||||
ret.instance_traits = readTraits("instance_traits");
|
||||
endDumpLevel();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String readString(String name) throws IOException {
|
||||
newDumpLevel(name, "String");
|
||||
int length = readU30Internal();
|
||||
byte[] b = safeRead(length);
|
||||
String r = new String(b, Utf8Helper.charset);
|
||||
endDumpLevel(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*public void markStart(){
|
||||
bytesRead=0;
|
||||
}*/
|
||||
public long getPosition() {
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.Decimal;
|
||||
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class ABCOutputStream extends OutputStream {
|
||||
|
||||
private final OutputStream os;
|
||||
|
||||
public ABCOutputStream(OutputStream os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
os.write(b);
|
||||
}
|
||||
|
||||
public void writeU30(long value) throws IOException {
|
||||
writeS32(value);
|
||||
/*boolean loop = true;
|
||||
boolean underZero=value<0;
|
||||
|
||||
if(underZero){
|
||||
value = value & 0xFFFFFFFF;
|
||||
}else{
|
||||
value = value & 0x7FFFFFFF;
|
||||
}
|
||||
do {
|
||||
int ret = (int) (value & 0x7F);
|
||||
if (value < 0x80) {
|
||||
loop = false;
|
||||
}
|
||||
if (value > 0x7F) {
|
||||
ret += 0x80;
|
||||
}
|
||||
write(ret);
|
||||
value = value >> 7;
|
||||
} while (loop);
|
||||
*/
|
||||
}
|
||||
|
||||
public void writeU32(long value) throws IOException {
|
||||
boolean loop = true;
|
||||
value &= 0xFFFFFFFF;
|
||||
do {
|
||||
int ret = (int) (value & 0x7F);
|
||||
if (value < 0x80) {
|
||||
loop = false;
|
||||
}
|
||||
if (value > 0x7F) {
|
||||
ret += 0x80;
|
||||
}
|
||||
write(ret);
|
||||
value >>= 7;
|
||||
} while (loop);
|
||||
}
|
||||
|
||||
public void writeS24(long value) throws IOException {
|
||||
int ret = (int) (value & 0xff);
|
||||
write(ret);
|
||||
value >>= 8;
|
||||
ret = (int) (value & 0xff);
|
||||
write(ret);
|
||||
value >>= 8;
|
||||
ret = (int) (value & 0xff);
|
||||
write(ret);
|
||||
}
|
||||
|
||||
public void writeS32(long value) throws IOException {
|
||||
boolean belowZero = value < 0;
|
||||
/*if (belowZero) {
|
||||
value = -value;
|
||||
}*/
|
||||
int bitcount = 0;
|
||||
boolean loop = true;
|
||||
//value = value & 0xFFFFFFFF;
|
||||
do {
|
||||
bitcount += 7;
|
||||
int ret = (int) (value & 0x7F);
|
||||
if (value < 0x80) {
|
||||
if (belowZero) { //&& bitcount < 35
|
||||
ret += 0x80;
|
||||
} else {
|
||||
loop = false;
|
||||
}
|
||||
} else {
|
||||
ret += 0x80;
|
||||
}
|
||||
|
||||
if (bitcount == 35) {
|
||||
ret &= 0xf;
|
||||
}
|
||||
write(ret);
|
||||
if (bitcount == 35) {
|
||||
break;
|
||||
}
|
||||
value >>= 7;
|
||||
} while (loop);
|
||||
}
|
||||
|
||||
public void writeLong(long value) throws IOException {
|
||||
byte[] writeBuffer = new byte[8];
|
||||
writeBuffer[7] = (byte) (value >>> 56);
|
||||
writeBuffer[6] = (byte) (value >>> 48);
|
||||
writeBuffer[5] = (byte) (value >>> 40);
|
||||
writeBuffer[4] = (byte) (value >>> 32);
|
||||
writeBuffer[3] = (byte) (value >>> 24);
|
||||
writeBuffer[2] = (byte) (value >>> 16);
|
||||
writeBuffer[1] = (byte) (value >>> 8);
|
||||
writeBuffer[0] = (byte) (value);
|
||||
write(writeBuffer);
|
||||
}
|
||||
|
||||
public void writeDouble(double value) throws IOException {
|
||||
writeLong(Double.doubleToLongBits(value));
|
||||
}
|
||||
|
||||
public void writeU8(int value) throws IOException {
|
||||
write(value);
|
||||
}
|
||||
|
||||
public void writeU16(int value) throws IOException {
|
||||
write(value & 0xff);
|
||||
write((value >> 8) & 0xff);
|
||||
}
|
||||
|
||||
public void writeString(String s) throws IOException {
|
||||
byte[] sbytes = Utf8Helper.getBytes(s);
|
||||
writeU30(sbytes.length);
|
||||
write(sbytes);
|
||||
}
|
||||
|
||||
public void writeNamespace(Namespace ns) throws IOException {
|
||||
write(ns.kind);
|
||||
boolean found = false;
|
||||
for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) {
|
||||
if (Namespace.nameSpaceKinds[k] == ns.kind) {
|
||||
writeU30(ns.name_index);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
throw new RuntimeException("Invalid ns kind:" + ns.kind);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeMultiname(Multiname m) throws IOException {
|
||||
writeU8(m.kind);
|
||||
if ((m.kind == 7) || (m.kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA.
|
||||
writeU30(m.namespace_index);
|
||||
writeU30(m.name_index);
|
||||
}
|
||||
if ((m.kind == 9) || (m.kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA.
|
||||
writeU30(m.name_index);
|
||||
writeU30(m.namespace_set_index);
|
||||
}
|
||||
if ((m.kind == 0xf) || (m.kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA
|
||||
writeU30(m.name_index);
|
||||
}
|
||||
if ((m.kind == 0x1B) || (m.kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA
|
||||
writeU30(m.namespace_set_index);
|
||||
}
|
||||
if (m.kind == 0x1D) {
|
||||
writeU30(m.qname_index);
|
||||
writeU30(m.params.size());
|
||||
for (int i = 0; i < m.params.size(); i++) {
|
||||
writeU30(m.params.get(i));
|
||||
}
|
||||
}
|
||||
//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA.
|
||||
}
|
||||
|
||||
public void writeMethodInfo(MethodInfo mi) throws IOException {
|
||||
writeU30(mi.param_types.length);
|
||||
writeU30(mi.ret_type);
|
||||
for (int i = 0; i < mi.param_types.length; i++) {
|
||||
writeU30(mi.param_types[i]);
|
||||
}
|
||||
writeU30(mi.name_index);
|
||||
write(mi.flags);
|
||||
if ((mi.flags & 8) == 8) {
|
||||
writeU30(mi.optional.length);
|
||||
for (int i = 0; i < mi.optional.length; i++) {
|
||||
writeU30(mi.optional[i].value_index);
|
||||
write(mi.optional[i].value_kind);
|
||||
}
|
||||
}
|
||||
|
||||
if ((mi.flags & 128) == 128) { //if has_paramnames
|
||||
for (int i = 0; i < mi.paramNames.length; i++) {
|
||||
writeU30(mi.paramNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTrait(Trait t) throws IOException {
|
||||
writeU30(t.name_index);
|
||||
write((t.kindFlags << 4) + t.kindType);
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst t1 = (TraitSlotConst) t;
|
||||
writeU30(t1.slot_id);
|
||||
writeU30(t1.type_index);
|
||||
writeU30(t1.value_index);
|
||||
if (t1.value_index != 0) {
|
||||
write(t1.value_kind);
|
||||
}
|
||||
}
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
writeU30(t2.disp_id);
|
||||
writeU30(t2.method_info);
|
||||
}
|
||||
if (t instanceof TraitClass) {
|
||||
TraitClass t3 = (TraitClass) t;
|
||||
writeU30(t3.slot_id);
|
||||
writeU30(t3.class_info);
|
||||
}
|
||||
if (t instanceof TraitFunction) {
|
||||
TraitFunction t4 = (TraitFunction) t;
|
||||
writeU30(t4.slot_id);
|
||||
writeU30(t4.method_info);
|
||||
}
|
||||
if ((t.kindFlags & 4) == 4) {
|
||||
writeU30(t.metadata.length);
|
||||
for (int i = 0; i < t.metadata.length; i++) {
|
||||
writeU30(t.metadata[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTraits(Traits t) throws IOException {
|
||||
writeU30(t.traits.size());
|
||||
for (int i = 0; i < t.traits.size(); i++) {
|
||||
writeTrait(t.traits.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeInstanceInfo(InstanceInfo ii) throws IOException {
|
||||
writeU30(ii.name_index);
|
||||
writeU30(ii.super_index);
|
||||
write(ii.flags);
|
||||
if ((ii.flags & 8) == 8) {
|
||||
writeU30(ii.protectedNS);
|
||||
}
|
||||
writeU30(ii.interfaces.length);
|
||||
for (int i = 0; i < ii.interfaces.length; i++) {
|
||||
writeU30(ii.interfaces[i]);
|
||||
}
|
||||
writeU30(ii.iinit_index);
|
||||
writeTraits(ii.instance_traits);
|
||||
}
|
||||
|
||||
public void writeDecimal(Decimal value) throws IOException {
|
||||
write(value.data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AVM2LocalData extends BaseLocalData {
|
||||
|
||||
public Boolean isStatic;
|
||||
public Integer classIndex;
|
||||
public HashMap<Integer, GraphTargetItem> localRegs;
|
||||
public ScopeStack scopeStack;
|
||||
public ConstantPool constants;
|
||||
public List<MethodInfo> methodInfo;
|
||||
public MethodBody methodBody;
|
||||
public ABC abc;
|
||||
public HashMap<Integer, String> localRegNames;
|
||||
public List<String> fullyQualifiedNames;
|
||||
public ArrayList<ABCException> parsedExceptions;
|
||||
public ArrayList<Integer> finallyJumps;
|
||||
public ArrayList<Integer> ignoredSwitches;
|
||||
public Integer scriptIndex;
|
||||
public HashMap<Integer, Integer> localRegAssignmentIps;
|
||||
public Integer ip;
|
||||
public HashMap<Integer, List<Integer>> refs;
|
||||
public AVM2Code code;
|
||||
|
||||
public AVM2LocalData() {
|
||||
|
||||
}
|
||||
|
||||
public AVM2LocalData(AVM2LocalData localData) {
|
||||
isStatic = localData.isStatic;
|
||||
classIndex = localData.classIndex;
|
||||
localRegs = localData.localRegs;
|
||||
scopeStack = localData.scopeStack;
|
||||
constants = localData.constants;
|
||||
methodInfo = localData.methodInfo;
|
||||
methodBody = localData.methodBody;
|
||||
abc = localData.abc;
|
||||
localRegNames = localData.localRegNames;
|
||||
fullyQualifiedNames = localData.fullyQualifiedNames;
|
||||
parsedExceptions = localData.parsedExceptions;
|
||||
finallyJumps = localData.finallyJumps;
|
||||
ignoredSwitches = localData.ignoredSwitches;
|
||||
scriptIndex = localData.scriptIndex;
|
||||
localRegAssignmentIps = localData.localRegAssignmentIps;
|
||||
ip = localData.ip;
|
||||
refs = localData.refs;
|
||||
code = localData.code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ClassPath {
|
||||
|
||||
public String packageStr;
|
||||
public String className;
|
||||
|
||||
public ClassPath(String packageStr, String className) {
|
||||
this.packageStr = packageStr;
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (packageStr == null || packageStr.isEmpty()) ? className : packageStr + "." + className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 37 * hash + Objects.hashCode(this.packageStr);
|
||||
hash = 37 * hash + Objects.hashCode(this.className);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ClassPath other = (ClassPath) obj;
|
||||
if (!Objects.equals(this.packageStr, other.packageStr)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.className, other.className)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class CopyOutputStream extends OutputStream {
|
||||
|
||||
private final OutputStream os;
|
||||
private final InputStream is;
|
||||
private long pos = 0;
|
||||
private final int TEMPSIZE = 5;
|
||||
private final int[] temp = new int[TEMPSIZE];
|
||||
private int tempPos = 0;
|
||||
public int ignoreFirst = 0;
|
||||
|
||||
public CopyOutputStream(OutputStream os, InputStream is) {
|
||||
this.os = os;
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
temp[tempPos] = b;
|
||||
tempPos = (tempPos + 1) % TEMPSIZE;
|
||||
|
||||
pos++;
|
||||
int r = is.read();
|
||||
if ((b & 0xff) != r) {
|
||||
if (ignoreFirst <= 0) {
|
||||
os.flush();
|
||||
|
||||
boolean output = true;
|
||||
|
||||
if (output) {
|
||||
System.out.println("Position: " + pos);
|
||||
System.out.print("Last written:");
|
||||
for (int i = 0; i < TEMPSIZE; i++) {
|
||||
System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " ");
|
||||
}
|
||||
System.out.println("");
|
||||
System.out.println("More expected:");
|
||||
for (int i = 0; i < TEMPSIZE; i++) {
|
||||
System.out.println("" + Integer.toHexString(is.read()));
|
||||
}
|
||||
|
||||
System.out.println("");
|
||||
System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found");
|
||||
}
|
||||
throw new NotSameException(pos);
|
||||
} else {
|
||||
ignoreFirst--;
|
||||
}
|
||||
}
|
||||
os.write(b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.helpers.Helper;
|
||||
|
||||
public class NotSameException extends RuntimeException {
|
||||
|
||||
public NotSameException(long pos) {
|
||||
super("Streams are not the same at pos " + Helper.formatHex((int) pos, 8));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum RenameType {
|
||||
|
||||
TYPENUMBER,
|
||||
RANDOMWORD
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeElementItem;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ScriptPack implements TreeElementItem {
|
||||
|
||||
public ABC abc;
|
||||
public int scriptIndex;
|
||||
public List<Integer> traitIndices;
|
||||
private final ClassPath path;
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return abc.swf;
|
||||
}
|
||||
|
||||
public ClassPath getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public ScriptPack(ClassPath path, ABC abc, int scriptIndex, List<Integer> traitIndices) {
|
||||
this.abc = abc;
|
||||
this.scriptIndex = scriptIndex;
|
||||
this.traitIndices = traitIndices;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPathPackage() {
|
||||
String packageName = "";
|
||||
for (int t : traitIndices) {
|
||||
Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
packageName = ns.getName(abc.constants); //assume not null
|
||||
}
|
||||
}
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public String getPathScriptName() {
|
||||
String scriptName = "";
|
||||
for (int t : traitIndices) {
|
||||
Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
scriptName = name.getName(abc.constants, new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
return scriptName;
|
||||
}
|
||||
|
||||
/*public String getPath() {
|
||||
String packageName = "";
|
||||
String scriptName = "";
|
||||
for (int t : traitIndices) {
|
||||
Multiname name = abc.script_info[scriptIndex].traits.traits.get(t).getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
packageName = ns.getName(abc.constants);
|
||||
scriptName = name.getName(abc.constants, new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
return packageName.equals("") ? scriptName : packageName + "." + scriptName;
|
||||
}*/
|
||||
private static String makeDirPath(String packageName) {
|
||||
if (packageName.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
String[] pathParts;
|
||||
if (packageName.contains(".")) {
|
||||
pathParts = packageName.split("\\.");
|
||||
} else {
|
||||
pathParts = new String[]{packageName};
|
||||
}
|
||||
for (int i = 0; i < pathParts.length; i++) {
|
||||
pathParts[i] = Helper.makeFileName(pathParts[i]);
|
||||
}
|
||||
return Helper.joinStrings(pathParts, File.separator);
|
||||
}
|
||||
|
||||
public void convert(final NulWriter writer, final List<ABCContainerTag> abcList, final List<Trait> traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
|
||||
for (int t : traitIndices) {
|
||||
Trait trait = traits.get(t);
|
||||
Multiname name = trait.getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
trait.convertPackaged(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
|
||||
} else {
|
||||
trait.convert(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void appendTo(GraphTextWriter writer, List<ABCContainerTag> abcList, List<Trait> traits, ScriptExportMode exportMode, boolean parallel) throws InterruptedException {
|
||||
for (int t : traitIndices) {
|
||||
Trait trait = traits.get(t);
|
||||
Multiname name = trait.getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
trait.toStringPackaged(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
|
||||
} else {
|
||||
trait.toString(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toSource(GraphTextWriter writer, final List<ABCContainerTag> abcList, final List<Trait> traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
|
||||
writer.suspendMeasure();
|
||||
int timeout = Configuration.decompilationTimeoutFile.get();
|
||||
try {
|
||||
CancellableWorker.call(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
convert(new NulWriter(), abcList, traits, exportMode, parallel);
|
||||
return null;
|
||||
}
|
||||
}, timeout, TimeUnit.SECONDS);
|
||||
} catch (TimeoutException ex) {
|
||||
writer.continueMeasure();
|
||||
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", ex);
|
||||
Helper.appendTimeoutComment(writer, timeout);
|
||||
return;
|
||||
} catch (ExecutionException ex) {
|
||||
writer.continueMeasure();
|
||||
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", ex);
|
||||
Helper.appendErrorComment(writer, ex);
|
||||
return;
|
||||
}
|
||||
writer.continueMeasure();
|
||||
|
||||
appendTo(writer, abcList, traits, exportMode, parallel);
|
||||
}
|
||||
|
||||
public File export(String directory, List<ABCContainerTag> abcList, ScriptExportMode exportMode, boolean parallel) throws IOException {
|
||||
String scriptName = getPathScriptName();
|
||||
String packageName = getPathPackage();
|
||||
File outDir = new File(directory + File.separatorChar + makeDirPath(packageName));
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
if (!outDir.exists()) {
|
||||
throw new IOException("cannot create directory " + outDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + ".as";
|
||||
|
||||
File file = new File(fileName);
|
||||
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
|
||||
try {
|
||||
toSource(writer, abcList, abc.script_info.get(scriptIndex).traits.traits, exportMode, parallel);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ScriptPack.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.RenameType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AVM2Deobfuscation {
|
||||
|
||||
private static final Random rnd = new Random();
|
||||
private static final int DEFAULT_FOO_SIZE = 10;
|
||||
|
||||
public static final String[] reservedWords = {
|
||||
"as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else",
|
||||
"extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof",
|
||||
"interface", "internal", "is", "native", "new", "null", "override", "package", "private", "protected", "public",
|
||||
"return", "set", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while",
|
||||
"with", "dynamic", "default", "final", "in", "static"};
|
||||
public static final String VALID_FIRST_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
|
||||
public static final String VALID_NEXT_CHARACTERS = VALID_FIRST_CHARACTERS + "0123456789";
|
||||
public static final String VALID_NS_CHARACTERS = ".:$";
|
||||
public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz";
|
||||
public static final String FOO_JOIN_CHARACTERS = "aeiouy";
|
||||
|
||||
private final ConstantPool constants;
|
||||
private final Map<String, Integer> usageTypesCount = new HashMap<>();
|
||||
|
||||
public AVM2Deobfuscation(ConstantPool constants) {
|
||||
this.constants = constants;
|
||||
}
|
||||
|
||||
private static boolean isReserved(String s) {
|
||||
for (String rw : reservedWords) {
|
||||
if (rw.equals(s.trim())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isValidNSPart(String s) {
|
||||
boolean isValid = true;
|
||||
if (isReserved(s)) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) > 127) {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isValid) {
|
||||
Pattern pat = Pattern.compile("^([" + Pattern.quote(VALID_FIRST_CHARACTERS) + "]" + "[" + Pattern.quote(VALID_FIRST_CHARACTERS + VALID_NEXT_CHARACTERS + VALID_NS_CHARACTERS) + "]*)*$");
|
||||
if (!pat.matcher(s).matches()) {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public String builtInNs(String ns) {
|
||||
if (ns == null) {
|
||||
return null;
|
||||
}
|
||||
if (ns.equals("http://www.adobe.com/2006/actionscript/flash/proxy")) {
|
||||
return "flash.utils.flash_proxy";
|
||||
}
|
||||
if (ns.equals("http://adobe.com/AS3/2006/builtin")) {
|
||||
return "-";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String fooString(HashMap<String, String> deobfuscated, String orig, boolean firstUppercase, int rndSize, String usageType, RenameType renameType) {
|
||||
boolean exists;
|
||||
String ret;
|
||||
int pos = 0;
|
||||
|
||||
if (usageType == null) {
|
||||
usageType = "name";
|
||||
}
|
||||
if (usageTypesCount.containsKey(usageType)) {
|
||||
pos = usageTypesCount.get(usageType);
|
||||
}
|
||||
|
||||
loopfoo:
|
||||
do {
|
||||
exists = false;
|
||||
ret = "";
|
||||
if (renameType == RenameType.TYPENUMBER) {
|
||||
pos++;
|
||||
ret = usageType + "_" + pos;
|
||||
} else if (renameType == RenameType.RANDOMWORD) {
|
||||
int len = 3 + rnd.nextInt(rndSize - 3);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
String c = "";
|
||||
if ((i % 2) == 0) {
|
||||
c = "" + FOO_CHARACTERS.charAt(rnd.nextInt(FOO_CHARACTERS.length()));
|
||||
} else {
|
||||
c = "" + FOO_JOIN_CHARACTERS.charAt(rnd.nextInt(FOO_JOIN_CHARACTERS.length()));
|
||||
}
|
||||
if (i == 0 && firstUppercase) {
|
||||
c = c.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
ret += c;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < constants.getStringCount(); i++) {
|
||||
if (constants.getString(i).equals(ret)) {
|
||||
exists = true;
|
||||
rndSize += 1;
|
||||
continue loopfoo;
|
||||
}
|
||||
}
|
||||
if (isReserved(ret)) {
|
||||
exists = true;
|
||||
rndSize += 1;
|
||||
continue;
|
||||
}
|
||||
if (deobfuscated.containsValue(ret)) {
|
||||
exists = true;
|
||||
rndSize += 1;
|
||||
continue;
|
||||
}
|
||||
} while (exists);
|
||||
usageTypesCount.put(usageType, pos);
|
||||
deobfuscated.put(orig, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int deobfuscatePackageName(Map<Integer, String> stringUsageTypes, Set<Integer> stringUsages, HashMap<String, String> namesMap, int strIndex, RenameType renameType) {
|
||||
if (strIndex <= 0) {
|
||||
return strIndex;
|
||||
}
|
||||
String s = constants.getString(strIndex);
|
||||
if (builtInNs(s) != null) {
|
||||
return strIndex;
|
||||
}
|
||||
boolean isValid = isValidNSPart(s);
|
||||
if (!isValid) {
|
||||
String newName;
|
||||
if (namesMap.containsKey(s)) {
|
||||
newName = constants.setString(strIndex, namesMap.get(s));
|
||||
} else {
|
||||
String[] parts = null;
|
||||
if (s.contains(".")) {
|
||||
parts = s.split("\\.");
|
||||
} else {
|
||||
parts = new String[]{s};
|
||||
}
|
||||
String ret = "";
|
||||
for (int p = 0; p < parts.length; p++) {
|
||||
if (p > 0) {
|
||||
ret += ".";
|
||||
}
|
||||
if (!isValidNSPart(parts[p])) {
|
||||
ret += fooString(namesMap, parts[p], false, DEFAULT_FOO_SIZE, "package", renameType);
|
||||
} else {
|
||||
ret += parts[p];
|
||||
}
|
||||
}
|
||||
newName = ret;
|
||||
namesMap.put(s, newName);
|
||||
}
|
||||
if (stringUsages.contains(strIndex)) {
|
||||
strIndex = constants.addString(newName);
|
||||
} else {
|
||||
constants.setString(strIndex, newName);
|
||||
}
|
||||
|
||||
}
|
||||
return strIndex;
|
||||
}
|
||||
|
||||
public int deobfuscateName(Map<Integer, String> stringUsageTypes, Set<Integer> stringUsages, Set<Integer> namespaceUsages, HashMap<String, String> namesMap, int strIndex, boolean firstUppercase, RenameType renameType) {
|
||||
if (strIndex <= 0) {
|
||||
return strIndex;
|
||||
}
|
||||
String s = constants.getString(strIndex);
|
||||
boolean isValid = true;
|
||||
if (isReserved(s)) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) > 127) {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
Pattern pat = Pattern.compile("^[" + Pattern.quote(VALID_FIRST_CHARACTERS) + "]" + "[" + Pattern.quote(VALID_FIRST_CHARACTERS + VALID_NEXT_CHARACTERS) + "]*$");
|
||||
if (!pat.matcher(s).matches()) {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
String newname;
|
||||
if (namesMap.containsKey(s)) {
|
||||
newname = namesMap.get(s);
|
||||
} else {
|
||||
newname = fooString(namesMap, constants.getString(strIndex), firstUppercase, DEFAULT_FOO_SIZE, stringUsageTypes.get(strIndex), renameType);
|
||||
}
|
||||
if (stringUsages.contains(strIndex) || namespaceUsages.contains(strIndex)) { //this name is already referenced as String
|
||||
strIndex = constants.addString(s); //add new index
|
||||
}
|
||||
constants.setString(strIndex, newname);
|
||||
if (!namesMap.containsKey(s)) {
|
||||
namesMap.put(s, constants.getString(strIndex));
|
||||
}
|
||||
}
|
||||
return strIndex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class CodeStats {
|
||||
|
||||
public int maxstack = 0;
|
||||
public int maxscope = 0;
|
||||
public int maxlocal = 1;
|
||||
public int initscope = 0;
|
||||
public boolean has_set_dxns = false;
|
||||
public boolean has_activation = false;
|
||||
public InstructionStats[] instructionStats;
|
||||
|
||||
public GraphTextWriter toString(GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
|
||||
writer.appendNoHilight("Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal).newLine();
|
||||
int i = 0;
|
||||
int ms = 0;
|
||||
for (InstructionStats stats : instructionStats) {
|
||||
int deltastack = stats.ins.definition.getStackDelta(stats.ins, abc);
|
||||
if (stats.stackpos > ms) {
|
||||
ms = stats.stackpos;
|
||||
}
|
||||
writer.appendNoHilight(i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(writer, LocalData.create(abc.constants, null, fullyQualifiedNames))).newLine();
|
||||
i++;
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
public CodeStats(AVM2Code code) {
|
||||
instructionStats = new InstructionStats[code.code.size()];
|
||||
for (int i = 0; i < code.code.size(); i++) {
|
||||
instructionStats[i] = new InstructionStats(code.code.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.Decimal;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstantPool {
|
||||
|
||||
public List<Long> constant_int = new ArrayList<>();
|
||||
public List<Long> constant_uint = new ArrayList<>();
|
||||
public List<Double> constant_double = new ArrayList<>();
|
||||
/* Only for some minor versions */
|
||||
public List<Decimal> constant_decimal = new ArrayList<>();
|
||||
public List<String> constant_string = new ArrayList<>();
|
||||
public List<Namespace> constant_namespace = new ArrayList<>();
|
||||
public List<NamespaceSet> constant_namespace_set = new ArrayList<>();
|
||||
public List<Multiname> constant_multiname = new ArrayList<>();
|
||||
|
||||
public synchronized int addInt(long value) {
|
||||
constant_int.add(value);
|
||||
return constant_int.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addNamespace(Namespace ns) {
|
||||
constant_namespace.add(ns);
|
||||
return constant_namespace.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addNamespaceSet(NamespaceSet nss) {
|
||||
constant_namespace_set.add(nss);
|
||||
return constant_namespace_set.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addMultiname(Multiname m) {
|
||||
constant_multiname.add(m);
|
||||
return constant_multiname.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addUInt(long value) {
|
||||
constant_uint.add(value);
|
||||
return constant_uint.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addDouble(double value) {
|
||||
constant_double.add(value);
|
||||
return constant_double.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addDecimal(Decimal value) {
|
||||
constant_decimal.add(value);
|
||||
return constant_decimal.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addString(String value) {
|
||||
constant_string.add(value);
|
||||
return constant_string.size() - 1;
|
||||
}
|
||||
|
||||
public long setInt(int index, long value) {
|
||||
constant_int.set(index, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Namespace setNamespace(int index, Namespace ns) {
|
||||
constant_namespace.set(index, ns);
|
||||
return ns;
|
||||
}
|
||||
|
||||
public NamespaceSet setNamespaceSet(int index, NamespaceSet nss) {
|
||||
constant_namespace_set.set(index, nss);
|
||||
return nss;
|
||||
}
|
||||
|
||||
public Multiname setMultiname(int index, Multiname m) {
|
||||
constant_multiname.set(index, m);
|
||||
return m;
|
||||
}
|
||||
|
||||
public long setUInt(int index, long value) {
|
||||
constant_uint.set(index, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public double setDouble(int index, double value) {
|
||||
constant_double.set(index, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Decimal setDecimal(int index, Decimal value) {
|
||||
constant_decimal.set(index, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public String setString(int index, String value) {
|
||||
constant_string.set(index, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public long getInt(int index) {
|
||||
return constant_int.get(index);
|
||||
}
|
||||
|
||||
public Namespace getNamespace(int index) {
|
||||
return constant_namespace.get(index);
|
||||
}
|
||||
|
||||
public NamespaceSet getNamespaceSet(int index) {
|
||||
return constant_namespace_set.get(index);
|
||||
}
|
||||
|
||||
public Multiname getMultiname(int index) {
|
||||
return constant_multiname.get(index);
|
||||
}
|
||||
|
||||
public long getUInt(int index) {
|
||||
return constant_uint.get(index);
|
||||
}
|
||||
|
||||
public double getDouble(int index) {
|
||||
return constant_double.get(index);
|
||||
}
|
||||
|
||||
public Decimal getDecimal(int index) {
|
||||
return constant_decimal.get(index);
|
||||
}
|
||||
|
||||
public String getString(int index) {
|
||||
return constant_string.get(index);
|
||||
}
|
||||
|
||||
public int getIntCount() {
|
||||
return constant_int.size();
|
||||
}
|
||||
|
||||
public int getNamespaceCount() {
|
||||
return constant_namespace.size();
|
||||
}
|
||||
|
||||
public int getNamespaceSetCount() {
|
||||
return constant_namespace_set.size();
|
||||
}
|
||||
|
||||
public int getMultinameCount() {
|
||||
return constant_multiname.size();
|
||||
}
|
||||
|
||||
public int getUIntCount() {
|
||||
return constant_uint.size();
|
||||
}
|
||||
|
||||
public int getDoubleCount() {
|
||||
return constant_double.size();
|
||||
}
|
||||
|
||||
public int getDecimalCount() {
|
||||
return constant_decimal.size();
|
||||
}
|
||||
|
||||
public int getStringCount() {
|
||||
return constant_string.size();
|
||||
}
|
||||
|
||||
public int getNamespaceSubIndex(int namespaceId) {
|
||||
Namespace ns = constant_namespace.get(namespaceId);
|
||||
int index = 0;
|
||||
for (int n = 1; n < namespaceId; n++) {
|
||||
if (constant_namespace.get(n).name_index == ns.name_index && constant_namespace.get(n).kind == ns.kind) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public int getNamespaceId(Namespace val, int index) {
|
||||
for (int n = 1; n < constant_namespace.size(); n++) {
|
||||
Namespace ns = constant_namespace.get(n);
|
||||
if (ns.name_index == val.name_index && (ns.kind == val.kind)) {
|
||||
if (index == 0) {
|
||||
return n;
|
||||
}
|
||||
index--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getIntId(long value) {
|
||||
for (int i = 1; i < constant_int.size(); i++) {
|
||||
if (constant_int.get(i) == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getUIntId(long value) {
|
||||
for (int i = 1; i < constant_uint.size(); i++) {
|
||||
if (constant_uint.get(i) == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getDoubleId(double value) {
|
||||
for (int i = 1; i < constant_double.size(); i++) {
|
||||
if (Double.isNaN(value) && Double.isNaN(constant_double.get(i))) {
|
||||
return i;
|
||||
}
|
||||
if (Double.compare(constant_double.get(i), value) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getStringId(String val) {
|
||||
if (val == null) {
|
||||
return 0;
|
||||
}
|
||||
for (int i = 1; i < constant_string.size(); i++) {
|
||||
if (constant_string.get(i).equals(val)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getMultinameId(Multiname val) {
|
||||
loopm:
|
||||
for (int m = 1; m < constant_multiname.size(); m++) {
|
||||
Multiname mul = constant_multiname.get(m);
|
||||
if (mul.kind == val.kind && mul.name_index == val.name_index && mul.namespace_index == val.namespace_index && mul.namespace_set_index == val.namespace_set_index && mul.qname_index == val.qname_index && mul.params.size() == val.params.size()) {
|
||||
for (int p = 0; p < mul.params.size(); p++) {
|
||||
if (mul.params.get(p) != val.params.get(p)) {
|
||||
continue loopm;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getQnameId(String name, int namespaceKind, String namespaceName, boolean add) {
|
||||
return getMultinameId(new Multiname(Multiname.QNAME, getStringId(name, add), getNamespaceId(new Namespace(namespaceKind, getStringId(namespaceName, add)), 0, add), 0, 0, new ArrayList<Integer>()), add);
|
||||
}
|
||||
|
||||
public int getPublicQnameId(String name, boolean add) {
|
||||
return getQnameId(name, Namespace.KIND_PACKAGE, "", add);
|
||||
}
|
||||
|
||||
public int getMultinameId(Multiname val, boolean add) {
|
||||
int id = getMultinameId(val);
|
||||
if (add && id == 0) {
|
||||
id = addMultiname(val);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getStringId(String val, boolean add) {
|
||||
if (val == null) {
|
||||
return 0;
|
||||
}
|
||||
int id = getStringId(val);
|
||||
if (add && id == 0) {
|
||||
id = addString(val);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getIntId(long val, boolean add) {
|
||||
int id = getIntId(val);
|
||||
if (add && id == 0) {
|
||||
id = addInt(val);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getNamespaceId(Namespace val, int index, boolean add) {
|
||||
int id = getNamespaceId(val, index);
|
||||
if (add && id == 0) {
|
||||
id = addNamespace(val);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getNamespaceSetId(NamespaceSet val) {
|
||||
loopi:
|
||||
for (int i = 1; i < constant_namespace_set.size(); i++) {
|
||||
NamespaceSet ts = constant_namespace_set.get(i);
|
||||
if (ts.namespaces.length != val.namespaces.length) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < val.namespaces.length; j++) {
|
||||
boolean found = false;
|
||||
for (int k = 0; k < val.namespaces.length; k++) {
|
||||
if (ts.namespaces[j] == val.namespaces[k]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
continue loopi;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getNamespaceSetId(NamespaceSet val, boolean add) {
|
||||
int id = getNamespaceSetId(val);
|
||||
if (add && id == 0) {
|
||||
id = addNamespaceSet(val);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getUIntId(long val, boolean add) {
|
||||
int id = getUIntId(val);
|
||||
if (add && id == 0) {
|
||||
id = addUInt(val);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getDoubleId(double val, boolean add) {
|
||||
int id = getDoubleId(val);
|
||||
if (add && id == 0) {
|
||||
id = addDouble(val);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public void dump(Utf8PrintWriter writer) {
|
||||
String s = "";
|
||||
for (int i = 1; i < constant_int.size(); i++) {
|
||||
writer.println("INT[" + i + "]=" + constant_int.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_uint.size(); i++) {
|
||||
writer.println("UINT[" + i + "]=" + constant_uint.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_double.size(); i++) {
|
||||
writer.println("Double[" + i + "]=" + constant_double.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_string.size(); i++) {
|
||||
writer.println("String[" + i + "]=" + constant_string.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_namespace.size(); i++) {
|
||||
writer.println("Namespace[" + i + "]=" + constant_namespace.get(i).toString(this));
|
||||
}
|
||||
for (int i = 1; i < constant_namespace_set.size(); i++) {
|
||||
writer.println("NamespaceSet[" + i + "]=" + constant_namespace_set.get(i).toString(this));
|
||||
}
|
||||
|
||||
for (int i = 1; i < constant_multiname.size(); i++) {
|
||||
writer.println("Multiname[" + i + "]=" + constant_multiname.get(i).toString(this, new ArrayList<String>()));
|
||||
}
|
||||
}
|
||||
|
||||
public String multinameToString(int index) {
|
||||
if (index == 0) {
|
||||
return "null";
|
||||
}
|
||||
return constant_multiname.get(index).toString(this, new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String namespaceToString(int index) {
|
||||
if (index == 0) {
|
||||
return "null";
|
||||
}
|
||||
return constant_namespace.get(index).toString(this);
|
||||
}
|
||||
|
||||
public String namespaceSetToString(int index) {
|
||||
if (index == 0) {
|
||||
return "null";
|
||||
}
|
||||
return constant_namespace_set.get(index).toString(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
public class ConvertException extends RuntimeException {
|
||||
|
||||
public int line;
|
||||
|
||||
public ConvertException(String s, int line) {
|
||||
super(s + " on line " + line);
|
||||
this.line = line;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ConvertOutput {
|
||||
|
||||
public TranslateStack stack;
|
||||
public List<GraphTargetItem> output;
|
||||
|
||||
public ConvertOutput(TranslateStack stack, List<GraphTargetItem> output) {
|
||||
this.stack = stack;
|
||||
this.output = output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class InstructionStats {
|
||||
|
||||
public boolean seen = false;
|
||||
public int stackpos = 0;
|
||||
public int scopepos = 0;
|
||||
public int stackpos_after = 0;
|
||||
public int scopepos_after = 0;
|
||||
public AVM2Instruction ins;
|
||||
|
||||
public InstructionStats(AVM2Instruction ins) {
|
||||
this.ins = ins;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
public class InvalidInstructionArguments extends RuntimeException {
|
||||
|
||||
public InvalidInstructionArguments() {
|
||||
super("Invalid method arguments");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Stack;
|
||||
|
||||
public class LocalDataArea {
|
||||
|
||||
public Stack<Object> operandStack = new Stack<>();
|
||||
public Stack<Object> scopeStack = new Stack<>();
|
||||
public HashMap<Integer, Object> localRegisters = new HashMap<>();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
public class UnknownInstructionCode extends RuntimeException {
|
||||
|
||||
public int code;
|
||||
|
||||
public UnknownInstructionCode(int code) {
|
||||
super("Unknown instruction code: 0x" + Integer.toHexString(code));
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
public class UnknownJumpException extends RuntimeException {
|
||||
|
||||
public TranslateStack stack;
|
||||
public int ip;
|
||||
public List<GraphTargetItem> output;
|
||||
|
||||
public UnknownJumpException(TranslateStack stack, int ip, List<GraphTargetItem> output) {
|
||||
this.stack = stack;
|
||||
this.ip = ip;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Unknown jump to " + ip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,813 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.graph;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.FinalProcessLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.LookupSwitchIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntegerTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FilteredCheckAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.InAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NextNameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NextValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ReturnValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.WithAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.FilterAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForEachInAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForInAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.TryAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphPartMulti;
|
||||
import com.jpexs.decompiler.graph.GraphSource;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.BreakItem;
|
||||
import com.jpexs.decompiler.graph.model.IfItem;
|
||||
import com.jpexs.decompiler.graph.model.LoopItem;
|
||||
import com.jpexs.decompiler.graph.model.NotItem;
|
||||
import com.jpexs.decompiler.graph.model.SwitchItem;
|
||||
import com.jpexs.decompiler.graph.model.WhileItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AVM2Graph extends Graph {
|
||||
|
||||
private final AVM2Code avm2code;
|
||||
private final ABC abc;
|
||||
private final MethodBody body;
|
||||
|
||||
public AVM2Code getCode() {
|
||||
return avm2code;
|
||||
}
|
||||
|
||||
public AVM2Graph(AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
|
||||
super(new AVM2GraphSource(code, isStatic, scriptIndex, classIndex, localRegs, scopeStack, abc, body, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs), body.getExceptionEntries());
|
||||
this.avm2code = code;
|
||||
this.abc = abc;
|
||||
this.body = body;
|
||||
/*heads = makeGraph(code, new ArrayList<GraphPart>(), body);
|
||||
this.code = code;
|
||||
this.abc = abc;
|
||||
this.body = body;
|
||||
for (GraphPart head : heads) {
|
||||
fixGraph(head);
|
||||
makeMulti(head, new ArrayList<GraphPart>());
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
public static List<GraphTargetItem> translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) throws InterruptedException {
|
||||
AVM2Graph g = new AVM2Graph(code, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs);
|
||||
|
||||
AVM2LocalData localData = new AVM2LocalData();
|
||||
localData.isStatic = isStatic;
|
||||
localData.classIndex = classIndex;
|
||||
localData.localRegs = localRegs;
|
||||
localData.scopeStack = scopeStack;
|
||||
localData.constants = abc.constants;
|
||||
localData.methodInfo = abc.method_info;
|
||||
localData.methodBody = body;
|
||||
localData.abc = abc;
|
||||
localData.localRegNames = localRegNames;
|
||||
localData.fullyQualifiedNames = fullyQualifiedNames;
|
||||
localData.parsedExceptions = new ArrayList<>();
|
||||
localData.finallyJumps = new ArrayList<>();
|
||||
localData.ignoredSwitches = new ArrayList<>();
|
||||
localData.scriptIndex = scriptIndex;
|
||||
localData.localRegAssignmentIps = new HashMap<>();
|
||||
localData.ip = 0;
|
||||
localData.refs = refs;
|
||||
localData.code = code;
|
||||
g.init(localData);
|
||||
List<GraphPart> allParts = new ArrayList<>();
|
||||
for (GraphPart head : g.heads) {
|
||||
populateParts(head, allParts);
|
||||
}
|
||||
return g.translate(localData, staticOperation, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkGraph(List<GraphPart> allBlocks) {
|
||||
for (ABCException ex : body.exceptions) {
|
||||
int startIp = avm2code.adr2pos(ex.start);
|
||||
int endIp = avm2code.adr2pos(ex.end);
|
||||
int targetIp = avm2code.adr2pos(ex.target);
|
||||
GraphPart target = null;
|
||||
for (GraphPart p : allBlocks) {
|
||||
if (p.start == targetIp) {
|
||||
target = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (GraphPart p : allBlocks) {
|
||||
if (p.start >= startIp && p.end <= endIp) {
|
||||
p.throwParts.add(target);
|
||||
target.refs.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*for(ABCException ex:body.exceptions){
|
||||
for(GraphPart p:allBlocks){
|
||||
boolean next_is_ex_start=false;
|
||||
for(GraphPart n:p.nextParts){
|
||||
if(n.start==code.adr2pos(ex.start)){
|
||||
next_is_ex_start = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(next_is_ex_start){
|
||||
for(GraphPart q:allBlocks){ //find target part
|
||||
if(q.start==code.adr2pos(ex.target)){
|
||||
p.nextParts.add(q);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<GraphTargetItem> check(GraphSource code, BaseLocalData localData, List<GraphPart> allParts, TranslateStack stack, GraphPart parent, GraphPart part, List<GraphPart> stopPart, List<Loop> loops, List<GraphTargetItem> output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
|
||||
List<GraphTargetItem> ret = null;
|
||||
|
||||
AVM2LocalData aLocalData = (AVM2LocalData) localData;
|
||||
List<ABCException> parsedExceptions = aLocalData.parsedExceptions;
|
||||
List<Integer> finallyJumps = aLocalData.finallyJumps;
|
||||
List<Integer> ignoredSwitches = aLocalData.ignoredSwitches;
|
||||
int ip = part.start;
|
||||
int addr = this.avm2code.fixAddrAfterDebugLine(this.avm2code.pos2adr(part.start));
|
||||
int maxend = -1;
|
||||
List<ABCException> catchedExceptions = new ArrayList<>();
|
||||
for (int e = 0; e < body.exceptions.length; e++) {
|
||||
if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) {
|
||||
if (!body.exceptions[e].isFinally()) {
|
||||
if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) {
|
||||
catchedExceptions.clear();
|
||||
maxend = this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end);
|
||||
catchedExceptions.add(body.exceptions[e]);
|
||||
} else if (this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) {
|
||||
catchedExceptions.add(body.exceptions[e]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (catchedExceptions.size() > 0) {
|
||||
/*if (currentLoop != null) {
|
||||
//currentLoop.phase=0;
|
||||
}*/
|
||||
parsedExceptions.addAll(catchedExceptions);
|
||||
int endpos = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(catchedExceptions.get(0).end));
|
||||
int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end);
|
||||
|
||||
List<List<GraphTargetItem>> catchedCommands = new ArrayList<>();
|
||||
if (this.avm2code.code.get(endpos).definition instanceof JumpIns) {
|
||||
int afterCatchAddr = this.avm2code.pos2adr(endpos + 1) + this.avm2code.code.get(endpos).operands[0];
|
||||
int afterCatchPos = this.avm2code.adr2pos(afterCatchAddr);
|
||||
final AVM2Graph t = this;
|
||||
Collections.sort(catchedExceptions, new Comparator<ABCException>() {
|
||||
@Override
|
||||
public int compare(ABCException o1, ABCException o2) {
|
||||
return t.avm2code.fixAddrAfterDebugLine(o1.target) - t.avm2code.fixAddrAfterDebugLine(o2.target);
|
||||
}
|
||||
});
|
||||
|
||||
List<GraphTargetItem> finallyCommands = new ArrayList<>();
|
||||
int returnPos = afterCatchPos;
|
||||
for (int e = 0; e < body.exceptions.length; e++) {
|
||||
if (body.exceptions[e].isFinally()) {
|
||||
if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) {
|
||||
if (afterCatchPos + 1 == code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))) {
|
||||
AVM2Instruction jmpIns = this.avm2code.code.get(code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end)));
|
||||
|
||||
if (jmpIns.definition instanceof JumpIns) {
|
||||
int finStart = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]);
|
||||
|
||||
GraphPart fpart = null;
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.start == finStart) {
|
||||
fpart = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int swPos = -1;
|
||||
for (int f = finStart; f < this.avm2code.code.size(); f++) {
|
||||
if (this.avm2code.code.get(f).definition instanceof LookupSwitchIns) {
|
||||
AVM2Instruction swins = this.avm2code.code.get(f);
|
||||
if (swins.operands.length >= 3) {
|
||||
if (swins.operands[0] == swins.getBytes().length) {
|
||||
if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) {
|
||||
stack.push(new ExceptionAVM2Item(body.exceptions[e]));
|
||||
GraphPart fepart = null;
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.start == f + 1) {
|
||||
fepart = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//this.code.code.get(f).ignored = true;
|
||||
//ignoredSwitches.add(f);
|
||||
swPos = f;
|
||||
|
||||
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
|
||||
stopPart2.add(fepart);
|
||||
//finallyCommands = printGraph(new ArrayList<GraphPart>(), localData, stack, allParts, parent, fpart, stopPart2, loops, staticOperation, path);
|
||||
returnPos = f + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//ignoredSwitches.add(-1);
|
||||
//int igs_size=ignoredSwitches.size();
|
||||
List<Integer> oldFinallyJumps = new ArrayList<>(finallyJumps);
|
||||
finallyJumps.clear();
|
||||
ignoredSwitches.add(swPos);
|
||||
finallyCommands = printGraph(localData, stack, allParts, parent, fpart, null, loops, staticOperation, path);
|
||||
//ignoredSwitches.remove(igs_size-1);
|
||||
finallyJumps.addAll(oldFinallyJumps);
|
||||
finallyJumps.add(finStart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GraphPart retPart = null;
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.start == returnPos) {
|
||||
retPart = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<GraphPart> catchParts = new ArrayList<>();
|
||||
for (int e = 0; e < catchedExceptions.size(); e++) {
|
||||
int eendpos;
|
||||
if (e < catchedExceptions.size() - 1) {
|
||||
eendpos = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2;
|
||||
} else {
|
||||
eendpos = afterCatchPos - 1;
|
||||
}
|
||||
|
||||
GraphPart npart = null;
|
||||
int findpos = code.adr2pos(catchedExceptions.get(e).target);
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.start == findpos) {
|
||||
npart = p;
|
||||
catchParts.add(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GraphPart nepart = null;
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.start == eendpos + 1) {
|
||||
nepart = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
stack.add(new ExceptionAVM2Item(catchedExceptions.get(e)));
|
||||
AVM2LocalData localData2 = new AVM2LocalData(aLocalData);
|
||||
localData2.scopeStack = new ScopeStack();
|
||||
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
|
||||
stopPart2.add(nepart);
|
||||
if (retPart != null) {
|
||||
stopPart2.add(retPart);
|
||||
}
|
||||
catchedCommands.add(printGraph(localData2, stack, allParts, parent, npart, stopPart2, loops, staticOperation, path));
|
||||
}
|
||||
|
||||
GraphPart nepart = null;
|
||||
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.start == endposStartBlock) {
|
||||
nepart = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
|
||||
stopPart2.add(nepart);
|
||||
stopPart2.addAll(catchParts);
|
||||
|
||||
if (retPart != null) {
|
||||
stopPart2.add(retPart);
|
||||
}
|
||||
List<GraphTargetItem> tryCommands = printGraph(localData, stack, allParts, parent, part, stopPart2, loops, staticOperation, path);
|
||||
|
||||
output.clear();
|
||||
output.add(new TryAVM2Item(tryCommands, catchedExceptions, catchedCommands, finallyCommands));
|
||||
ip = returnPos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ip != part.start) {
|
||||
part = null;
|
||||
for (GraphPart p : allParts) {
|
||||
List<GraphPart> ps = p.getSubParts();
|
||||
for (GraphPart p2 : ps) {
|
||||
if (p2.start == ip) {
|
||||
part = p2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = new ArrayList<>();
|
||||
ret.addAll(output);
|
||||
GraphTargetItem lop = checkLoop(part, stopPart, loops);
|
||||
if (lop == null) {
|
||||
ret.addAll(printGraph(localData, stack, allParts, null, part, stopPart, loops, staticOperation, path));
|
||||
} else {
|
||||
ret.add(lop);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (part.nextParts.isEmpty()) {
|
||||
if (this.avm2code.code.get(part.end).definition instanceof ReturnValueIns) { //returns in finally clause
|
||||
if (part.getHeight() >= 3) {
|
||||
if (this.avm2code.code.get(part.getPosAt(part.getHeight() - 2)).definition instanceof KillIns) {
|
||||
if (this.avm2code.code.get(part.getPosAt(part.getHeight() - 3)).definition instanceof GetLocalTypeIns) {
|
||||
if (output.size() >= 2) {
|
||||
if (output.get(output.size() - 2) instanceof SetLocalAVM2Item) {
|
||||
ret = new ArrayList<>();
|
||||
ret.addAll(output);
|
||||
ret.remove(ret.size() - 1);
|
||||
ret.add(new ReturnValueAVM2Item(this.avm2code.code.get(part.end), ((SetLocalAVM2Item) output.get(output.size() - 2)).value));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((this.avm2code.code.get(part.end).definition instanceof LookupSwitchIns) && ignoredSwitches.contains(part.end)) {
|
||||
ret = new ArrayList<>();
|
||||
ret.addAll(output);
|
||||
return ret;
|
||||
}
|
||||
if (((part.nextParts.size() == 2)
|
||||
&& (!stack.isEmpty())
|
||||
&& (stack.peek() instanceof StrictEqAVM2Item)
|
||||
&& (part.nextParts.get(0).getHeight() >= 2)
|
||||
&& (this.avm2code.code.get(this.avm2code.fixIPAfterDebugLine(part.nextParts.get(0).start)).definition instanceof PushIntegerTypeIns)
|
||||
&& (!part.nextParts.get(0).nextParts.isEmpty())
|
||||
&& (this.avm2code.code.get(part.nextParts.get(0).nextParts.get(0).end).definition instanceof LookupSwitchIns))
|
||||
|| ((part.nextParts.size() == 2)
|
||||
&& (!stack.isEmpty())
|
||||
&& (stack.peek() instanceof StrictNeqAVM2Item)
|
||||
&& (part.nextParts.get(1).getHeight() >= 2)
|
||||
&& (this.avm2code.code.get(this.avm2code.fixIPAfterDebugLine(part.nextParts.get(1).start)).definition instanceof PushIntegerTypeIns)
|
||||
&& (!part.nextParts.get(1).nextParts.isEmpty())
|
||||
&& (this.avm2code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) {
|
||||
|
||||
if (stack.peek() instanceof StrictEqAVM2Item) {
|
||||
ignoredSwitches.add(part.nextParts.get(0).nextParts.get(0).end);
|
||||
} else {
|
||||
ignoredSwitches.add(part.nextParts.get(1).nextParts.get(0).end);
|
||||
}
|
||||
ret = new ArrayList<>();
|
||||
ret.addAll(output);
|
||||
boolean reversed = false;
|
||||
if (stack.peek() instanceof StrictEqAVM2Item) {
|
||||
reversed = true;
|
||||
}
|
||||
GraphTargetItem switchedObject = null;
|
||||
if (!output.isEmpty()) {
|
||||
if (output.get(output.size() - 1) instanceof SetLocalAVM2Item) {
|
||||
switchedObject = ((SetLocalAVM2Item) output.get(output.size() - 1)).value;
|
||||
}
|
||||
}
|
||||
if (switchedObject == null) {
|
||||
switchedObject = new NullAVM2Item(null);
|
||||
}
|
||||
HashMap<Integer, GraphTargetItem> caseValuesMap = new HashMap<>();
|
||||
|
||||
GraphTargetItem tar = stack.pop();
|
||||
if (tar instanceof StrictEqAVM2Item) {
|
||||
tar = ((StrictEqAVM2Item) tar).leftSide;
|
||||
}
|
||||
if (tar instanceof StrictNeqAVM2Item) {
|
||||
tar = ((StrictNeqAVM2Item) tar).leftSide;
|
||||
}
|
||||
caseValuesMap.put(this.avm2code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], tar);
|
||||
|
||||
GraphPart switchLoc = part.nextParts.get(reversed ? 0 : 1).nextParts.get(0);
|
||||
|
||||
while ((this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictNeIns)
|
||||
|| (this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictEqIns)) {
|
||||
part = part.nextParts.get(reversed ? 1 : 0);
|
||||
translatePart(localData, part, stack, staticOperation, null);
|
||||
tar = stack.pop();
|
||||
if (tar instanceof StrictEqAVM2Item) {
|
||||
tar = ((StrictEqAVM2Item) tar).leftSide;
|
||||
}
|
||||
if (tar instanceof StrictNeqAVM2Item) {
|
||||
tar = ((StrictNeqAVM2Item) tar).leftSide;
|
||||
}
|
||||
if (this.avm2code.code.get(part.end).definition instanceof IfStrictNeIns) {
|
||||
reversed = false;
|
||||
} else {
|
||||
reversed = true;
|
||||
}
|
||||
GraphPart numPart = part.nextParts.get(reversed ? 0 : 1);
|
||||
AVM2Instruction ins = null;
|
||||
TranslateStack sstack = new TranslateStack();
|
||||
do {
|
||||
for (int n = 0; n < numPart.getHeight(); n++) {
|
||||
ins = this.avm2code.code.get(numPart.getPosAt(n));
|
||||
if (ins.definition instanceof LookupSwitchIns) {
|
||||
break;
|
||||
}
|
||||
ins.translate(localData, sstack, new ArrayList<GraphTargetItem>(), staticOperation, path);
|
||||
}
|
||||
if (numPart.nextParts.size() > 1) {
|
||||
break;
|
||||
} else {
|
||||
numPart = numPart.nextParts.get(0);
|
||||
}
|
||||
} while (!(this.avm2code.code.get(numPart.end).definition instanceof LookupSwitchIns));
|
||||
GraphTargetItem nt = sstack.peek();
|
||||
|
||||
if (!(nt instanceof IntegerValueAVM2Item)) {
|
||||
throw new RuntimeException("Invalid integer value in Switch");
|
||||
}
|
||||
IntegerValueAVM2Item iv = (IntegerValueAVM2Item) nt;
|
||||
caseValuesMap.put((int) (long) iv.value, tar);
|
||||
while (this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).start).definition instanceof JumpIns) {
|
||||
reversed = false;
|
||||
part = part.nextParts.get(reversed ? 1 : 0);
|
||||
if (part instanceof GraphPartMulti) {
|
||||
part = ((GraphPartMulti) part).parts.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean hasDefault = false;
|
||||
GraphPart dp = part.nextParts.get(reversed ? 1 : 0);
|
||||
while (this.avm2code.code.get(dp.start).definition instanceof JumpIns) {
|
||||
if (dp instanceof GraphPartMulti) {
|
||||
dp = ((GraphPartMulti) dp).parts.get(0);
|
||||
}
|
||||
dp = dp.nextParts.get(0);
|
||||
}
|
||||
|
||||
GraphPart numPart = dp;
|
||||
AVM2Instruction ins = null;
|
||||
TranslateStack sstack = new TranslateStack();
|
||||
do {
|
||||
for (int n = 0; n < numPart.getHeight(); n++) {
|
||||
ins = this.avm2code.code.get(numPart.getPosAt(n));
|
||||
if (ins.definition instanceof LookupSwitchIns) {
|
||||
break;
|
||||
}
|
||||
ins.translate(localData, sstack, new ArrayList<GraphTargetItem>(), staticOperation, path);
|
||||
}
|
||||
if (numPart.nextParts.size() > 1) {
|
||||
break;
|
||||
} else {
|
||||
numPart = numPart.nextParts.get(0);
|
||||
}
|
||||
} while (!(this.avm2code.code.get(numPart.end).definition instanceof LookupSwitchIns));
|
||||
GraphTargetItem nt = sstack.peek();
|
||||
if (nt instanceof IntegerValueAVM2Item) {
|
||||
hasDefault = true;
|
||||
}
|
||||
List<GraphTargetItem> caseValues = new ArrayList<>();
|
||||
for (int i = 0; i < switchLoc.nextParts.size() - 1; i++) {
|
||||
if (caseValuesMap.containsKey(i)) {
|
||||
caseValues.add(caseValuesMap.get(i));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
List<List<GraphTargetItem>> caseCommands = new ArrayList<>();
|
||||
GraphPart next = null;
|
||||
|
||||
next = getMostCommonPart(localData, switchLoc.nextParts, loops);//getNextPartPath(loopContinues);
|
||||
currentLoop = new Loop(loops.size(), null, next);
|
||||
currentLoop.phase = 1;
|
||||
loops.add(currentLoop);
|
||||
//switchLoc.getNextPartPath(new ArrayList<GraphPart>());
|
||||
List<Integer> valuesMapping = new ArrayList<>();
|
||||
List<GraphPart> caseBodies = new ArrayList<>();
|
||||
for (int i = 0; i < caseValues.size(); i++) {
|
||||
GraphPart cur = switchLoc.nextParts.get(1 + i);
|
||||
if (!caseBodies.contains(cur)) {
|
||||
caseBodies.add(cur);
|
||||
}
|
||||
valuesMapping.add(caseBodies.indexOf(cur));
|
||||
}
|
||||
|
||||
List<GraphTargetItem> defaultCommands = new ArrayList<>();
|
||||
GraphPart defaultPart = null;
|
||||
if (hasDefault) {
|
||||
defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1);
|
||||
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
|
||||
stopPart2.add(next);
|
||||
defaultCommands = printGraph(localData, stack, allParts, switchLoc, defaultPart, stopPart2, loops, staticOperation, path);
|
||||
if (!defaultCommands.isEmpty()) {
|
||||
if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) {
|
||||
if (((BreakItem) defaultCommands.get(defaultCommands.size() - 1)).loopId == currentLoop.id) {
|
||||
defaultCommands.remove(defaultCommands.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<GraphPart> ignored = new ArrayList<>();
|
||||
for (Loop l : loops) {
|
||||
ignored.add(l.loopContinue);
|
||||
}
|
||||
|
||||
for (int i = 0; i < caseBodies.size(); i++) {
|
||||
List<GraphTargetItem> cc = new ArrayList<>();
|
||||
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
|
||||
for (int j = 0; j < caseBodies.size(); j++) {
|
||||
if (caseBodies.get(j) != caseBodies.get(i)) {
|
||||
stopPart2.add(caseBodies.get(j));
|
||||
}
|
||||
}
|
||||
if (hasDefault) {
|
||||
stopPart2.add(defaultPart);
|
||||
}
|
||||
|
||||
cc.addAll(0, printGraph(localData, stack, allParts, switchLoc, caseBodies.get(i), stopPart2, loops, staticOperation, path));
|
||||
caseCommands.add(cc);
|
||||
}
|
||||
|
||||
SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping);
|
||||
ret.add(sti);
|
||||
//loops.remove(currentLoop);
|
||||
if (next != null) {
|
||||
/*if (ti != null) {
|
||||
ret.add(ti);
|
||||
} else {*/
|
||||
currentLoop.phase = 2;
|
||||
ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path));
|
||||
//}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GraphPart checkPart(TranslateStack stack, BaseLocalData localData, GraphPart next, List<GraphPart> allParts) {
|
||||
AVM2LocalData aLocalData = (AVM2LocalData) localData;
|
||||
List<Integer> finallyJumps = aLocalData.finallyJumps;
|
||||
List<Integer> ignoredSwitches = aLocalData.ignoredSwitches;
|
||||
GraphPart ret = next;
|
||||
for (int f = 0; f < finallyJumps.size(); f++) {
|
||||
int fip = finallyJumps.get(f);
|
||||
int swip = ignoredSwitches.get(f);
|
||||
if (next.start == fip) {
|
||||
if (stack != null && swip != -1) {
|
||||
AVM2Instruction swIns = avm2code.code.get(swip);
|
||||
GraphTargetItem t = stack.pop();
|
||||
Double dval = EcmaScript.toNumber(t.getResult());
|
||||
int val = (int) (double) dval;
|
||||
if (swIns.definition instanceof LookupSwitchIns) {
|
||||
List<Integer> branches = swIns.getBranches(code);
|
||||
int nip = branches.get(0);
|
||||
if (val >= 0 && val < branches.size() - 1) {
|
||||
nip = branches.get(1 + val);
|
||||
}
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.start == nip) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
ret = null;
|
||||
}
|
||||
}
|
||||
ret = null;
|
||||
}
|
||||
}
|
||||
if (ret != next) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pos = next.start;
|
||||
int addr = this.avm2code.fixAddrAfterDebugLine(avm2code.pos2adr(pos));
|
||||
for (int e = 0; e < body.exceptions.length; e++) {
|
||||
if (body.exceptions[e].isFinally()) {
|
||||
if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) {
|
||||
if (true) { //afterCatchPos + 1 == code.adr2pos(this.code.fixAddrAfterDebugLine(body.exceptions[e].end))) {
|
||||
AVM2Instruction jmpIns = this.avm2code.code.get(avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end)));
|
||||
if (jmpIns.definition instanceof JumpIns) {
|
||||
int finStart = avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]);
|
||||
finallyJumps.add(finStart);
|
||||
ignoredSwitches.add(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GraphTargetItem checkLoop(LoopItem loopItem, BaseLocalData localData, List<Loop> loops) {
|
||||
AVM2LocalData aLocalData = (AVM2LocalData) localData;
|
||||
if (loopItem instanceof WhileItem) {
|
||||
WhileItem w = (WhileItem) loopItem;
|
||||
|
||||
if ((!w.expression.isEmpty()) && (w.expression.get(w.expression.size() - 1) instanceof HasNextAVM2Item)) {
|
||||
if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection != null) {
|
||||
if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection.getNotCoerced().getThroughRegister() instanceof FilteredCheckAVM2Item) {
|
||||
//GraphTargetItem gti = ((HasNextAVM2Item) ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1))).collection.getNotCoerced().getThroughRegister();
|
||||
if (w.commands.size() >= 3) { //((w.commands.size() == 3) || (w.commands.size() == 4)) {
|
||||
int pos = 0;
|
||||
while (w.commands.get(pos) instanceof SetLocalAVM2Item) {
|
||||
pos++;
|
||||
}
|
||||
GraphTargetItem ft = w.commands.get(pos);
|
||||
if (ft instanceof WithAVM2Item) {
|
||||
ft = w.commands.get(pos + 1);
|
||||
if (ft instanceof IfItem) {
|
||||
IfItem ift = (IfItem) ft;
|
||||
if (ift.onTrue.size() > 0) {
|
||||
ft = ift.onTrue.get(0);
|
||||
if (ft instanceof SetPropertyAVM2Item) {
|
||||
SetPropertyAVM2Item spt = (SetPropertyAVM2Item) ft;
|
||||
if (spt.object instanceof LocalRegAVM2Item) {
|
||||
int regIndex = ((LocalRegAVM2Item) spt.object).regIndex;
|
||||
HasNextAVM2Item iti = (HasNextAVM2Item) w.expression.get(w.expression.size() - 1);
|
||||
HashMap<Integer, GraphTargetItem> localRegs = aLocalData.localRegs;
|
||||
localRegs.put(regIndex, new FilterAVM2Item(null, iti.collection.getThroughRegister(), ift.expression));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!w.commands.isEmpty()) {
|
||||
if (w.commands.get(0) instanceof SetTypeAVM2Item) {
|
||||
SetTypeAVM2Item sti = (SetTypeAVM2Item) w.commands.remove(0);
|
||||
GraphTargetItem gti = sti.getValue().getNotCoerced();
|
||||
if (gti instanceof NextValueAVM2Item) {
|
||||
return new ForEachInAVM2Item(w.src, w.loop, new InAVM2Item(null, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands);
|
||||
} else if (gti instanceof NextNameAVM2Item) {
|
||||
return new ForInAVM2Item(w.src, w.loop, new InAVM2Item(null, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return loopItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData) {
|
||||
if (level == 0) {
|
||||
if (!list.isEmpty()) {
|
||||
if (list.get(list.size() - 1) instanceof ReturnVoidAVM2Item) {
|
||||
list.remove(list.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*for (int i = 0; i < list.size(); i++) {
|
||||
|
||||
if (list.get(i) instanceof WhileItem) {
|
||||
WhileItem w = (WhileItem) list.get(i);
|
||||
|
||||
}
|
||||
}*/
|
||||
List<GraphTargetItem> ret = avm2code.clearTemporaryRegisters(list);
|
||||
if (ret != list) {
|
||||
list.clear();
|
||||
list.addAll(ret);
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i) instanceof SetTypeAVM2Item) {
|
||||
if (((SetTypeAVM2Item) list.get(i)).getValue() instanceof ExceptionAVM2Item) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (list.get(i) instanceof IfItem) {
|
||||
IfItem ifi = (IfItem) list.get(i);
|
||||
if (((ifi.expression instanceof HasNextAVM2Item)
|
||||
|| ((ifi.expression instanceof NotItem)
|
||||
&& (((NotItem) ifi.expression).getOriginal() instanceof HasNextAVM2Item)))) {
|
||||
HasNextAVM2Item hnt = null;
|
||||
List<GraphTargetItem> body = new ArrayList<>();
|
||||
List<GraphTargetItem> nextbody = new ArrayList<>();
|
||||
if (ifi.expression instanceof NotItem) {
|
||||
hnt = (HasNextAVM2Item) ((NotItem) ifi.expression).getOriginal();
|
||||
body.addAll(ifi.onFalse);
|
||||
for (int j = i + 1; j < list.size();) {
|
||||
body.add(list.remove(i + 1));
|
||||
}
|
||||
nextbody = ifi.onTrue;
|
||||
} else {
|
||||
hnt = (HasNextAVM2Item) ifi.expression;
|
||||
body = ifi.onTrue;
|
||||
nextbody = ifi.onFalse;
|
||||
}
|
||||
if (!body.isEmpty()) {
|
||||
if (body.get(0) instanceof SetTypeAVM2Item) {
|
||||
SetTypeAVM2Item sti = (SetTypeAVM2Item) body.remove(0);
|
||||
GraphTargetItem gti = sti.getValue().getNotCoerced();
|
||||
GraphTargetItem repl = null;
|
||||
|
||||
if (gti instanceof NextValueAVM2Item) {
|
||||
repl = new ForEachInAVM2Item(ifi.src, new Loop(0, null, null), new InAVM2Item(null, sti.getObject(), hnt.collection), body);
|
||||
} else if (gti instanceof NextNameAVM2Item) {
|
||||
repl = new ForInAVM2Item(ifi.src, new Loop(0, null, null), new InAVM2Item(null, sti.getObject(), hnt.collection), body);
|
||||
}
|
||||
if (repl != null) {
|
||||
list.remove(i);
|
||||
list.add(i, repl);
|
||||
list.addAll(i + 1, nextbody);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEmpty(List<GraphTargetItem> output) {
|
||||
if (super.isEmpty(output)) {
|
||||
return true;
|
||||
}
|
||||
for (GraphTargetItem i : output) {
|
||||
if (i instanceof SetLocalAVM2Item) {
|
||||
if (avm2code.isKilled(((SetLocalAVM2Item) i).regIndex, 0, avm2code.code.size() - 1)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AVM2LocalData prepareBranchLocalData(BaseLocalData localData) {
|
||||
AVM2LocalData aLocalData = (AVM2LocalData) localData;
|
||||
AVM2LocalData ret = new AVM2LocalData(aLocalData);
|
||||
ScopeStack copyScopeStack = new ScopeStack();
|
||||
copyScopeStack.addAll(ret.scopeStack);
|
||||
ret.scopeStack = copyScopeStack;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.graph;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConvertOutput;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSource;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AVM2GraphSource extends GraphSource {
|
||||
|
||||
private final AVM2Code code;
|
||||
boolean isStatic;
|
||||
int classIndex;
|
||||
int scriptIndex;
|
||||
HashMap<Integer, GraphTargetItem> localRegs;
|
||||
ScopeStack scopeStack;
|
||||
ABC abc;
|
||||
MethodBody body;
|
||||
HashMap<Integer, String> localRegNames;
|
||||
List<String> fullyQualifiedNames;
|
||||
HashMap<Integer, Integer> localRegAssigmentIps;
|
||||
HashMap<Integer, List<Integer>> refs;
|
||||
|
||||
public AVM2Code getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public AVM2GraphSource(AVM2Code code, boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, ScopeStack scopeStack, ABC abc, MethodBody body, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, HashMap<Integer, Integer> localRegAssigmentIp, HashMap<Integer, List<Integer>> refs) {
|
||||
this.code = code;
|
||||
this.isStatic = isStatic;
|
||||
this.classIndex = classIndex;
|
||||
this.localRegs = localRegs;
|
||||
this.scopeStack = scopeStack;
|
||||
this.abc = abc;
|
||||
this.body = body;
|
||||
this.localRegNames = localRegNames;
|
||||
this.fullyQualifiedNames = fullyQualifiedNames;
|
||||
this.scriptIndex = scriptIndex;
|
||||
this.localRegAssigmentIps = localRegAssigmentIp;
|
||||
this.refs = refs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return code.code.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AVM2Instruction get(int pos) {
|
||||
return code.code.get(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return code.code.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ScopeStack newstack = ((AVM2LocalData) localData).scopeStack;
|
||||
ConvertOutput co = code.toSourceOutput(path, part, false, isStatic, scriptIndex, classIndex, localRegs, stack, newstack, abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()], localRegAssigmentIps, refs);
|
||||
ret.addAll(co.output);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int adr2pos(long adr) {
|
||||
return code.adr2pos(adr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long pos2adr(int pos) {
|
||||
return code.pos2adr(pos);
|
||||
}
|
||||
}
|
||||
+363
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.ABCOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.LookupSwitchIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSource;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AVM2Instruction implements Serializable, GraphSourceItem {
|
||||
|
||||
public static final long serialVersionUID = 1L;
|
||||
public InstructionDefinition definition;
|
||||
public int[] operands;
|
||||
public long offset;
|
||||
public byte[] bytes;
|
||||
public String comment;
|
||||
public boolean ignored = false;
|
||||
public String labelname;
|
||||
public long mappedOffset = -1;
|
||||
public int changeJumpTo = -1;
|
||||
|
||||
public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte[] bytes) {
|
||||
this.definition = definition;
|
||||
this.operands = operands;
|
||||
this.offset = offset;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ABCOutputStream aos = new ABCOutputStream(bos);
|
||||
aos.write(definition.instructionCode);
|
||||
for (int i = 0; i < definition.operands.length; i++) {
|
||||
int opt = definition.operands[i] & 0xff00;
|
||||
switch (opt) {
|
||||
case AVM2Code.OPT_S24:
|
||||
aos.writeS24(operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_U30:
|
||||
aos.writeU30(operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_U8:
|
||||
aos.writeU8(operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_BYTE:
|
||||
aos.writeU8(0xff & operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_CASE_OFFSETS:
|
||||
|
||||
aos.writeU30(operands[i]); //case count
|
||||
for (int j = i + 1; j < operands.length; j++) {
|
||||
aos.writeS24(operands[j]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
//ignored
|
||||
}
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(definition.instructionName);
|
||||
for (int i = 0; i < operands.length; i++) {
|
||||
s.append(" ");
|
||||
s.append(operands[i]);
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public List<Long> getOffsets() {
|
||||
List<Long> ret = new ArrayList<>();
|
||||
String s = "";
|
||||
for (int i = 0; i < definition.operands.length; i++) {
|
||||
switch (definition.operands[i]) {
|
||||
case AVM2Code.DAT_OFFSET:
|
||||
ret.add(offset + operands[i] + getBytes().length);
|
||||
break;
|
||||
case AVM2Code.DAT_CASE_BASEOFFSET:
|
||||
ret.add(offset + operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_CASE_OFFSETS:
|
||||
for (int j = i + 1; j < operands.length; j++) {
|
||||
ret.add(offset + operands[j]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Object> getParamsAsList(ConstantPool constants) {
|
||||
List<Object> s = new ArrayList<>();
|
||||
for (int i = 0; i < definition.operands.length; i++) {
|
||||
switch (definition.operands[i]) {
|
||||
case AVM2Code.DAT_MULTINAME_INDEX:
|
||||
s.add(constants.getMultiname(operands[i]));
|
||||
break;
|
||||
case AVM2Code.DAT_STRING_INDEX:
|
||||
s.add(constants.getString(operands[i]));
|
||||
break;
|
||||
case AVM2Code.DAT_INT_INDEX:
|
||||
s.add(Long.valueOf(constants.getInt(operands[i])));
|
||||
break;
|
||||
case AVM2Code.DAT_UINT_INDEX:
|
||||
s.add(new Long(constants.getUInt(operands[i])));
|
||||
break;
|
||||
case AVM2Code.DAT_DOUBLE_INDEX:
|
||||
s.add(Double.valueOf(constants.getDouble(operands[i])));
|
||||
break;
|
||||
case AVM2Code.DAT_OFFSET:
|
||||
s.add(new Long(offset + operands[i] + getBytes().length));
|
||||
break;
|
||||
case AVM2Code.DAT_CASE_BASEOFFSET:
|
||||
s.add(new Long(offset + operands[i]));
|
||||
break;
|
||||
case AVM2Code.OPT_CASE_OFFSETS:
|
||||
s.add(new Long(operands[i]));
|
||||
for (int j = i + 1; j < operands.length; j++) {
|
||||
s.add(new Long(offset + operands[j]));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
s.add(new Long(operands[i]));
|
||||
}
|
||||
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getParams(ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0; i < definition.operands.length; i++) {
|
||||
switch (definition.operands[i]) {
|
||||
case AVM2Code.DAT_MULTINAME_INDEX:
|
||||
if (operands[i] == 0) {
|
||||
s.append(" null");
|
||||
} else {
|
||||
s.append(" ");
|
||||
s.append(constants.getMultiname(operands[i]).toString(constants, fullyQualifiedNames));
|
||||
}
|
||||
/*s.append(" m[");
|
||||
s.append(operands[i]);
|
||||
s.append("]\"");
|
||||
if (constants.constant_multiname[operands[i]] == null) {
|
||||
s.append("");
|
||||
} else {
|
||||
s.append(Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants, fullyQualifiedNames)));
|
||||
}
|
||||
s.append("\"");*/
|
||||
break;
|
||||
case AVM2Code.DAT_STRING_INDEX:
|
||||
if (operands[i] == 0) {
|
||||
s.append(" null");
|
||||
} else {
|
||||
s.append(" \"");
|
||||
s.append(Helper.escapeString(constants.getString(operands[i])));
|
||||
s.append("\"");
|
||||
}
|
||||
break;
|
||||
case AVM2Code.DAT_INT_INDEX:
|
||||
if (operands[i] == 0) {
|
||||
s.append(" null");
|
||||
} else {
|
||||
s.append(" ");
|
||||
s.append(constants.getInt(operands[i]));
|
||||
}
|
||||
break;
|
||||
case AVM2Code.DAT_UINT_INDEX:
|
||||
if (operands[i] == 0) {
|
||||
s.append(" null");
|
||||
} else {
|
||||
s.append(" ");
|
||||
s.append(constants.getUInt(operands[i]));
|
||||
}
|
||||
break;
|
||||
case AVM2Code.DAT_DOUBLE_INDEX:
|
||||
if (operands[i] == 0) {
|
||||
s.append(" null");
|
||||
} else {
|
||||
s.append(" ");
|
||||
s.append(constants.getDouble(operands[i]));
|
||||
}
|
||||
break;
|
||||
case AVM2Code.DAT_OFFSET:
|
||||
s.append(" ");
|
||||
s.append("ofs");
|
||||
s.append(Helper.formatAddress(offset + operands[i] + getBytes().length));
|
||||
break;
|
||||
case AVM2Code.DAT_CASE_BASEOFFSET:
|
||||
s.append(" ");
|
||||
s.append("ofs");
|
||||
s.append(Helper.formatAddress(offset + operands[i]));
|
||||
break;
|
||||
case AVM2Code.OPT_CASE_OFFSETS:
|
||||
s.append(" ");
|
||||
s.append(operands[i]);
|
||||
for (int j = i + 1; j < operands.length; j++) {
|
||||
s.append(" ");
|
||||
s.append("ofs");
|
||||
s.append(Helper.formatAddress(offset + operands[j]));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
s.append(" ");
|
||||
s.append(operands[i]);
|
||||
}
|
||||
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
if (ignored) {
|
||||
return " ;ignored";
|
||||
}
|
||||
if ((comment == null) || comment.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return " ;" + comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnored() {
|
||||
return ignored;
|
||||
}
|
||||
|
||||
public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) {
|
||||
writer.appendNoHilight(Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName);
|
||||
writer.appendNoHilight(getParams(localData.constantsAvm2, localData.fullyQualifiedNames) + getComment());
|
||||
return writer;
|
||||
}
|
||||
|
||||
public String toStringNoAddress(ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
String s = definition.instructionName;
|
||||
s += getParams(constants, fullyQualifiedNames) + getComment();
|
||||
return s;
|
||||
}
|
||||
public List<Object> replaceWith;
|
||||
|
||||
@Override
|
||||
public void translate(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, int staticOperation, String path) throws InterruptedException {
|
||||
AVM2LocalData aLocalData = (AVM2LocalData) localData;
|
||||
definition.translate(aLocalData.isStatic,
|
||||
aLocalData.scriptIndex,
|
||||
aLocalData.classIndex,
|
||||
aLocalData.localRegs,
|
||||
stack,
|
||||
aLocalData.scopeStack,
|
||||
aLocalData.constants, this, aLocalData.methodInfo, output, aLocalData.methodBody, aLocalData.abc, aLocalData.localRegNames, aLocalData.fullyQualifiedNames, null, aLocalData.localRegAssignmentIps, aLocalData.ip, aLocalData.refs, aLocalData.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJump() {
|
||||
return (definition instanceof JumpIns) || (fixedBranch > -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBranch() {
|
||||
if (fixedBranch > -1) {
|
||||
return false;
|
||||
}
|
||||
return (definition instanceof IfTypeIns) || (definition instanceof LookupSwitchIns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExit() {
|
||||
return (definition instanceof ReturnValueIns) || (definition instanceof ReturnVoidIns) || (definition instanceof ThrowIns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getOffset() {
|
||||
return mappedOffset > -1 ? mappedOffset : offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBranches(GraphSource code) {
|
||||
List<Integer> ret = new ArrayList<>();
|
||||
if (definition instanceof IfTypeIns) {
|
||||
|
||||
if (fixedBranch == -1 || fixedBranch == 0) {
|
||||
ret.add(code.adr2pos(offset + getBytes().length + operands[0]));
|
||||
}
|
||||
if (!(definition instanceof JumpIns)) {
|
||||
if (fixedBranch == -1 || fixedBranch == 1) {
|
||||
ret.add(code.adr2pos(offset + getBytes().length));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (definition instanceof LookupSwitchIns) {
|
||||
if (fixedBranch == -1 || fixedBranch == 0) {
|
||||
ret.add(code.adr2pos(offset + operands[0]));
|
||||
}
|
||||
for (int k = 2; k < operands.length; k++) {
|
||||
if (fixedBranch == -1 || fixedBranch == k - 1) {
|
||||
ret.add(code.adr2pos(offset + operands[k]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoredLoops() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnored(boolean ignored, int pos) {
|
||||
this.ignored = ignored;
|
||||
}
|
||||
|
||||
public void setFixBranch(int pos) {
|
||||
this.fixedBranch = pos;
|
||||
}
|
||||
private int fixedBranch = -1;
|
||||
|
||||
public int getFixBranch() {
|
||||
return fixedBranch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeobfuscatePop() {
|
||||
return definition instanceof DeobfuscatePopIns;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DeobfuscatePopIns extends PopIns {
|
||||
|
||||
public DeobfuscatePopIns() {
|
||||
instructionName = "ffdec_deobfuscatepop";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface IfTypeIns {
|
||||
|
||||
public abstract void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins);
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
public class InstructionDefinition implements Serializable {
|
||||
|
||||
public static final long serialVersionUID = 1L;
|
||||
|
||||
public int[] operands;
|
||||
public String instructionName = "";
|
||||
public int instructionCode = 0;
|
||||
|
||||
public InstructionDefinition(int instructionCode, String instructionName, int[] operands) {
|
||||
this.instructionCode = instructionCode;
|
||||
this.instructionName = instructionName;
|
||||
this.operands = operands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(instructionName);
|
||||
for (int i = 0; i < operands.length; i++) {
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) {
|
||||
s.append(" U30");
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) {
|
||||
s.append(" U8");
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) {
|
||||
s.append(" BYTE");
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) {
|
||||
s.append(" S24");
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) {
|
||||
s.append(" U30 S24,[S24]...");
|
||||
}
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented");
|
||||
}
|
||||
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) throws InterruptedException {
|
||||
}
|
||||
|
||||
protected FullMultinameAVM2Item resolveMultiname(TranslateStack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) {
|
||||
GraphTargetItem ns = null;
|
||||
GraphTargetItem name = null;
|
||||
if (constants.getMultiname(multinameIndex).needsName()) {
|
||||
name = stack.pop();
|
||||
}
|
||||
if (constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ns = stack.pop();
|
||||
}
|
||||
return new FullMultinameAVM2Item(ins, multinameIndex, name, ns);
|
||||
}
|
||||
|
||||
protected int resolvedCount(ConstantPool constants, int multinameIndex) {
|
||||
int pos = 0;
|
||||
if (constants.getMultiname(multinameIndex).needsNs()) {
|
||||
pos++;
|
||||
}
|
||||
if (constants.getMultiname(multinameIndex).needsName()) {
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
|
||||
}
|
||||
|
||||
protected String resolveMultinameNoPop(int pos, Stack<AVM2Item> stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins, List<String> fullyQualifiedNames) {
|
||||
String ns = "";
|
||||
String name;
|
||||
if (constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ns = "[" + stack.get(pos) + "]";
|
||||
pos++;
|
||||
}
|
||||
if (constants.getMultiname(multinameIndex).needsName()) {
|
||||
name = stack.get(pos).toString();
|
||||
} else {
|
||||
name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames), ins.offset);
|
||||
}
|
||||
return name + ns;
|
||||
}
|
||||
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected boolean isRegisterCompileTime(int regId, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
Set<Integer> previous = new HashSet<>();
|
||||
AVM2Code.getPreviousReachableIps(ip, refs, previous, new HashSet<Integer>());
|
||||
for (int p : previous) {
|
||||
if (p < 0) {
|
||||
continue;
|
||||
}
|
||||
if (p >= code.code.size()) {
|
||||
continue;
|
||||
}
|
||||
AVM2Instruction sins = code.code.get(p);
|
||||
if (code.code.get(p).definition instanceof SetLocalTypeIns) {
|
||||
SetLocalTypeIns sl = (SetLocalTypeIns) sins.definition;
|
||||
if (sl.getRegisterId(sins) == regId) {
|
||||
if (!AVM2Code.isDirectAncestor(ip, p, refs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((code.code.get(p).definition instanceof IncLocalIns)
|
||||
|| (code.code.get(p).definition instanceof IncLocalIIns)
|
||||
|| (code.code.get(p).definition instanceof DecLocalIns)
|
||||
|| (code.code.get(p).definition instanceof DecLocalIIns)) {
|
||||
if (sins.operands[0] == regId) {
|
||||
if (!AVM2Code.isDirectAncestor(ip, p, refs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public interface SetTypeIns {
|
||||
|
||||
public abstract String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) throws InterruptedException;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TagInstruction extends InstructionDefinition {
|
||||
|
||||
public static final long serialVersionUID = 1L;
|
||||
|
||||
public TagInstruction(String tagName) {
|
||||
super(-1, tagName, new int[0]);
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Lf32Ins extends InstructionDefinition {
|
||||
|
||||
public Lf32Ins() {
|
||||
super(0x38, "lf32", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Lf64Ins extends InstructionDefinition {
|
||||
|
||||
public Lf64Ins() {
|
||||
super(0x39, "lf64", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Li16Ins extends InstructionDefinition {
|
||||
|
||||
public Li16Ins() {
|
||||
super(0x36, "li16", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Li32Ins extends InstructionDefinition {
|
||||
|
||||
public Li32Ins() {
|
||||
super(0x37, "li32", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Li8Ins extends InstructionDefinition {
|
||||
|
||||
public Li8Ins() {
|
||||
super(0x35, "li8", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Sf32Ins extends InstructionDefinition {
|
||||
|
||||
public Sf32Ins() {
|
||||
super(0x3D, "sf32", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Sf64Ins extends InstructionDefinition {
|
||||
|
||||
public Sf64Ins() {
|
||||
super(0x3E, "sf64", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Si16Ins extends InstructionDefinition {
|
||||
|
||||
public Si16Ins() {
|
||||
super(0x3B, "si16", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Si32Ins extends InstructionDefinition {
|
||||
|
||||
public Si32Ins() {
|
||||
super(0x3C, "si32", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Si8Ins extends InstructionDefinition {
|
||||
|
||||
public Si8Ins() {
|
||||
super(0x3A, "si8", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem ofs = stack.pop();
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Sxi16Ins extends InstructionDefinition {
|
||||
|
||||
public Sxi16Ins() {
|
||||
super(0x52, "sxi_16", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Sxi1Ins extends InstructionDefinition {
|
||||
|
||||
public Sxi1Ins() {
|
||||
super(0x50, "sxi_1", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Sxi8Ins extends InstructionDefinition {
|
||||
|
||||
public Sxi8Ins() {
|
||||
super(0x51, "sxi_8", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1 - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName));
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class AddIIns extends AddIns {
|
||||
|
||||
public AddIIns() {
|
||||
instructionName = "add_i";
|
||||
instructionCode = 0xc5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new AddAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class AddIns extends InstructionDefinition {
|
||||
|
||||
public AddIns() {
|
||||
super(0xa0, "add", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Object o1 = lda.operandStack.pop();
|
||||
Object o2 = lda.operandStack.pop();
|
||||
if ((o1 instanceof Long) && ((o2 instanceof Long))) {
|
||||
Long ret = Long.valueOf(((Long) o1).longValue() + ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Double))) {
|
||||
Double ret = Double.valueOf(((Double) o1).doubleValue() + ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Long) && ((o2 instanceof Double))) {
|
||||
Double ret = new Double(((Long) o1).longValue() + ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Long))) {
|
||||
Double ret = new Double(((Double) o1).doubleValue() + ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else {
|
||||
String s = o1.toString() + o2.toString();
|
||||
lda.operandStack.push(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new AddAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DecrementIIns extends InstructionDefinition {
|
||||
|
||||
public DecrementIIns() {
|
||||
super(0xc1, "decrement_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Object obj = lda.operandStack.pop();
|
||||
if (obj instanceof Long) {
|
||||
Long obj2 = ((Long) obj).longValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else if (obj instanceof Double) {
|
||||
Double obj2 = ((Double) obj).doubleValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
Double obj2 = Double.parseDouble((String) obj) - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot decrement local register");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
stack.push(new DecrementAVM2Item(ins, stack.pop()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DecrementIns extends InstructionDefinition {
|
||||
|
||||
public DecrementIns() {
|
||||
super(0x93, "decrement", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Object obj = lda.operandStack.pop();
|
||||
if (obj instanceof Long) {
|
||||
Long obj2 = ((Long) obj).longValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else if (obj instanceof Double) {
|
||||
Double obj2 = ((Double) obj).doubleValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
Double obj2 = Double.parseDouble((String) obj) - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot decrement local register");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
stack.push(new DecrementAVM2Item(ins, stack.pop()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.DivideAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DivideIns extends InstructionDefinition {
|
||||
|
||||
public DivideIns() {
|
||||
super(0xa3, "divide", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Object o2 = lda.operandStack.pop();
|
||||
Object o1 = lda.operandStack.pop();
|
||||
if ((o1 instanceof Long) && ((o2 instanceof Long))) {
|
||||
Long ret = Long.valueOf(((Long) o1).longValue() / ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Double))) {
|
||||
Double ret = Double.valueOf(((Double) o1).doubleValue() / ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Long) && ((o2 instanceof Double))) {
|
||||
Double ret = new Double(((Long) o1).longValue() / ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Long))) {
|
||||
Double ret = new Double(((Double) o1).doubleValue() / ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot divide");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new DivideAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IncrementIIns extends InstructionDefinition {
|
||||
|
||||
public IncrementIIns() {
|
||||
super(0xc0, "increment_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
stack.push(new IncrementAVM2Item(ins, stack.pop()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IncrementIns extends InstructionDefinition {
|
||||
|
||||
public IncrementIns() {
|
||||
super(0x91, "increment", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
stack.push(new IncrementAVM2Item(ins, stack.pop()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.ModuloAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ModuloIns extends InstructionDefinition {
|
||||
|
||||
public ModuloIns() {
|
||||
super(0xa4, "modulo", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Object o1 = lda.operandStack.pop();
|
||||
Object o2 = lda.operandStack.pop();
|
||||
|
||||
if ((o1 instanceof Long) && ((o2 instanceof Long))) {
|
||||
Long ret = Long.valueOf(((Long) o2).longValue() % ((Long) o1).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot modulo");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new ModuloAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.MultiplyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class MultiplyIIns extends InstructionDefinition {
|
||||
|
||||
public MultiplyIIns() {
|
||||
super(0xc7, "multiply_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new MultiplyAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.MultiplyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class MultiplyIns extends InstructionDefinition {
|
||||
|
||||
public MultiplyIns() {
|
||||
super(0xa2, "multiply", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Object o1 = lda.operandStack.pop();
|
||||
Object o2 = lda.operandStack.pop();
|
||||
if ((o1 instanceof Long) && ((o2 instanceof Long))) {
|
||||
Long ret = Long.valueOf(((Long) o1).longValue() * ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Double))) {
|
||||
Double ret = Double.valueOf(((Double) o1).doubleValue() * ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Long) && ((o2 instanceof Double))) {
|
||||
Double ret = new Double(((Long) o1).longValue() * ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Long))) {
|
||||
Double ret = new Double(((Double) o1).doubleValue() * ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot multiply");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new MultiplyAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NegateIIns extends InstructionDefinition {
|
||||
|
||||
public NegateIIns() {
|
||||
super(0xc4, "negate_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v = stack.pop();
|
||||
stack.push(new NegAVM2Item(ins, v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NegateIns extends InstructionDefinition {
|
||||
|
||||
public NegateIns() {
|
||||
super(0x90, "negate", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v = stack.pop();
|
||||
stack.push(new NegAVM2Item(ins, v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.NotItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NotIns extends InstructionDefinition {
|
||||
|
||||
public NotIns() {
|
||||
super(0x96, "not", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v = stack.pop();
|
||||
stack.push(new NotItem(ins, v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class SubtractIIns extends InstructionDefinition {
|
||||
|
||||
public SubtractIIns() {
|
||||
super(0xc6, "subtract_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new SubtractAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class SubtractIns extends InstructionDefinition {
|
||||
|
||||
public SubtractIns() {
|
||||
super(0xa1, "subtract", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new SubtractAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitAndAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BitAndIns extends InstructionDefinition {
|
||||
|
||||
public BitAndIns() {
|
||||
super(0xa8, "bitand", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Long value2 = (Long) lda.operandStack.pop();
|
||||
Long value1 = (Long) lda.operandStack.pop();
|
||||
Long value3 = value1 & value2;
|
||||
lda.operandStack.push(value3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new BitAndAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitNotAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BitNotIns extends InstructionDefinition {
|
||||
|
||||
public BitNotIns() {
|
||||
super(0x97, "bitnot", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Long value = (Long) lda.operandStack.pop();
|
||||
Long ret = Long.valueOf(-value.longValue());
|
||||
lda.operandStack.push(ret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v = stack.pop();
|
||||
stack.push(new BitNotAVM2Item(ins, v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitOrAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BitOrIns extends InstructionDefinition {
|
||||
|
||||
public BitOrIns() {
|
||||
super(0xa9, "bitor", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Long value2 = (Long) lda.operandStack.pop();
|
||||
Long value1 = (Long) lda.operandStack.pop();
|
||||
Long value3 = value1 | value2;
|
||||
lda.operandStack.push(value3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new BitOrAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitXorAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BitXorIns extends InstructionDefinition {
|
||||
|
||||
public BitXorIns() {
|
||||
super(0xaa, "bitxor", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Long value2 = (Long) lda.operandStack.pop();
|
||||
Long value1 = (Long) lda.operandStack.pop();
|
||||
Long value3 = value1 ^ value2;
|
||||
lda.operandStack.push(value3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new BitXorAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LShiftAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class LShiftIns extends InstructionDefinition {
|
||||
|
||||
public LShiftIns() {
|
||||
super(0xa5, "lshift", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LShiftAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.RShiftAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class RShiftIns extends InstructionDefinition {
|
||||
|
||||
public RShiftIns() {
|
||||
super(0xa6, "rshift", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new RShiftAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.URShiftAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class URShiftIns extends InstructionDefinition {
|
||||
|
||||
public URShiftIns() {
|
||||
super(0xa7, "urshift", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new URShiftAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class EqualsIns extends InstructionDefinition {
|
||||
|
||||
public EqualsIns() {
|
||||
super(0xab, "equals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
Object obj1 = lda.operandStack.pop();
|
||||
Object obj2 = lda.operandStack.pop();
|
||||
Boolean res = obj1.equals(obj2);
|
||||
lda.operandStack.push(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new EqAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class GreaterEqualsIns extends InstructionDefinition {
|
||||
|
||||
public GreaterEqualsIns() {
|
||||
super(0xb0, "greaterequals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class GreaterThanIns extends InstructionDefinition {
|
||||
|
||||
public GreaterThanIns() {
|
||||
super(0xaf, "greaterthan", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class LessEqualsIns extends InstructionDefinition {
|
||||
|
||||
public LessEqualsIns() {
|
||||
super(0xae, "lessequals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class LessThanIns extends InstructionDefinition {
|
||||
|
||||
public LessThanIns() {
|
||||
super(0xad, "lessthan", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class StrictEqualsIns extends InstructionDefinition {
|
||||
|
||||
public StrictEqualsIns() {
|
||||
super(0xac, "strictequals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new StrictEqAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1;
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConstructAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXAttrAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXElemAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstructIns extends InstructionDefinition {
|
||||
|
||||
public ConstructIns() {
|
||||
super(0x42, "construct", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int argCount = (int) ((Long) arguments.get(0)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object obj = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Cannot call constructor");
|
||||
//call construct property of obj
|
||||
//push new instance
|
||||
}
|
||||
|
||||
public static boolean walkXML(GraphTargetItem item, List<GraphTargetItem> list) {
|
||||
boolean ret = true;
|
||||
if (item instanceof StringAVM2Item) {
|
||||
list.add(item);
|
||||
} else if (item instanceof AddAVM2Item) {
|
||||
ret = ret && walkXML(((AddAVM2Item) item).leftSide, list);
|
||||
ret = ret && walkXML(((AddAVM2Item) item).rightSide, list);
|
||||
} else if ((item instanceof EscapeXElemAVM2Item) || (item instanceof EscapeXAttrAVM2Item)) {
|
||||
list.add(item);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) throws InterruptedException {
|
||||
int argCount = ins.operands[0];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
GraphTargetItem obj = stack.pop();
|
||||
|
||||
FullMultinameAVM2Item xmlMult = null;
|
||||
boolean isXML = false;
|
||||
if (obj instanceof GetPropertyAVM2Item) {
|
||||
GetPropertyAVM2Item gpt = (GetPropertyAVM2Item) obj;
|
||||
if (gpt.object instanceof FindPropertyAVM2Item) {
|
||||
FindPropertyAVM2Item fpt = (FindPropertyAVM2Item) gpt.object;
|
||||
xmlMult = (FullMultinameAVM2Item) fpt.propertyName;
|
||||
isXML = xmlMult.isXML(constants, localRegNames, fullyQualifiedNames) && xmlMult.isXML(constants, localRegNames, fullyQualifiedNames);
|
||||
}
|
||||
}
|
||||
if (obj instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item glt = (GetLexAVM2Item) obj;
|
||||
isXML = glt.propertyName.getName(constants, fullyQualifiedNames).equals("XML");
|
||||
}
|
||||
|
||||
if (isXML) {
|
||||
if (args.size() == 1) {
|
||||
GraphTargetItem arg = args.get(0);
|
||||
List<GraphTargetItem> xmlLines = new ArrayList<>();
|
||||
if (walkXML(arg, xmlLines)) {
|
||||
stack.push(new XMLAVM2Item(ins, xmlLines));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stack.push(new ConstructAVM2Item(ins, obj, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -ins.operands[0] - 1 + 1;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConstructPropAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstructPropIns extends InstructionDefinition {
|
||||
|
||||
public ConstructPropIns() {
|
||||
super(0x4a, "constructprop", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}*/
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
throw new RuntimeException("Cannot construct property");
|
||||
//create property
|
||||
//push new instance
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) throws InterruptedException {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
GraphTargetItem obj = stack.pop();
|
||||
|
||||
if (multiname.isXML(constants, localRegNames, fullyQualifiedNames)) {
|
||||
if (args.size() == 1) {
|
||||
GraphTargetItem arg = args.get(0);
|
||||
List<GraphTargetItem> xmlLines = new ArrayList<>();
|
||||
if (ConstructIns.walkXML(arg, xmlLines)) {
|
||||
stack.push(new XMLAVM2Item(ins, xmlLines));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stack.push(new ConstructPropAVM2Item(ins, obj, multiname, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
int ret = -ins.operands[1] - 1 + 1;
|
||||
int multinameIndex = ins.operands[0];
|
||||
if (abc.constants.getMultiname(multinameIndex).needsName()) {
|
||||
ret--;
|
||||
}
|
||||
if (abc.constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ret--;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConstructSuperAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstructSuperIns extends InstructionDefinition {
|
||||
|
||||
public ConstructSuperIns() {
|
||||
super(0x49, "constructsuper", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int argCount = (int) ((Long) arguments.get(0)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object obj = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Cannot call super constructor");
|
||||
//call construct property of obj
|
||||
//do not push anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int argCount = ins.operands[0];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
GraphTargetItem obj = stack.pop();
|
||||
output.add(new ConstructSuperAVM2Item(ins, obj, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -ins.operands[0] - 1;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NewActivationIns extends InstructionDefinition {
|
||||
|
||||
public NewActivationIns() {
|
||||
super(0x57, "newactivation", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
stack.push(new NewActivationAVM2Item(ins));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewArrayAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NewArrayIns extends InstructionDefinition {
|
||||
|
||||
public NewArrayIns() {
|
||||
super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int argCount = ins.operands[0];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
stack.push(new NewArrayAVM2Item(ins, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -ins.operands[0] + 1;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NewCatchIns extends InstructionDefinition {
|
||||
|
||||
public NewCatchIns() {
|
||||
super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int exInfo = ins.operands[0];
|
||||
stack.push(new ExceptionAVM2Item(body.exceptions[exInfo]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.UnparsedAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NewClassIns extends InstructionDefinition {
|
||||
|
||||
public NewClassIns() {
|
||||
super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) throws InterruptedException {
|
||||
int clsIndex = ins.operands[0];
|
||||
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
stack.pop().toString(writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
|
||||
String baseType = writer.toString();
|
||||
stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(constants, fullyQualifiedNames) + ".class extends " + baseType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NewFunctionIns extends InstructionDefinition {
|
||||
|
||||
public NewFunctionIns() {
|
||||
super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int methodIndex = ins.operands[0];
|
||||
NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, "", path, isStatic, scriptIndex, classIndex, abc, fullyQualifiedNames, constants, method_info, methodIndex);
|
||||
stack.push(function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NameValuePair;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class NewObjectIns extends InstructionDefinition {
|
||||
|
||||
public NewObjectIns() {
|
||||
super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int argCount = ins.operands[0];
|
||||
List<NameValuePair> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
GraphTargetItem name = stack.pop();
|
||||
args.add(0, new NameValuePair(name, value));
|
||||
}
|
||||
stack.push(new NewObjectAVM2Item(ins, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -ins.operands[0] * 2 + 1;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.debug;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
|
||||
public class DebugFileIns extends InstructionDefinition {
|
||||
|
||||
public DebugFileIns() {
|
||||
super(0xf1, "debugfile", new int[]{AVM2Code.DAT_STRING_INDEX});
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.debug;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
|
||||
public class DebugIns extends InstructionDefinition {
|
||||
|
||||
public DebugIns() {
|
||||
super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_REGISTER_INDEX, AVM2Code.OPT_U30});
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.debug;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
|
||||
public class DebugLineIns extends InstructionDefinition {
|
||||
|
||||
public DebugLineIns() {
|
||||
super(0xf0, "debugline", new int[]{AVM2Code.DAT_LINENUM});
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallIns extends InstructionDefinition {
|
||||
|
||||
public CallIns() {
|
||||
super(0x41, "call", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int argCount = (int) ((Long) arguments.get(0)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object receiver = lda.operandStack.pop();
|
||||
Object function = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Call to unknown function");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int argCount = ins.operands[0];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
GraphTargetItem function = stack.pop();
|
||||
stack.push(new CallAVM2Item(ins, receiver, function, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2 + 1 - ins.operands[0];
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallMethodAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallMethodIns extends InstructionDefinition {
|
||||
|
||||
public CallMethodIns() {
|
||||
super(0x43, "callmethod", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of object's method
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object receiver = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Call to unknown method");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int methodIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
String methodName = method_info.get(methodIndex).getName(constants);
|
||||
stack.push(new CallMethodAVM2Item(ins, receiver, methodName, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1 - ins.operands[1];
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallPropLexIns extends CallPropertyIns {
|
||||
|
||||
public CallPropLexIns() {
|
||||
instructionName = "callproplex";
|
||||
instructionCode = 0x4c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
|
||||
stack.push(new CallPropertyAVM2Item(ins, false, receiver, multiname, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
int ret = -ins.operands[1] - 1 + 1;
|
||||
int multinameIndex = ins.operands[0];
|
||||
if (abc.constants.getMultiname(multinameIndex).needsName()) {
|
||||
ret--;
|
||||
}
|
||||
if (abc.constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ret--;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallPropVoidIns extends InstructionDefinition {
|
||||
|
||||
public CallPropVoidIns() {
|
||||
super(0x4f, "callpropvoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
//same as callproperty
|
||||
/*
|
||||
int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object obj = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Call to unknown property");
|
||||
//do not push anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
|
||||
output.add(new CallPropertyAVM2Item(ins, true, receiver, multiname, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
int ret = -ins.operands[1] - 1;
|
||||
int multinameIndex = ins.operands[0];
|
||||
if (abc.constants.getMultiname(multinameIndex).needsName()) {
|
||||
ret--;
|
||||
}
|
||||
if (abc.constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ret--;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallPropertyIns extends InstructionDefinition {
|
||||
|
||||
public CallPropertyIns() {
|
||||
super(0x46, "callproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object obj = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Call to unknown property");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
|
||||
stack.push(new CallPropertyAVM2Item(ins, false, receiver, multiname, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
int ret = -ins.operands[1] - 1 + 1;
|
||||
int multinameIndex = ins.operands[0];
|
||||
if (abc.constants.getMultiname(multinameIndex).needsName()) {
|
||||
ret--;
|
||||
}
|
||||
if (abc.constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ret--;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallStaticAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallStaticIns extends InstructionDefinition {
|
||||
|
||||
public CallStaticIns() {
|
||||
super(0x44, "callstatic", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of method_info
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object receiver = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Call to unknown static method");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int methodIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
String methodName = method_info.get(methodIndex).getName(constants);
|
||||
stack.push(new CallStaticAVM2Item(ins, receiver, methodName, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1 + 1 - ins.operands[1];
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallSuperIns extends InstructionDefinition {
|
||||
|
||||
public CallSuperIns() {
|
||||
super(0x45, "callsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object receiver = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Call to unknown super method");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
|
||||
stack.push(new CallSuperAVM2Item(ins, false, receiver, multiname, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
int ret = -ins.operands[1] - 1 + 1;
|
||||
int multinameIndex = ins.operands[0];
|
||||
if (abc.constants.getMultiname(multinameIndex).needsName()) {
|
||||
ret--;
|
||||
}
|
||||
if (abc.constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ret--;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CallSuperVoidIns extends InstructionDefinition {
|
||||
|
||||
public CallSuperVoidIns() {
|
||||
super(0x4e, "callsupervoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List<Object> arguments) {
|
||||
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List<Object> passArguments = new ArrayList<Object>();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object receiver = lda.operandStack.pop();*/
|
||||
throw new RuntimeException("Call to unknown super method");
|
||||
//do not push anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, stack.pop());
|
||||
}
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
|
||||
output.add(new CallSuperAVM2Item(ins, true, receiver, multiname, args));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
int ret = -ins.operands[1] - 1;
|
||||
int multinameIndex = ins.operands[0];
|
||||
if (abc.constants.getMultiname(multinameIndex).needsName()) {
|
||||
ret--;
|
||||
}
|
||||
if (abc.constants.getMultiname(multinameIndex).needsNs()) {
|
||||
ret--;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfEqIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfEqIns() {
|
||||
super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new EqAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new NeqAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.NotItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfFalseIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfFalseIns() {
|
||||
super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new NotItem(ins, v1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
//String v1 = stack.pop().toString();
|
||||
//stack.push("(" + v1 + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfGeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfGeIns() {
|
||||
super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfGtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfGtIns() {
|
||||
super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfLeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfLeIns() {
|
||||
super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfLtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfLtIns() {
|
||||
super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfNGeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNGeIns() {
|
||||
super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfNGtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNGtIns() {
|
||||
super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfNLeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNLeIns() {
|
||||
super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfNLtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNLtIns() {
|
||||
super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new GeAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new LtAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IfNeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNeIns() {
|
||||
super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new NeqAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new EqAVM2Item(ins, v1, v2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user