repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
|---|---|---|---|---|---|---|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Ldiv.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Ldiv extends Instruction_noargs {
public Instruction_Ldiv() {
super((byte) ByteCode.LDIV);
name = "ldiv";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lload.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lload extends Instruction_bytevar {
public Instruction_Lload() {
super((byte) ByteCode.LLOAD);
name = "lload";
}
}
| 2,243
| 35.193548
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lload_0.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lload_0 extends Instruction_noargs {
public Instruction_Lload_0() {
super((byte) ByteCode.LLOAD_0);
name = "lload_0";
}
}
| 2,250
| 35.306452
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lload_1.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lload_1 extends Instruction_noargs {
public Instruction_Lload_1() {
super((byte) ByteCode.LLOAD_1);
name = "lload_1";
}
}
| 2,250
| 35.306452
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lload_2.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lload_2 extends Instruction_noargs {
public Instruction_Lload_2() {
super((byte) ByteCode.LLOAD_2);
name = "lload_2";
}
}
| 2,250
| 35.306452
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lload_3.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lload_3 extends Instruction_noargs {
public Instruction_Lload_3() {
super((byte) ByteCode.LLOAD_3);
name = "lload_3";
}
}
| 2,250
| 35.306452
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lmul.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lmul extends Instruction_noargs {
public Instruction_Lmul() {
super((byte) ByteCode.LMUL);
name = "lmul";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lneg.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lneg extends Instruction_noargs {
public Instruction_Lneg() {
super((byte) ByteCode.LNEG);
name = "lneg";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lookupswitch.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lookupswitch extends Instruction {
private static final Logger logger = LoggerFactory.getLogger(Instruction_Lookupswitch.class);
public Instruction_Lookupswitch() {
super((byte) ByteCode.LOOKUPSWITCH);
name = "lookupswitch";
branches = true;
}
public byte pad; // number of bytes used for padding
public int default_offset;
public int npairs;
public int match_offsets[];
public Instruction default_inst;
public Instruction match_insts[];
public String toString(cp_info constant_pool[]) {
// first figure out padding to next 4-byte quantity
String args;
int i;
args = super.toString(constant_pool) + argsep + "(" + Integer.toString(pad) + ")";
args = args + argsep + Integer.toString(default_inst.label);
args = args + argsep + Integer.toString(npairs) + ": ";
for (i = 0; i < npairs; i++) {
args = args + "case " + Integer.toString(match_offsets[i * 2]) + ": label_" + Integer.toString(match_insts[i].label);
}
return args;
}
public int parse(byte bc[], int index) {
// first figure out padding to next 4-byte quantity
int i, j;
i = index % 4;
if (i != 0) {
pad = (byte) (4 - i);
} else {
pad = (byte) 0;
}
index += pad;
default_offset = getInt(bc, index);
index += 4;
npairs = getInt(bc, index);
index += 4;
if (npairs > 0) {
match_offsets = new int[npairs * 2];
j = 0;
do {
match_offsets[j] = getInt(bc, index);
j++;
index += 4;
match_offsets[j] = getInt(bc, index);
index += 4;
j++;
} while (j < npairs * 2);
}
return index;
}
public int nextOffset(int curr) {
int i, siz = 0;
i = (curr + 1) % 4;
if (i != 0) {
siz = (4 - i);
}
return (curr + siz + 9 + npairs * 8);
}
public int compile(byte bc[], int index) {
int i;
bc[index++] = code;
// insert padding so next instruction is on a 4-byte boundary
for (i = 0; i < pad; i++) {
bc[index++] = 0;
}
if (default_inst != null) {
index = intToBytes(default_inst.label - label, bc, index);
} else {
index = intToBytes(default_offset, bc, index);
}
index = intToBytes(npairs, bc, index);
for (i = 0; i < npairs; i++) {
index = intToBytes(match_offsets[i * 2], bc, index);
if (match_insts[i] != null) {
index = intToBytes((match_insts[i]).label - label, bc, index);
} else {
index = intToBytes(match_offsets[i * 2 + 1], bc, index);
}
}
return index;
}
public void offsetToPointer(ByteCode bc) {
int i;
default_inst = bc.locateInst(default_offset + label);
if (default_inst == null) {
logger.warn("can't locate target of instruction");
logger.debug(" which should be at byte address " + (label + default_offset));
} else {
default_inst.labelled = true;
}
if (npairs > 0) {
match_insts = new Instruction[npairs];
for (i = 0; i < npairs; i++) {
match_insts[i] = bc.locateInst(match_offsets[i * 2 + 1] + label);
if (match_insts[i] == null) {
logger.warn("can't locate target of instruction");
logger.debug(" which should be at byte address " + (label + match_offsets[i * 2 + 1]));
} else {
match_insts[i].labelled = true;
}
}
}
}
public Instruction[] branchpoints(Instruction next) {
Instruction i[] = new Instruction[npairs + 1];
int j;
i[0] = default_inst;
for (j = 1; j < npairs + 1; j++) {
i[j] = match_insts[j - 1];
}
return i;
}
}
| 5,784
| 30.612022
| 123
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lor.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lor extends Instruction_noargs {
public Instruction_Lor() {
super((byte) ByteCode.LOR);
name = "lor";
}
}
| 2,234
| 35.048387
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lrem.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lrem extends Instruction_noargs {
public Instruction_Lrem() {
super((byte) ByteCode.LREM);
name = "lrem";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lreturn.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lreturn extends Instruction_noargs {
public Instruction_Lreturn() {
super((byte) ByteCode.LRETURN);
name = "lreturn";
branches = true;
returns = true;
}
}
| 2,291
| 34.8125
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lshl.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lshl extends Instruction_noargs {
public Instruction_Lshl() {
super((byte) ByteCode.LSHL);
name = "lshl";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lshr.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lshr extends Instruction_noargs {
public Instruction_Lshr() {
super((byte) ByteCode.LSHR);
name = "lshr";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lstore.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lstore extends Instruction_bytevar {
public Instruction_Lstore() {
super((byte) ByteCode.LSTORE);
name = "lstore";
}
}
| 2,247
| 35.258065
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lstore_0.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lstore_0 extends Instruction_noargs {
public Instruction_Lstore_0() {
super((byte) ByteCode.LSTORE_0);
name = "lstore_0";
}
}
| 2,254
| 35.370968
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lstore_1.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lstore_1 extends Instruction_noargs {
public Instruction_Lstore_1() {
super((byte) ByteCode.LSTORE_1);
name = "lstore_1";
}
}
| 2,254
| 35.370968
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lstore_2.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lstore_2 extends Instruction_noargs {
public Instruction_Lstore_2() {
super((byte) ByteCode.LSTORE_2);
name = "lstore_2";
}
}
| 2,254
| 35.370968
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lstore_3.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lstore_3 extends Instruction_noargs {
public Instruction_Lstore_3() {
super((byte) ByteCode.LSTORE_3);
name = "lstore_3";
}
}
| 2,254
| 35.370968
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lsub.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lsub extends Instruction_noargs {
public Instruction_Lsub() {
super((byte) ByteCode.LSUB);
name = "lsub";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lushr.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lushr extends Instruction_noargs {
public Instruction_Lushr() {
super((byte) ByteCode.LUSHR);
name = "lushr";
}
}
| 2,242
| 35.177419
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Lxor.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Lxor extends Instruction_noargs {
public Instruction_Lxor() {
super((byte) ByteCode.LXOR);
name = "lxor";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Monitorenter.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Monitorenter extends Instruction_noargs {
public Instruction_Monitorenter() {
super((byte) ByteCode.MONITORENTER);
name = "monitorenter";
}
}
| 2,270
| 35.629032
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Monitorexit.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Monitorexit extends Instruction_noargs {
public Instruction_Monitorexit() {
super((byte) ByteCode.MONITOREXIT);
name = "monitorexit";
}
}
| 2,266
| 35.564516
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Multianewarray.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Multianewarray extends Instruction_intindex {
public byte dims;
public Instruction_Multianewarray() {
super((byte) ByteCode.MULTIANEWARRAY);
name = "multianewarray";
}
public String toString(cp_info constant_pool[]) {
return super.toString(constant_pool) + argsep + dims;
}
public int nextOffset(int curr) {
return super.nextOffset(curr) + 1;
}
public int parse(byte bc[], int index) {
index = super.parse(bc, index);
dims = bc[index];
return index + 1;
}
public int compile(byte bc[], int index) {
index = super.compile(bc, index);
bc[index] = dims;
return index + 1;
}
}
| 2,756
| 31.821429
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_New.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_New extends Instruction_intindex {
public Instruction_New() {
super((byte) ByteCode.NEW);
name = "new";
/* branches = true; */ calls = true;
}
public Instruction[] branchpoints(Instruction next) {
Instruction i[] = new Instruction[1];
i[0] = null;
return i;
}
}
| 2,411
| 33.956522
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Newarray.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Newarray extends Instruction {
public static final int T_BOOLEAN = 4;
public static final int T_CHAR = 5;
public static final int T_FLOAT = 6;
public static final int T_DOUBLE = 7;
public static final int T_BYTE = 8;
public static final int T_SHORT = 9;
public static final int T_INT = 10;
public static final int T_LONG = 11;
/** one of the T_* constants. */
public byte atype;
public Instruction_Newarray() {
super((byte) ByteCode.NEWARRAY);
name = "newarray";
}
public String toString(cp_info constant_pool[]) {
String args;
switch (atype) {
case T_BOOLEAN:
args = "boolean";
break;
case T_CHAR:
args = "char";
break;
case T_FLOAT:
args = "float";
break;
case T_DOUBLE:
args = "double";
break;
case T_BYTE:
args = "byte";
break;
case T_SHORT:
args = "short";
break;
case T_INT:
args = "int";
break;
case T_LONG:
args = "long";
break;
default:
args = Integer.toString(atype);
break;
}
return super.toString(constant_pool) + argsep + args;
}
public int nextOffset(int curr) {
return curr + 2;
}
public int parse(byte bc[], int index) {
atype = bc[index];
return index + 1;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
bc[index] = atype;
return index + 1;
}
}
| 3,587
| 28.409836
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Nop.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Nop extends Instruction_noargs {
public Instruction_Nop() {
super((byte) ByteCode.NOP);
name = "nop";
}
}
| 2,234
| 35.048387
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Pop.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Pop extends Instruction_noargs {
public Instruction_Pop() {
super((byte) ByteCode.POP);
name = "pop";
}
}
| 2,234
| 35.048387
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Pop2.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Pop2 extends Instruction_noargs {
public Instruction_Pop2() {
super((byte) ByteCode.POP2);
name = "pop2";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Putfield.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Putfield extends Instruction_intindex {
public Instruction_Putfield() {
super((byte) ByteCode.PUTFIELD);
name = "putfield";
}
}
| 2,256
| 35.403226
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Putstatic.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Putstatic extends Instruction_intindex {
public Instruction_Putstatic() {
super((byte) ByteCode.PUTSTATIC);
name = "putstatic";
}
}
| 2,260
| 35.467742
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Ret.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Ret extends Instruction_bytevar {
public Instruction_Ret() {
super((byte) ByteCode.RET);
name = "ret";
branches = true;
/* returns = true; */
}
}
| 2,282
| 34.671875
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Ret_w.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Ret_w extends Instruction_intvar {
public Instruction_Ret_w() {
super((byte) ByteCode.RET_W);
name = "ret_w";
branches = true;
/* returns = true; */
}
}
| 2,289
| 34.78125
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Return.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Return extends Instruction_noargs {
public Instruction_Return() {
super((byte) ByteCode.RETURN);
name = "return";
branches = true;
returns = true;
}
}
| 2,287
| 34.75
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Saload.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Saload extends Instruction_noargs {
public Instruction_Saload() {
super((byte) ByteCode.SALOAD);
name = "saload";
}
}
| 2,246
| 35.241935
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Sastore.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Sastore extends Instruction_noargs {
public Instruction_Sastore() {
super((byte) ByteCode.SASTORE);
name = "sastore";
}
}
| 2,250
| 35.306452
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Sipush.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Sipush extends Instruction_int {
public Instruction_Sipush() {
super((byte) ByteCode.SIPUSH);
name = "sipush";
}
public Instruction_Sipush(int i) {
this();
arg_i = i;
}
}
| 2,312
| 33.522388
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Swap.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Swap extends Instruction_noargs {
public Instruction_Swap() {
super((byte) ByteCode.SWAP);
name = "swap";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Tableswitch.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Tableswitch extends Instruction {
private static final Logger logger = LoggerFactory.getLogger(Instruction_Tableswitch.class);
public Instruction_Tableswitch() {
super((byte) ByteCode.TABLESWITCH);
name = "tableswitch";
branches = true;
}
public byte pad; // number of bytes used for padding
public int default_offset;
public int low;
public int high;
public int jump_offsets[];
public Instruction default_inst;
public Instruction jump_insts[];
public String toString(cp_info constant_pool[]) {
String args;
int i;
args = super.toString(constant_pool) + argsep + "(" + Integer.toString(pad) + ")";
args = args + argsep + "label_" + Integer.toString(default_inst.label);
args = args + argsep + Integer.toString(low);
args = args + argsep + Integer.toString(high) + ": ";
for (i = 0; i < high - low + 1; i++) {
args = args + argsep + "label_" + Integer.toString(jump_insts[i].label);
}
return args;
}
public int parse(byte bc[], int index) {
// first figure out padding to next 4-byte quantity
int i, j;
i = index % 4;
if (i != 0) {
pad = (byte) (4 - i);
} else {
pad = (byte) 0;
}
index += pad;
default_offset = getInt(bc, index);
index += 4;
low = getInt(bc, index);
index += 4;
high = getInt(bc, index);
index += 4;
i = high - low + 1;
if (i > 0) {
jump_offsets = new int[i];
j = 0;
do {
jump_offsets[j] = getInt(bc, index);
index += 4;
j++;
} while (j < i);
}
return index;
}
public int nextOffset(int curr) {
int i, siz = 0;
i = (curr + 1) % 4;
if (i != 0) {
siz = (4 - i);
}
return (curr + siz + 13 + (high - low + 1) * 4);
}
public int compile(byte bc[], int index) {
int i;
bc[index++] = code;
// insert padding so next instruction is on a 4-byte boundary
for (i = 0; i < pad; i++) {
bc[index++] = 0;
}
if (default_inst != null) {
index = intToBytes(default_inst.label - label, bc, index);
} else {
index = intToBytes(default_offset, bc, index);
}
index = intToBytes(low, bc, index);
index = intToBytes(high, bc, index);
for (i = 0; i <= high - low; i++) {
if (jump_insts[i] != null) {
index = intToBytes((jump_insts[i]).label - label, bc, index);
} else {
index = intToBytes(jump_offsets[i], bc, index);
}
}
return index;
}
public void offsetToPointer(ByteCode bc) {
int i;
default_inst = bc.locateInst(default_offset + label);
if (default_inst == null) {
logger.warn("can't locate target of instruction");
logger.debug(" which should be at byte address " + (label + default_offset));
} else {
default_inst.labelled = true;
}
if (high - low + 1 > 0) {
jump_insts = new Instruction[high - low + 1];
for (i = 0; i < high - low + 1; i++) {
jump_insts[i] = bc.locateInst(jump_offsets[i] + label);
if (jump_insts[i] == null) {
logger.warn("can't locate target of instruction");
logger.debug(" which should be at byte address " + (label + jump_offsets[i]));
} else {
jump_insts[i].labelled = true;
}
}
}
}
public Instruction[] branchpoints(Instruction next) {
Instruction i[] = new Instruction[high - low + 2];
int j;
i[0] = default_inst;
for (j = 1; j < high - low + 2; j++) {
i[j] = jump_insts[j - 1];
}
return i;
}
}
| 5,715
| 30.065217
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Unknown.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Unknown extends Instruction_noargs {
public Instruction_Unknown(byte c) {
super(c);
name = "unknown instruction (" + ((c) & 0xff) + ")";
}
}
| 2,269
| 35.612903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_Wide.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_Wide extends Instruction_noargs {
public Instruction_Wide() {
super((byte) ByteCode.WIDE);
name = "wide";
}
}
| 2,238
| 35.112903
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_branch.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
abstract class Instruction_branch extends Instruction {
private static final Logger logger = LoggerFactory.getLogger(Instruction_branch.class);
public int arg_i;
public Instruction target; // pointer to target instruction
public Instruction_branch(byte c) {
super(c);
branches = true;
}
public String toString(cp_info constant_pool[]) {
return super.toString(constant_pool) + argsep + "[label_" + Integer.toString(target.label) + "]";
}
public void offsetToPointer(ByteCode bc) {
target = bc.locateInst(arg_i + label);
if (target == null) {
logger.warn("can't locate target of instruction");
logger.debug(" which should be at byte address " + (label + arg_i));
} else {
target.labelled = true;
}
}
// returns the array of instructions which might be the target of a
// branch with this instruction, assuming the next instruction is next
public Instruction[] branchpoints(Instruction next) {
Instruction i[] = new Instruction[2];
i[0] = target;
i[1] = next;
return i;
}
public String toString() {
return super.toString() + "\t" + target.label;
}
}
| 3,304
| 33.427083
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_byte.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_byte extends Instruction {
public byte arg_b;
public Instruction_byte(byte c) {
super(c);
}
public String toString(cp_info constant_pool[]) {
return super.toString(constant_pool) + argsep + arg_b;
}
public int nextOffset(int curr) {
return curr + 2;
}
public int parse(byte bc[], int index) {
arg_b = bc[index];
return index + 1;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
bc[index++] = arg_b;
return index;
}
public String toString() {
return super.toString() + " " + arg_b;
}
}
| 2,689
| 30.27907
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_byteindex.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_byteindex extends Instruction {
/**
* arg_b needs to be short in order to contain all the possible values for an unsigned byte
*/
public short arg_b;
public Instruction_byteindex(byte c) {
super(c);
}
public String toString(cp_info constant_pool[]) {
int i = (arg_b) & 0xff;
return super.toString(constant_pool) + argsep + "[" + constant_pool[i].toString(constant_pool) + "]";
}
public int nextOffset(int curr) {
return curr + 2;
}
public void markCPRefs(boolean[] refs) {
refs[(arg_b) & 0xff] = true;
}
public void redirectCPRefs(short redirect[]) {
arg_b = (byte) (redirect[(arg_b) & 0xff]);
}
public int parse(byte bc[], int index) {
arg_b = bc[index];
arg_b = (arg_b >= 0) ? arg_b : (short) (256 + arg_b);
return index + 1;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
bc[index++] = (byte) arg_b;
return index;
}
}
| 3,050
| 30.453608
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_bytevar.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_bytevar extends Instruction implements Interface_OneIntArg {
/**
* arg_b needs to be short in order to contain all the possible values for an unsigned byte
*/
public int arg_b;
public boolean isWide;
public Instruction_bytevar(byte c) {
super(c);
}
public String toString(cp_info constant_pool[]) {
return super.toString(constant_pool) + argsep + LOCALPREFIX + arg_b;
}
public int nextOffset(int curr) {
return curr + 1 + ((isWide) ? 3 : 1);
}
public int parse(byte bc[], int index) {
int indexbyte1 = (bc[index]) & 0xff;
if (isWide) {
int indexbyte2 = (bc[index + 1]) & 0xff;
arg_b = (indexbyte1 << 8) | indexbyte2;
return index + 2;
} else {
arg_b = indexbyte1;
return index + 1;
}
}
public int compile(byte bc[], int index) {
bc[index++] = code;
bc[index++] = (byte) arg_b;
return index;
}
public int getIntArg() {
return arg_b;
}
}
| 3,071
| 29.72
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_int.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_int extends Instruction {
public int arg_i;
public Instruction_int(byte c) {
super(c);
}
public String toString(cp_info constant_pool[]) {
return super.toString(constant_pool) + argsep + arg_i;
}
public int nextOffset(int curr) {
return curr + 3;
}
public int parse(byte bc[], int index) {
arg_i = getShort(bc, index);
return index + 2;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
shortToBytes((short) arg_i, bc, index);
return index + 2;
}
}
| 2,639
| 31.195122
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_intbranch.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_intbranch extends Instruction_branch {
public Instruction_intbranch(byte c) {
super(c);
}
public int nextOffset(int curr) {
return curr + 3;
}
public int parse(byte bc[], int index) {
arg_i = getShort(bc, index);
return index + 2;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
if (target != null) {
shortToBytes((short) (target.label - label), bc, index);
} else {
shortToBytes((short) (arg_i), bc, index);
}
return index + 2;
}
}
| 2,633
| 31.925
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_intindex.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_intindex extends Instruction {
public int arg_i;
public Instruction_intindex(byte c) {
super(c);
}
public String toString(cp_info constant_pool[]) {
return super.toString(constant_pool) + argsep + "[" + constant_pool[arg_i].toString(constant_pool) + "]";
}
public int nextOffset(int curr) {
return curr + 3;
}
public void markCPRefs(boolean[] refs) {
refs[arg_i] = true;
}
public void redirectCPRefs(short redirect[]) {
arg_i = redirect[arg_i];
}
public int parse(byte bc[], int index) {
arg_i = getShort(bc, index);
return index + 2;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
shortToBytes((short) arg_i, bc, index);
return index + 2;
}
}
| 2,855
| 30.733333
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_intvar.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_intvar extends Instruction implements Interface_OneIntArg {
public int arg_i;
public Instruction_intvar(byte c) {
super(c);
}
public String toString(cp_info constant_pool[]) {
return super.toString(constant_pool) + argsep + LOCALPREFIX + arg_i;
}
public int nextOffset(int curr) {
return curr + 3;
}
public int parse(byte bc[], int index) {
arg_i = getShort(bc, index);
return index + 2;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
shortToBytes((short) arg_i, bc, index);
return index + 2;
}
public int getIntArg() {
return arg_i;
}
}
| 2,740
| 30.872093
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_longbranch.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_longbranch extends Instruction_branch {
public Instruction_longbranch(byte c) {
super(c);
}
public int nextOffset(int curr) {
return curr + 5;
}
public int parse(byte bc[], int index) {
arg_i = getInt(bc, index);
return index + 4;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
if (target != null) {
shortToBytes((short) (target.label - label), bc, index);
} else {
shortToBytes((short) (arg_i), bc, index);
}
return index + 4;
}
}
| 2,633
| 31.925
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Instruction_noargs.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Instruction subclasses are used to represent parsed bytecode; each bytecode operation has a corresponding subclass of
* Instruction.
* <p>
* Each subclass is derived from one of
* <ul>
* <li>Instruction</li>
* <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
* <li>Instruction_byte (an Instruction with a single byte data argument)</li>
* <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
* <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
* <li>Instruction_int (an Instruction with a single short data argument)</li>
* <li>Instruction_intvar (a short argument specifying a local variable)</li>
* <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
* <li>Instruction_intbranch (a short argument specifying a code offset)</li>
* <li>Instruction_longbranch (an int argument specifying a code offset)</li>
* </ul>
*
* @author Clark Verbrugge
* @see Instruction
* @see Instruction_noargs
* @see Instruction_byte
* @see Instruction_bytevar
* @see Instruction_byteindex
* @see Instruction_int
* @see Instruction_intvar
* @see Instruction_intindex
* @see Instruction_intbranch
* @see Instruction_longbranch
* @see Instruction_Unknown
*/
class Instruction_noargs extends Instruction {
public Instruction_noargs(byte c) {
super(c);
}
public int parse(byte bc[], int index) {
return index;
}
public int compile(byte bc[], int index) {
bc[index++] = code;
return index;
}
}
| 2,361
| 32.742857
| 120
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Interface_Astore.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2002 Sable Research Group
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface Interface_Astore {
public int getLocalNumber();
}
| 895
| 31
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Interface_OneIntArg.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2002 Sable Research Group
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface Interface_OneIntArg {
public int getIntArg();
}
| 893
| 30.928571
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/LineNumberTable_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* A debugging attribute, this associates blocks of bytecode with specific source code line numbers.
*
* @see attribute_info
* @author Clark Verbrugge
*/
public class LineNumberTable_attribute extends attribute_info {
/** Length of the line_number_table array. */
public int line_number_table_length;
/**
* Line number table.
*
* @see line_number_table_entry
*/
public line_number_table_entry line_number_table[];
public String toString() {
String sv = "LineNumberTable : " + line_number_table_length + "\n";
for (int i = 0; i < line_number_table_length; i++) {
sv += "LineNumber(" + line_number_table[i].start_pc + ":" + line_number_table[i].start_inst + ","
+ line_number_table[i].line_number + ")";
sv += "\n";
}
return sv;
}
}
| 1,626
| 29.12963
| 103
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/LocalVariableTable_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A debugging attribute, this gives the names of local variables within blocks of bytecode.
*
* @see attribute_info
* @author Clark Verbrugge
*/
class LocalVariableTable_attribute extends attribute_info {
private static final Logger logger = LoggerFactory.getLogger(LocalVariableTable_attribute.class);
/** Length of the local variable table. */
public int local_variable_table_length;
/** Actual table of local variables. */
public local_variable_table_entry local_variable_table[];
/**
* Locates the first name found for a given local variable.
*
* @param constant_pool
* constant pool for the associated class.
* @param idx
* local variable index.
* @return name of the local variable, or <i>null</i> if not found.
* @see LocalVariableTable_attribute#getLocalVariableName(cp_info[], int, int)
*/
public String getLocalVariableName(cp_info constant_pool[], int idx) {
return getLocalVariableName(constant_pool, idx, -1);
}
/**
* Locates the name of the given local variable for the specified code offset.
*
* @param constant_pool
* constant pool for the associated class.
* @param idx
* local variable index.
* @param code
* code offset for variable name; use -1 to return the first name found for that local variable.
* @return name of the local variable, or <i>null</i> if not found.
* @see LocalVariableTable_attribute#getLocalVariableName(cp_info[], int)
*/
public String getLocalVariableName(cp_info constant_pool[], int idx, int code) {
local_variable_table_entry e;
int i;
// logger.debug("searching for name of local: " + idx + "at: " + code);
// now to find that variable
for (i = 0; i < local_variable_table_length; i++) {
e = local_variable_table[i];
if (e.index == idx && (code == -1 || (code >= e.start_pc && code < e.start_pc + e.length))) {
// (code>=e.start_pc && code<e.start_pc+e.length))) {
// found the variable, now find its name.
// logger.debug("found entry: " + i);
if (constant_pool[e.name_index] instanceof CONSTANT_Utf8_info) {
String n = ((CONSTANT_Utf8_info) (constant_pool[e.name_index])).convert();
if (Util.v().isValidJimpleName(n)) {
return n;
} else {
return null;
}
} else {
throw new RuntimeException("What? A local variable table " + "name_index isn't a UTF8 entry?");
}
}
}
return null;
}
public String getLocalVariableDescriptor(cp_info constant_pool[], int idx, int code) {
local_variable_table_entry e;
int i;
for (i = 0; i < local_variable_table_length; i++) {
e = local_variable_table[i];
if (e.index == idx && (code == -1 || (code >= e.start_pc && code < e.start_pc + e.length))) {
if (constant_pool[e.descriptor_index] instanceof CONSTANT_Utf8_info) {
String n = ((CONSTANT_Utf8_info) (constant_pool[e.descriptor_index])).convert();
return n;
} else {
throw new RuntimeException("What? A local variable table " + "name_index isn't a UTF8 entry?");
}
}
}
return null;
}
public String getEntryName(cp_info constant_pool[], int entryIndex) {
try {
local_variable_table_entry e = local_variable_table[entryIndex];
if (constant_pool[e.name_index] instanceof CONSTANT_Utf8_info) {
String n = ((CONSTANT_Utf8_info) (constant_pool[e.name_index])).convert();
if (Util.v().isValidJimpleName(n)) {
return n;
} else {
return null;
}
} else {
throw new RuntimeException("name_index not addressing an UTF8 entry.");
}
} catch (ArrayIndexOutOfBoundsException x) {
return null;
}
}
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < local_variable_table_length; i++) {
buffer.append(local_variable_table[i].toString() + "\n");
}
return buffer.toString();
}
}
| 4,957
| 33.915493
| 107
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/LocalVariableTypeTable_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A debugging attribute, this gives the types of local variables within blocks of bytecode. - for java 1.5
*
* @see attribute_info
* @author Jennifer Lhotak modified from LocalVariableTable_attribute
*/
class LocalVariableTypeTable_attribute extends attribute_info {
private static final Logger logger = LoggerFactory.getLogger(LocalVariableTypeTable_attribute.class);
/** Length of the local variable type table. */
public int local_variable_type_table_length;
/** Actual table of local variable types. */
public local_variable_type_table_entry local_variable_type_table[];
/**
* Locates the first type found for a given local variable.
*
* @param constant_pool
* constant pool for the associated class.
* @param idx
* local variable type index.
* @return type of the local variable, or <i>null</i> if not found.
* @see LocalVariableTypeTable_attribute#getLocalVariableType(cp_info[], int, int)
*/
public String getLocalVariableType(cp_info constant_pool[], int idx) {
return getLocalVariableType(constant_pool, idx, -1);
}
/**
* Locates the type of the given local variable for the specified code offset.
*
* @param constant_pool
* constant pool for the associated class.
* @param idx
* local variable type index.
* @param code
* code offset for variable name; use -1 to return the first name found for that local variable.
* @return type of the local variable, or <i>null</i> if not found.
* @see LocalVariableTypeTable_attribute#getLocalVariableType(cp_info[], int)
*/
public String getLocalVariableType(cp_info constant_pool[], int idx, int code) {
local_variable_type_table_entry e;
int i;
// logger.debug("searching for type of local: " + idx + "at: " + code);
// now to find that variable
for (i = 0; i < local_variable_type_table_length; i++) {
e = local_variable_type_table[i];
if (e.index == idx && (code == -1 || (code >= e.start_pc && code <= e.start_pc + e.length))) {
// (code>=e.start_pc && code<e.start_pc+e.length))) {
// found the variable, now find its name.
// logger.debug("found entry: " + i);
if (constant_pool[e.signature_index] instanceof CONSTANT_Utf8_info) {
String n = ((CONSTANT_Utf8_info) (constant_pool[e.signature_index])).convert();
// logger.debug("found type: "+n);
// if (Util.v().isValidJimpleName(n))
// return n;
// else
// return null;
} else {
throw new RuntimeException("What? A local variable type table " + "signature_index isn't a UTF8 entry?");
}
}
}
return null;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < local_variable_type_table_length; i++) {
buffer.append(local_variable_type_table[i].toString() + "\n");
}
return buffer.toString();
}
}
| 3,858
| 35.40566
| 115
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Long2ndHalfType.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.G;
import soot.Singletons;
import soot.Type;
public class Long2ndHalfType extends Type {
public Long2ndHalfType(Singletons.Global g) {
}
public static Long2ndHalfType v() {
return G.v().soot_coffi_Long2ndHalfType();
}
public boolean equals(Type otherType) {
return otherType instanceof Long2ndHalfType;
}
@Override
public String toString() {
return "long2ndhalf";
}
}
| 1,236
| 25.319149
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/RuntimeInvisibleAnnotations_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There should be at most one RuntimeInvisibleAnnotations attribute in every method, field and class indicating the list of
* annotations.
*
* @see attribute_info
* @see method_info#attributes, @see field_info#attributes,
* @see coffi_class#attributes
* @author Jennifer Lhotak
*/
public class RuntimeInvisibleAnnotations_attribute extends attribute_info {
/** Length of annotations table array. */
public int number_of_annotations;
/**
* Each entry represents a single runtime invisible annotation.
*/
public annotation annotations[];
}
| 1,385
| 32
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/RuntimeInvisibleParameterAnnotations_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There should be at most one RuntimeVisibleParameterAnnotations attribute in method indicating the list of annotations for
* each method parameter
*
* @see attribute_info
* @see method_info#attributes
* @author Jennifer Lhotak
*/
public class RuntimeInvisibleParameterAnnotations_attribute extends attribute_info {
/** Length of annotations table array. */
public int num_parameters;
/**
* Each entry represents a single runtime visible annotation.
*/
public parameter_annotation parameter_annotations[];
}
| 1,354
| 32.04878
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/RuntimeVisibleAnnotations_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There should be at most one RuntimeVisibleAnnotations attribute in every method, field and class indicating the list of
* annotations.
*
* @see attribute_info
* @see method_info#attributes, @see field_info#attributes,
* @see coffi_class#attributes
* @author Jennifer Lhotak
*/
public class RuntimeVisibleAnnotations_attribute extends attribute_info {
/** Length of annotations table array. */
public int number_of_annotations;
/**
* Each entry represents a single runtime visible annotation.
*/
public annotation annotations[];
}
| 1,379
| 31.857143
| 122
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/RuntimeVisibleParameterAnnotations_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There should be at most one RuntimeVisibleParameterAnnotations attribute in method indicating the list of annotations for
* each method parameter
*
* @see attribute_info
* @see method_info#attributes
* @author Jennifer Lhotak
*/
public class RuntimeVisibleParameterAnnotations_attribute extends attribute_info {
/** Length of annotations table array. */
public int num_parameters;
/**
* Each entry represents a single runtime visible annotation.
*/
public parameter_annotation parameter_annotations[];
}
| 1,352
| 32
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Signature_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Attribute that connects signature attribute.
*
* @see attribute_info
* @author Jennifer Lhotak
*/
class Signature_attribute extends attribute_info {
public int signature_index;
}
| 1,015
| 28.028571
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/SourceFile_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* A debugging attribute, this gives the name of the source file for this <tt>.class</tt> file.
*
* @see attribute_info
* @author Clark Verbrugge
*/
public class SourceFile_attribute extends attribute_info {
/**
* Constant pool index of a utf8 string for the name of the associated source file.
*
* @see CONSTANT_Utf8_info
*/
public int sourcefile_index;
}
| 1,204
| 29.897436
| 95
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Synthetic_attribute.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2004 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Attribute that connects synthetic attribute.
*
* @see attribute_info
* @author Jennifer Lhotak
*/
class Synthetic_attribute extends attribute_info {
}
| 984
| 28.848485
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/TypeArray.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.io.PrintStream;
import soot.ArrayType;
import soot.RefType;
import soot.Type;
class TypeArray {
private Type[] types;
private TypeArray() {
}
/**
* Returns an empty array of types.
*
*/
public static TypeArray v(int size) {
TypeArray newArray = new TypeArray();
newArray.types = new Type[size];
for (int i = 0; i < size; i++) {
newArray.types[i] = UnusuableType.v();
}
return newArray;
}
public Type get(int index) {
return types[index];
}
public TypeArray set(int index, Type type) {
TypeArray newArray = new TypeArray();
newArray.types = types.clone();
newArray.types[index] = type;
return newArray;
}
public boolean equals(Object obj) {
if (obj instanceof TypeArray) {
TypeArray other = (TypeArray) obj;
if (types.length != other.types.length) {
return false;
}
for (Type element : types) {
if (!element.equals(element)) {
return false;
}
}
return true;
} else {
return false;
}
}
public TypeArray merge(TypeArray otherArray) {
TypeArray newArray = new TypeArray();
if (types.length != otherArray.types.length) {
throw new RuntimeException("Merging of type arrays failed; unequal array length");
}
newArray.types = new Type[types.length];
for (int i = 0; i < types.length; i++) {
if (types[i].equals(otherArray.types[i])) {
newArray.types[i] = types[i];
} else if ((types[i] instanceof ArrayType || types[i] instanceof RefType)
&& (otherArray.types[i] instanceof ArrayType || otherArray.types[i] instanceof RefType)) {
// This type merge does not need to be accurate, because it is not really used
newArray.types[i] = RefType.v("java.lang.Object");
} else {
newArray.types[i] = UnusuableType.v();
}
}
return newArray;
}
public void print(PrintStream out) {
for (int i = 0; i < types.length; i++) {
out.println(i + ": " + types[i].toString());
}
}
}
| 2,896
| 23.760684
| 100
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/TypeStack.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.io.PrintStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import soot.ArrayType;
import soot.RefType;
import soot.Type;
/*
* A less resource hungry implementation of the TypeStack would just have pointers to
* 'sub-stacks' instead of copying the entire array around.
*/
class TypeStack {
private static final Logger logger = LoggerFactory.getLogger(TypeStack.class);
private Type[] types;
private TypeStack() {
// no constructor
}
public Object clone() {
TypeStack newTypeStack = new TypeStack();
newTypeStack.types = types.clone();
return newTypeStack;
}
/**
* Returns an empty stack.
*/
public static TypeStack v() {
TypeStack typeStack = new TypeStack();
typeStack.types = new Type[0];
return typeStack;
}
public TypeStack pop() {
TypeStack newStack = new TypeStack();
newStack.types = new Type[types.length - 1];
System.arraycopy(types, 0, newStack.types, 0, types.length - 1);
return newStack;
}
public TypeStack push(Type type) {
TypeStack newStack = new TypeStack();
newStack.types = new Type[types.length + 1];
System.arraycopy(types, 0, newStack.types, 0, types.length);
newStack.types[types.length] = type;
return newStack;
}
public Type get(int index) {
return types[index];
}
public int topIndex() {
return types.length - 1;
}
public Type top() {
if (types.length == 0) {
throw new RuntimeException("TypeStack is empty");
} else {
return types[types.length - 1];
}
}
public boolean equals(Object object) {
if (object instanceof TypeStack) {
TypeStack otherStack = (TypeStack) object;
if (otherStack.types.length != types.length) {
return false;
}
for (Type element : types) {
if (!element.equals(element)) {
return false;
}
}
return true;
} else {
return false;
}
}
public TypeStack merge(TypeStack other) {
if (types.length != other.types.length) {
throw new RuntimeException(
"TypeStack merging failed; unequal " + "stack lengths: " + types.length + " and " + other.types.length);
}
TypeStack newStack = new TypeStack();
newStack.types = new Type[other.types.length];
for (int i = 0; i < types.length; i++) {
if (types[i].equals(other.types[i])) {
newStack.types[i] = types[i];
} else {
if ((!(types[i] instanceof ArrayType) && !(types[i] instanceof RefType))
|| (!(other.types[i] instanceof RefType) && !(other.types[i] instanceof ArrayType))) {
throw new RuntimeException("TypeStack merging failed; incompatible types " + types[i] + " and " + other.types[i]);
}
// logger.debug("Merging: " + types[i] + " with " + other.types[i]);
newStack.types[i] = RefType.v("java.lang.Object");
}
}
return newStack;
}
public void print(PrintStream out) {
for (int i = types.length - 1; i >= 0; i--) {
out.println(i + ": " + types[i].toString());
}
if (types.length == 0) {
out.println("<empty>");
}
}
}
| 3,985
| 23.604938
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/UnusuableType.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.G;
import soot.Singletons;
import soot.Type;
public class UnusuableType extends Type {
public UnusuableType(Singletons.Global g) {
}
public static UnusuableType v() {
return G.v().soot_coffi_UnusuableType();
}
public boolean equals(Type otherType) {
return otherType instanceof UnusuableType;
}
@Override
public String toString() {
return "unusuable";
}
}
| 1,224
| 25.06383
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Utf8_Enumeration.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Enumeration;
/**
* An enumeration of a Utf8 allows one to run through the characters in a unicode string; used primarily for comparing
* unicode strings. Note that unlike regular enumerations, and to be efficient (ie to avoid allocating an object in each call
* to nextElement), the return value is accessed by this object's 'c' field, and nextElement merely returns this.
*
* @see CONSTANT_Utf8_info
* @see Utf8_Enumeration#c
* @see Utf8_Enumeration#nextElement
* @author Clark Verbrugge
*/
public class Utf8_Enumeration implements Enumeration {
/**
* The latest character, as determined by nextElement.
*
* @see Utf8_Enumeration#nextElement
*/
public int c; // latest character
private short curindex;
private short length;
private byte bytes[];
/**
* For creating an empty enumeration; you must use reset() after this to initialize the enumeration.
*
* @see Utf8_Enumeration#reset
*/
public Utf8_Enumeration() {
}
/**
* For creating a normal enumeration of the given Utf8 string.
*
* @param b
* array of bytes in Utf8 format.
*/
public Utf8_Enumeration(byte b[]) {
bytes = b;
curindex = (short) 2;
length = (short) (((((bytes[0])) & 0xff) << 8) + (((bytes[1])) & 0xff) + 2);
}
/**
* Resets this object to be an enumeration of the given Utf8 string.
*
* @param b
* array of bytes in Utf8 format.
*/
public void reset(byte b[]) {
bytes = b;
curindex = (short) 2;
length = (short) (((((bytes[0])) & 0xff) << 8) + (((bytes[1])) & 0xff) + 2);
}
/** <i>true</i> if the entire string hasn't been enumerated yet. */
public boolean hasMoreElements() {
if (curindex < length) {
return true;
}
return false;
}
/**
* Determines the next Utf8 character, and stores it in c.
*
* @return <i>this</i>
* @see Utf8_Enumeration#c
*/
public Object nextElement() {
byte b;
b = bytes[curindex++];
if ((b & ((byte) 0x80)) == 0) { // one-byte character
c = b;
} else if ((b & ((byte) 0xe0)) == 0xc0) { // two-byte character
c = ((b & ((byte) 0x1f))) << 6;
b = bytes[curindex++];
c |= (b & ((byte) 0x3f));
} else { // three-byte character
c = ((b & ((byte) 0x0f))) << 12;
b = bytes[curindex++];
c |= ((b & ((byte) 0x3f))) << 6;
b = bytes[curindex++];
c |= (b & ((byte) 0x3f));
}
return this;
}
}
| 3,280
| 27.530435
| 125
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/Util.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import soot.ArrayType;
import soot.Body;
import soot.BooleanType;
import soot.ByteType;
import soot.CharType;
import soot.DoubleType;
import soot.FloatType;
import soot.G;
import soot.IntType;
import soot.Local;
import soot.LongType;
import soot.Modifier;
import soot.RefType;
import soot.Scene;
import soot.ShortType;
import soot.Singletons;
import soot.SootClass;
import soot.SootField;
import soot.SootMethod;
import soot.SootResolver;
import soot.Type;
import soot.UnknownType;
import soot.VoidType;
import soot.jimple.Jimple;
import soot.jimple.JimpleBody;
import soot.tagkit.AnnotationAnnotationElem;
import soot.tagkit.AnnotationArrayElem;
import soot.tagkit.AnnotationClassElem;
import soot.tagkit.AnnotationConstants;
import soot.tagkit.AnnotationDefaultTag;
import soot.tagkit.AnnotationDoubleElem;
import soot.tagkit.AnnotationElem;
import soot.tagkit.AnnotationEnumElem;
import soot.tagkit.AnnotationFloatElem;
import soot.tagkit.AnnotationIntElem;
import soot.tagkit.AnnotationLongElem;
import soot.tagkit.AnnotationStringElem;
import soot.tagkit.AnnotationTag;
import soot.tagkit.ConstantValueTag;
import soot.tagkit.DeprecatedTag;
import soot.tagkit.DoubleConstantValueTag;
import soot.tagkit.EnclosingMethodTag;
import soot.tagkit.FloatConstantValueTag;
import soot.tagkit.GenericAttribute;
import soot.tagkit.Host;
import soot.tagkit.InnerClassTag;
import soot.tagkit.IntegerConstantValueTag;
import soot.tagkit.LongConstantValueTag;
import soot.tagkit.SignatureTag;
import soot.tagkit.SourceFileTag;
import soot.tagkit.StringConstantValueTag;
import soot.tagkit.SyntheticTag;
import soot.tagkit.VisibilityAnnotationTag;
import soot.tagkit.VisibilityParameterAnnotationTag;
public class Util {
private static final Logger logger = LoggerFactory.getLogger(Util.class);
public Util(Singletons.Global g) {
}
public static Util v() {
return G.v().soot_coffi_Util();
}
private cp_info[] activeConstantPool = null;
private LocalVariableTable_attribute activeVariableTable;
/*
* maps from variable names to local variable slot indexes to soot Locals
*/
private Map<String, Map<Integer, Local>> nameToIndexToLocal;
private boolean useFaithfulNaming = false;
/**
* Set the informations relative to the current method body. This method must be called before using getLocalForIndex(...)
* and getLocalForStackOp(...) each time a different current method body is considered.
*/
public void bodySetup(LocalVariableTable_attribute la, LocalVariableTypeTable_attribute lt, cp_info[] ca) {
activeVariableTable = la;
activeConstantPool = ca;
nameToIndexToLocal = null;
}
public void setFaithfulNaming(boolean v) {
useFaithfulNaming = v;
}
public boolean isUsingFaithfulNaming() {
return useFaithfulNaming;
}
public void resolveFromClassFile(SootClass aClass, InputStream is, String filePath, Collection<Type> references) {
SootClass bclass = aClass;
String className = bclass.getName();
ClassFile coffiClass = new ClassFile(className);
// Load up class file, and retrieve
// bclass from class manager.
{
boolean success = coffiClass.loadClassFile(is);
if (!success) {
if (!Scene.v().allowsPhantomRefs()) {
throw new RuntimeException("Could not load classfile: " + bclass.getName());
} else {
logger.warn("" + className + " is a phantom class!");
bclass.setPhantomClass();
return;
}
}
CONSTANT_Class_info c = (CONSTANT_Class_info) coffiClass.constant_pool[coffiClass.this_class];
String name = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[c.name_index])).convert();
name = name.replace('/', '.');
if (!name.equals(bclass.getName())) {
throw new RuntimeException(
"Error: class " + name + " read in from a classfile in which " + bclass.getName() + " was expected.");
}
}
// Set modifier
bclass.setModifiers(coffiClass.access_flags & (~0x0020));
// don't want the ACC_SUPER flag, it is
// always supposed to be set
// anyways
// Set superclass
{
if (coffiClass.super_class != 0) {
// This object is not java.lang.Object,
// so must have a super
// class
CONSTANT_Class_info c = (CONSTANT_Class_info) coffiClass.constant_pool[coffiClass.super_class];
String superName = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[c.name_index])).convert();
superName = superName.replace('/', '.');
references.add(RefType.v(superName));
bclass.setSuperclass(SootResolver.v().makeClassRef(superName));
}
}
// Add interfaces to the bclass
{
for (int i = 0; i < coffiClass.interfaces_count; i++) {
CONSTANT_Class_info c = (CONSTANT_Class_info) coffiClass.constant_pool[coffiClass.interfaces[i]];
String interfaceName = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[c.name_index])).convert();
interfaceName = interfaceName.replace('/', '.');
references.add(RefType.v(interfaceName));
SootClass interfaceClass = SootResolver.v().makeClassRef(interfaceName);
interfaceClass.setModifiers(interfaceClass.getModifiers() | Modifier.INTERFACE);
bclass.addInterface(interfaceClass);
}
}
// Add every field to the bclass
for (int i = 0; i < coffiClass.fields_count; i++) {
field_info fieldInfo = coffiClass.fields[i];
String fieldName = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[fieldInfo.name_index])).convert();
String fieldDescriptor = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[fieldInfo.descriptor_index])).convert();
int modifiers = fieldInfo.access_flags;
Type fieldType = jimpleTypeOfFieldDescriptor(fieldDescriptor);
SootField field = Scene.v().makeSootField(fieldName, fieldType, modifiers);
bclass.addField(field);
references.add(fieldType);
// add initialization constant, if any
for (int j = 0; j < fieldInfo.attributes_count; j++) {
// add constant value attributes
if (fieldInfo.attributes[j] instanceof ConstantValue_attribute) {
ConstantValue_attribute attr = (ConstantValue_attribute) fieldInfo.attributes[j];
cp_info cval = coffiClass.constant_pool[attr.constantvalue_index];
ConstantValueTag tag;
switch (cval.tag) {
case cp_info.CONSTANT_Integer:
tag = new IntegerConstantValueTag((int) ((CONSTANT_Integer_info) cval).bytes);
break;
case cp_info.CONSTANT_Float:
// tag = new
// FloatConstantValueTag((int)((CONSTANT_Float_info)cval).bytes);
tag = new FloatConstantValueTag(((CONSTANT_Float_info) cval).convert());
break;
case cp_info.CONSTANT_Long: {
CONSTANT_Long_info lcval = (CONSTANT_Long_info) cval;
tag = new LongConstantValueTag((lcval.high << 32) + lcval.low);
break;
}
case cp_info.CONSTANT_Double: {
CONSTANT_Double_info dcval = (CONSTANT_Double_info) cval;
// tag = new
// DoubleConstantValueTag((dcval.high <<
// 32) +
// dcval.low);
tag = new DoubleConstantValueTag(dcval.convert());
break;
}
case cp_info.CONSTANT_String: {
CONSTANT_String_info scval = (CONSTANT_String_info) cval;
CONSTANT_Utf8_info ucval = (CONSTANT_Utf8_info) coffiClass.constant_pool[scval.string_index];
tag = new StringConstantValueTag(ucval.convert());
break;
}
default:
throw new RuntimeException("unexpected ConstantValue: " + cval);
}
field.addTag(tag);
}
// add synthetic tag
else if (fieldInfo.attributes[j] instanceof Synthetic_attribute) {
field.addTag(new SyntheticTag());
}
// add deprecated tag
else if (fieldInfo.attributes[j] instanceof Deprecated_attribute) {
field.addTag(new DeprecatedTag());
}
// add signature tag
else if (fieldInfo.attributes[j] instanceof Signature_attribute) {
int signature_index = ((Signature_attribute) fieldInfo.attributes[j]).signature_index;
String generic_sig = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[signature_index])).convert();
field.addTag(new SignatureTag(generic_sig));
} else if (fieldInfo.attributes[j] instanceof RuntimeVisibleAnnotations_attribute
|| fieldInfo.attributes[j] instanceof RuntimeInvisibleAnnotations_attribute) {
addAnnotationVisibilityAttribute(field, fieldInfo.attributes[j], coffiClass, references);
} else if (fieldInfo.attributes[j] instanceof Generic_attribute) {
Generic_attribute attr = (Generic_attribute) fieldInfo.attributes[j];
String name = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[attr.attribute_name])).convert();
field.addTag(new GenericAttribute(name, attr.info));
}
}
}
// Add every method to the bclass
for (int i = 0; i < coffiClass.methods_count; i++) {
method_info methodInfo = coffiClass.methods[i];
if ((coffiClass.constant_pool[methodInfo.name_index]) == null) {
logger.debug("method index: " + methodInfo.toName(coffiClass.constant_pool));
throw new RuntimeException("method has no name");
}
String methodName = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[methodInfo.name_index])).convert();
String methodDescriptor = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[methodInfo.descriptor_index])).convert();
List<Type> parameterTypes;
Type returnType;
// Generate parameterTypes & returnType
{
Type[] types = jimpleTypesOfFieldOrMethodDescriptor(methodDescriptor);
parameterTypes = new ArrayList<Type>();
for (int j = 0; j < types.length - 1; j++) {
references.add(types[j]);
parameterTypes.add(types[j]);
}
returnType = types[types.length - 1];
references.add(returnType);
}
int modifiers = methodInfo.access_flags;
SootMethod method;
method = Scene.v().makeSootMethod(methodName, parameterTypes, returnType, modifiers);
bclass.addMethod(method);
methodInfo.jmethod = method;
// add exceptions to method
{
for (int j = 0; j < methodInfo.attributes_count; j++) {
if (methodInfo.attributes[j] instanceof Exception_attribute) {
Exception_attribute exceptions = (Exception_attribute) methodInfo.attributes[j];
for (int k = 0; k < exceptions.number_of_exceptions; k++) {
CONSTANT_Class_info c = (CONSTANT_Class_info) coffiClass.constant_pool[exceptions.exception_index_table[k]];
String exceptionName = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[c.name_index])).convert();
exceptionName = exceptionName.replace('/', '.');
references.add(RefType.v(exceptionName));
method.addExceptionIfAbsent(SootResolver.v().makeClassRef(exceptionName));
}
} else if (methodInfo.attributes[j] instanceof Synthetic_attribute) {
method.addTag(new SyntheticTag());
} else if (methodInfo.attributes[j] instanceof Deprecated_attribute) {
method.addTag(new DeprecatedTag());
} else if (methodInfo.attributes[j] instanceof Signature_attribute) {
int signature_index = ((Signature_attribute) methodInfo.attributes[j]).signature_index;
String generic_sig = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[signature_index])).convert();
method.addTag(new SignatureTag(generic_sig));
} else if (methodInfo.attributes[j] instanceof RuntimeVisibleAnnotations_attribute
|| methodInfo.attributes[j] instanceof RuntimeInvisibleAnnotations_attribute) {
addAnnotationVisibilityAttribute(method, methodInfo.attributes[j], coffiClass, references);
} else if (methodInfo.attributes[j] instanceof RuntimeVisibleParameterAnnotations_attribute
|| methodInfo.attributes[j] instanceof RuntimeInvisibleParameterAnnotations_attribute) {
addAnnotationVisibilityParameterAttribute(method, methodInfo.attributes[j], coffiClass, references);
} else if (methodInfo.attributes[j] instanceof AnnotationDefault_attribute) {
AnnotationDefault_attribute attr = (AnnotationDefault_attribute) methodInfo.attributes[j];
element_value[] input = new element_value[1];
input[0] = attr.default_value;
ArrayList<AnnotationElem> list = createElementTags(1, coffiClass, input);
method.addTag(new AnnotationDefaultTag(list.get(0)));
} else if (methodInfo.attributes[j] instanceof Generic_attribute) {
Generic_attribute attr = (Generic_attribute) methodInfo.attributes[j];
String name = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[attr.attribute_name])).convert();
method.addTag(new GenericAttribute(name, attr.info));
}
}
}
// Go through the constant pool, forcing
// all mentioned classes to be
// resolved.
{
for (int k = 0; k < coffiClass.constant_pool_count; k++) {
if (coffiClass.constant_pool[k] instanceof CONSTANT_Class_info) {
CONSTANT_Class_info c = (CONSTANT_Class_info) coffiClass.constant_pool[k];
String desc = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[c.name_index])).convert();
String name = desc.replace('/', '.');
if (name.startsWith("[")) {
references.add(jimpleTypeOfFieldDescriptor(desc));
} else {
references.add(RefType.v(name));
}
}
if (coffiClass.constant_pool[k] instanceof CONSTANT_Fieldref_info
|| coffiClass.constant_pool[k] instanceof CONSTANT_Methodref_info
|| coffiClass.constant_pool[k] instanceof CONSTANT_InterfaceMethodref_info) {
Type[] types = jimpleTypesOfFieldOrMethodDescriptor(cp_info.getTypeDescr(coffiClass.constant_pool, k));
for (Type element : types) {
references.add(element);
}
}
}
}
}
// Set coffi source of method
for (int i = 0; i < coffiClass.methods_count; i++) {
method_info methodInfo = coffiClass.methods[i];
// methodInfo.jmethod.setSource(coffiClass,
// methodInfo);
methodInfo.jmethod.setSource(new CoffiMethodSource(coffiClass, methodInfo));
}
// Set "SourceFile" attribute tag
for (int i = 0; i < coffiClass.attributes_count; i++) {
if (coffiClass.attributes[i] instanceof SourceFile_attribute) {
SourceFile_attribute attr = (SourceFile_attribute) coffiClass.attributes[i];
String sourceFile = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[attr.sourcefile_index])).convert();
if (sourceFile.indexOf(' ') >= 0) {
logger.debug("" + "Warning: Class " + className + " has invalid SourceFile attribute (will be ignored).");
} else {
bclass.addTag(new SourceFileTag(sourceFile, filePath));
}
}
// Set "InnerClass" attribute tag
else if (coffiClass.attributes[i] instanceof InnerClasses_attribute) {
InnerClasses_attribute attr = (InnerClasses_attribute) coffiClass.attributes[i];
for (int j = 0; j < attr.inner_classes_length; j++) {
inner_class_entry e = attr.inner_classes[j];
String inner = null;
String outer = null;
String name = null;
if (e.inner_class_index != 0) {
int name_index = ((CONSTANT_Class_info) coffiClass.constant_pool[e.inner_class_index]).name_index;
inner = ((CONSTANT_Utf8_info) coffiClass.constant_pool[name_index]).convert();
}
if (e.outer_class_index != 0) {
int name_index = ((CONSTANT_Class_info) coffiClass.constant_pool[e.outer_class_index]).name_index;
outer = ((CONSTANT_Utf8_info) coffiClass.constant_pool[name_index]).convert();
}
if (e.name_index != 0) {
name = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[e.name_index])).convert();
}
bclass.addTag(new InnerClassTag(inner, outer, name, e.access_flags));
}
}
// set synthetic tags
else if (coffiClass.attributes[i] instanceof Synthetic_attribute) {
bclass.addTag(new SyntheticTag());
}
// set deprectaed tags
else if (coffiClass.attributes[i] instanceof Deprecated_attribute) {
bclass.addTag(new DeprecatedTag());
} else if (coffiClass.attributes[i] instanceof Signature_attribute) {
int signature_index = ((Signature_attribute) coffiClass.attributes[i]).signature_index;
String generic_sig = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[signature_index])).convert();
bclass.addTag(new SignatureTag(generic_sig));
} else if (coffiClass.attributes[i] instanceof EnclosingMethod_attribute) {
EnclosingMethod_attribute attr = (EnclosingMethod_attribute) coffiClass.attributes[i];
int name_index = ((CONSTANT_Class_info) coffiClass.constant_pool[attr.class_index]).name_index;
String class_name = ((CONSTANT_Utf8_info) coffiClass.constant_pool[name_index]).convert();
CONSTANT_NameAndType_info info = (CONSTANT_NameAndType_info) coffiClass.constant_pool[attr.method_index];
String method_name = "";
String method_sig = "";
if (info != null) {
method_name = ((CONSTANT_Utf8_info) coffiClass.constant_pool[info.name_index]).convert();
method_sig = ((CONSTANT_Utf8_info) coffiClass.constant_pool[info.descriptor_index]).convert();
}
bclass.addTag(new EnclosingMethodTag(class_name, method_name, method_sig));
} else if (coffiClass.attributes[i] instanceof RuntimeVisibleAnnotations_attribute
|| coffiClass.attributes[i] instanceof RuntimeInvisibleAnnotations_attribute) {
addAnnotationVisibilityAttribute(bclass, coffiClass.attributes[i], coffiClass, references);
} else if (coffiClass.attributes[i] instanceof Generic_attribute) {
Generic_attribute attr = (Generic_attribute) coffiClass.attributes[i];
String name = ((CONSTANT_Utf8_info) (coffiClass.constant_pool[attr.attribute_name])).convert();
bclass.addTag(new GenericAttribute(name, attr.info));
}
}
}
Type jimpleReturnTypeOfMethodDescriptor(String descriptor) {
Type[] types = jimpleTypesOfFieldOrMethodDescriptor(descriptor);
return types[types.length - 1];
}
private final ArrayList<Type> conversionTypes = new ArrayList<Type>();
/*
* private Map cache = new HashMap(); public Type[] jimpleTypesOfFieldOrMethodDescriptor( String descriptor) { Type[] ret =
* (Type[]) cache.get(descriptor); if( ret != null ) return ret; conversionTypes.clear();
*
* while(descriptor.length() != 0) { boolean isArray = false; int numDimensions = 0; Type baseType;
*
* // Skip parenthesis if(descriptor.startsWith("(") || descriptor.startsWith(")")) { descriptor = descriptor.substring(1);
* continue; }
*
* // Handle array case while(descriptor.startsWith("[")) { isArray = true; numDimensions++; descriptor =
* descriptor.substring(1); }
*
* // Determine base type if(descriptor.startsWith("B")) { baseType = ByteType.v(); descriptor = descriptor.substring(1); }
* else if(descriptor.startsWith("C")) { baseType = CharType.v(); descriptor = descriptor.substring(1); } else
* if(descriptor.startsWith("D")) { baseType = DoubleType.v(); descriptor = descriptor.substring(1); } else
* if(descriptor.startsWith("F")) { baseType = FloatType.v(); descriptor = descriptor.substring(1); } else
* if(descriptor.startsWith("I")) { baseType = IntType.v(); descriptor = descriptor.substring(1); } else
* if(descriptor.startsWith("J")) { baseType = LongType.v(); descriptor = descriptor.substring(1); } else
* if(descriptor.startsWith("L")) { int index = descriptor.indexOf(';');
*
* if(index == -1) throw new RuntimeException("Class reference has no ending ;" );
*
* String className = descriptor.substring(1, index);
*
* baseType = RefType.v(className.replace('/', '.'));
*
* descriptor = descriptor.substring(index + 1); } else if(descriptor.startsWith("S")) { baseType = ShortType.v();
* descriptor = descriptor.substring(1); } else if(descriptor.startsWith("Z")) { baseType = BooleanType.v(); descriptor =
* descriptor.substring(1); } else if(descriptor.startsWith("V")) { baseType = VoidType.v(); descriptor =
* descriptor.substring(1); } else throw new RuntimeException("Unknown field type!" );
*
* Type t;
*
* // Determine type if(isArray) t = ArrayType.v(baseType, numDimensions); else t = baseType;
*
* conversionTypes.add(t); }
*
* ret = (Type[]) conversionTypes.toArray(new Type[0]); cache.put(descriptor, ret); return ret; }
*/
private final Map<String, Type[]> cache = new HashMap<String, Type[]>();
public Type[] jimpleTypesOfFieldOrMethodDescriptor(String descriptor) {
Type[] ret = null;
synchronized (cache) {
ret = cache.get(descriptor);
}
if (ret != null) {
return ret;
}
char[] d = descriptor.toCharArray();
int p = 0;
List<Type> conversionTypes = new ArrayList<Type>();
outer: while (p < d.length) {
boolean isArray = false;
int numDimensions = 0;
Type baseType = null;
swtch: while (p < d.length) {
switch (d[p]) {
// Skip parenthesis
case '(':
case ')':
p++;
continue outer;
case '[':
isArray = true;
numDimensions++;
p++;
continue swtch;
case 'B':
baseType = ByteType.v();
p++;
break swtch;
case 'C':
baseType = CharType.v();
p++;
break swtch;
case 'D':
baseType = DoubleType.v();
p++;
break swtch;
case 'F':
baseType = FloatType.v();
p++;
break swtch;
case 'I':
baseType = IntType.v();
p++;
break swtch;
case 'J':
baseType = LongType.v();
p++;
break swtch;
case 'L':
int index = p + 1;
while (index < d.length && d[index] != ';') {
if (d[index] == '/') {
d[index] = '.';
}
index++;
}
if (index >= d.length) {
throw new RuntimeException("Class reference has no ending ;");
}
String className = new String(d, p + 1, index - p - 1);
baseType = RefType.v(className);
p = index + 1;
break swtch;
case 'S':
baseType = ShortType.v();
p++;
break swtch;
case 'Z':
baseType = BooleanType.v();
p++;
break swtch;
case 'V':
baseType = VoidType.v();
p++;
break swtch;
default:
throw new RuntimeException("Unknown field type!");
}
}
if (baseType == null) {
continue;
}
// Determine type
Type t;
if (isArray) {
t = ArrayType.v(baseType, numDimensions);
} else {
t = baseType;
}
conversionTypes.add(t);
}
ret = conversionTypes.toArray(new Type[0]);
synchronized (cache) {
cache.put(descriptor, ret);
}
return ret;
}
public Type jimpleTypeOfFieldDescriptor(String descriptor) {
// Handle array case
int numDimensions = 0;
while (descriptor.startsWith("[")) {
numDimensions++;
descriptor = descriptor.substring(1);
}
// Determine base type
Type baseType;
if (descriptor.equals("B")) {
baseType = ByteType.v();
} else if (descriptor.equals("C")) {
baseType = CharType.v();
} else if (descriptor.equals("D")) {
baseType = DoubleType.v();
} else if (descriptor.equals("F")) {
baseType = FloatType.v();
} else if (descriptor.equals("I")) {
baseType = IntType.v();
} else if (descriptor.equals("J")) {
baseType = LongType.v();
} else if (descriptor.equals("V")) {
baseType = VoidType.v();
} else if (descriptor.startsWith("L")) {
if (!descriptor.endsWith(";")) {
throw new RuntimeException("Class reference does not end with ;");
}
String className = descriptor.substring(1, descriptor.length() - 1);
baseType = RefType.v(className.replace('/', '.'));
} else if (descriptor.equals("S")) {
baseType = ShortType.v();
} else if (descriptor.equals("Z")) {
baseType = BooleanType.v();
} else {
throw new RuntimeException("Unknown field type: " + descriptor);
}
// Return type
return (numDimensions > 0) ? ArrayType.v(baseType, numDimensions) : baseType;
}
int nextEasyNameIndex;
void resetEasyNames() {
nextEasyNameIndex = 0;
}
String getNextEasyName() {
final String[] easyNames = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
"s", "t", "u", "v", "w", "x", "y", "z" };
int justifiedIndex = nextEasyNameIndex++;
if (justifiedIndex >= easyNames.length) {
return "local" + (justifiedIndex - easyNames.length);
} else {
return easyNames[justifiedIndex];
}
}
Local getLocalForStackOp(JimpleBody listBody, TypeStack typeStack, int index) {
if (typeStack.get(index).equals(Double2ndHalfType.v()) || typeStack.get(index).equals(Long2ndHalfType.v())) {
index--;
}
return getLocalCreatingIfNecessary(listBody, "$stack" + index, UnknownType.v());
}
String getAbbreviationOfClassName(String className) {
StringBuffer buffer = new StringBuffer(new Character(className.charAt(0)).toString());
int periodIndex = 0;
for (;;) {
periodIndex = className.indexOf('.', periodIndex + 1);
if (periodIndex == -1) {
break;
}
buffer.append(Character.toLowerCase(className.charAt(periodIndex + 1)));
}
return buffer.toString();
}
String getNormalizedClassName(String className) {
className = className.replace('/', '.');
if (className.endsWith(";")) {
className = className.substring(0, className.length() - 1);
}
// Handle array case
{
int numDimensions = 0;
while (className.startsWith("[")) {
numDimensions++;
className = className.substring(1, className.length());
className = className + "[]";
}
if (numDimensions != 0) {
if (!className.startsWith("L")) {
throw new RuntimeException("For some reason an array reference does not start with L");
}
className = className.substring(1, className.length());
}
}
return className;
}
private Local getLocalUnsafe(Body b, String name) {
for (Local local : b.getLocals()) {
if (local.getName().equals(name)) {
return local;
}
}
return null;
}
Local getLocalCreatingIfNecessary(JimpleBody listBody, String name, Type type) {
Local l = getLocalUnsafe(listBody, name);
if (l != null) {
if (!l.getType().equals(type)) {
throw new RuntimeException("The body already declares this local name with a different type.");
}
} else {
l = Jimple.v().newLocal(name, type);
listBody.getLocals().add(l);
}
return l;
}
/**
* Get a Local for the parameter at the given local variable index.
*
* @listBody the method body.
* @index the parameter's local variable index.
* @return the Local for the given local variable index.
*/
Local getLocalForParameter(JimpleBody listBody, int index) {
return getLocalForIndex(listBody, index, 0, 0, false);
}
/**
* Get a Local for the local variable at the given index in the context of the given instruction.
*
* @listBody the method body.
* @index the local variable index.
* @context the instruction context.
* @return the Local for the given local variable index.
*/
Local getLocalForIndex(JimpleBody listBody, int index, Instruction context) {
return getLocalForIndex(listBody, index, context.originalIndex, context.nextOffset(context.originalIndex),
ByteCode.isLocalStore(context.code));
}
private Local getLocalForIndex(JimpleBody listBody, int index, int bcIndex, int nextBcIndex, boolean isLocalStore) {
String name = null;
Local local;
if (useFaithfulNaming && activeVariableTable != null) {
/*
* [use-original-names]
*
* Use original variables names. Generally speeking, the current way of handling original variables names is sound if
* the local variable table is consistant with the source code.
*
* consistant(table) ==> sound(local for index)
*
* In the table, variables are tuples ((s,l),i,N) where (s,l) encodes the half-open bytecode index interval [s,s+l[, i
* is the local variable index and N is the original variable name. ((s,l),i,N) means "from bytecode index s included
* to bytecode index s+l excluded, the variable at index i is named N is the source code".
*
* However the content of the table is for informational and debugging purpose only, the compiler can insert whatever
* inconsistancies it may want, meaning we cannot trust the table.
*
* The most common inconsistancy we found so far is where variables with different indexes and overlapping bytecode
* ranges are given the same name in the table. Although it won't happen with user-defined variables since Java doesn't
* allow the same variable name to be declared in nested scopes. But this situation can arise for compiler-generated
* local variables if they are assigned the same name (`i$` is common in OpenJDK). Notable example are local variables
* generated to implement the Java for-each statement (for(Foo foo : bar){}). If the source code contains nested
* for-each statements, then it becomes ugly because all the generated iterators or counters (for-each on arrays) are
* assigned the same name in the table.
*
* This inconsistancy is now handled correctly by the following code. The idea is based on the observation that the
* Local allocation works well if we simply allocate a different Local object for each local variable index (it is the
* default allocation policy, when the original names are not kept). Therefore, local variables with the same name and
* same index should have the same Local object. And local variables with the same name but different index should have
* a different Local object. We maintain the map nameToIndexToLocal :: Name -> (Index -> Local Object) from variable
* names to maps from variable indexes to Local objects. So we allocate a new Local object for each pair of a variable
* name and a variable index.
*
* Unfortunately, this is still unsound if the table gives several names for the same variable of the source code. Or
* if it reports wrong bytecode ranges, or if it doesn't report the name of a variable everywhere it is used in the
* bytecode...
*
* In order to obtain sound Local allocation when taking original names into account... we should not allocate Local
* according to these names. Instead we must keep the default allocation policy (one Local object for each local
* variable index), and then annotate each statement with "most probable name(s)" for each use or def Local.
*
*/
if (bcIndex != -1) {
int lookupBcIndex = bcIndex;
/*
* For local store bytecode, the local actually takes its new value after the bytecode is executed, so we must look
* at the next bytecode index. This is the behavior observed at least with OpenJDK javac.
*/
if (isLocalStore) {
lookupBcIndex = nextBcIndex;
}
name = activeVariableTable.getLocalVariableName(activeConstantPool, index, lookupBcIndex);
/*
* // for debug purpose String desc = activeVariableTable. getLocalVariableDescriptor( activeConstantPool, index,
* activeOriginalIndex); if (activeVariableTypeTable != null){ String debug_type = activeVariableTypeTable.
* getLocalVariableType( activeConstantPool, index, activeOriginalIndex); }
*/
}
}
if (name == null) {
name = "l" + index; // generate a default name for the local
}
if (nameToIndexToLocal == null) {
nameToIndexToLocal = new HashMap<String, Map<Integer, Local>>();
}
Map<Integer, Local> indexToLocal;
if (!nameToIndexToLocal.containsKey(name)) {
indexToLocal = new HashMap<Integer, Local>();
nameToIndexToLocal.put(name, indexToLocal);
} else {
indexToLocal = nameToIndexToLocal.get(name);
}
if (indexToLocal.containsKey(index)) {
local = indexToLocal.get(index);
} else {
local = Jimple.v().newLocal(name, UnknownType.v());
listBody.getLocals().add(local);
indexToLocal.put(index, local);
}
return local;
}
/*
* void setLocalType(Local local, List locals, int localIndex, Type type) { if(local.getType().equals(UnknownType .v()) ||
* local.getType().equals(type)) { local.setType(type);
*
* if(local.getType().equals(DoubleType. v()) || local.getType().equals(LongType.v())) { // This means the next local
* becomes voided, since these types occupy two // words.
*
* Local secondHalf = (Local) locals.get(localIndex + 1);
*
* secondHalf.setType(VoidType.v()); }
*
* return; }
*
* if(type.equals(IntType.v())) { if(local.getType().equals(BooleanType .v()) || local.getType().equals(CharType.v()) ||
* local.getType().equals(ShortType.v()) || local.getType().equals(ByteType.v())) { // Even though it's not the same, it's
* ok, because booleans, chars, shorts, and // bytes are all sort of treated like integers by the JVM. return; }
*
* }
*
* throw new RuntimeException("required and actual types do not match: " + type.toString() + " with " +
* local.getType().toString()); }
*/
/**
* Verifies the prospective name for validity as a Jimple name. In particular, first-char is alpha | _ | $,
* subsequent-chars are alphanum | _ | $.
*
* We could use isJavaIdentifier, except that Jimple's grammar doesn't support all of those, just ASCII.
*
* I'd put this in soot.Local, but that's an interface.
*
* @author Patrick Lam
*/
boolean isValidJimpleName(String prospectiveName) {
if (prospectiveName == null) {
return false;
}
for (int i = 0; i < prospectiveName.length(); i++) {
char c = prospectiveName.charAt(i);
if (i == 0 && c >= '0' && c <= '9') {
return false;
}
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_' || c == '$'))) {
return false;
}
}
return true;
}
private void addAnnotationVisibilityAttribute(Host host, attribute_info attribute, ClassFile coffiClass,
Collection<Type> references) {
VisibilityAnnotationTag tag;
if (attribute instanceof RuntimeVisibleAnnotations_attribute) {
tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE);
RuntimeVisibleAnnotations_attribute attr = (RuntimeVisibleAnnotations_attribute) attribute;
addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references);
} else {
tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE);
RuntimeInvisibleAnnotations_attribute attr = (RuntimeInvisibleAnnotations_attribute) attribute;
addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references);
}
host.addTag(tag);
}
private void addAnnotationVisibilityParameterAttribute(Host host, attribute_info attribute, ClassFile coffiClass,
Collection<Type> references) {
VisibilityParameterAnnotationTag tag;
if (attribute instanceof RuntimeVisibleParameterAnnotations_attribute) {
RuntimeVisibleParameterAnnotations_attribute attr = (RuntimeVisibleParameterAnnotations_attribute) attribute;
tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_VISIBLE);
for (int i = 0; i < attr.num_parameters; i++) {
parameter_annotation pAnnot = attr.parameter_annotations[i];
VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE);
addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references);
tag.addVisibilityAnnotation(vTag);
}
} else {
RuntimeInvisibleParameterAnnotations_attribute attr = (RuntimeInvisibleParameterAnnotations_attribute) attribute;
tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_INVISIBLE);
for (int i = 0; i < attr.num_parameters; i++) {
parameter_annotation pAnnot = attr.parameter_annotations[i];
VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE);
addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references);
tag.addVisibilityAnnotation(vTag);
}
}
host.addTag(tag);
}
private void addAnnotations(int numAnnots, annotation[] annotations, ClassFile coffiClass, VisibilityAnnotationTag tag,
Collection<Type> references) {
for (int i = 0; i < numAnnots; i++) {
annotation annot = annotations[i];
String annotType = ((CONSTANT_Utf8_info) coffiClass.constant_pool[annot.type_index]).convert();
String ref = annotType.substring(1, annotType.length() - 1);
ref = ref.replace('/', '.');
references.add(RefType.v(ref));
AnnotationTag annotTag = new AnnotationTag(annotType,
createElementTags(annot.num_element_value_pairs, coffiClass, annot.element_value_pairs));
tag.addAnnotation(annotTag);
}
}
private ArrayList<AnnotationElem> createElementTags(int count, ClassFile coffiClass, element_value[] elems) {
ArrayList<AnnotationElem> list = new ArrayList<AnnotationElem>();
for (int j = 0; j < count; j++) {
element_value ev = elems[j];
char kind = ev.tag;
String elemName = "default";
if (ev.name_index != 0) {
elemName = ((CONSTANT_Utf8_info) coffiClass.constant_pool[ev.name_index]).convert();
}
if (kind == 'B' || kind == 'C' || kind == 'I' || kind == 'S' || kind == 'Z' || kind == 'D' || kind == 'F'
|| kind == 'J' || kind == 's') {
constant_element_value cev = (constant_element_value) ev;
if (kind == 'B' || kind == 'C' || kind == 'I' || kind == 'S' || kind == 'Z') {
cp_info cval = coffiClass.constant_pool[cev.constant_value_index];
int constant_val = (int) ((CONSTANT_Integer_info) cval).bytes;
AnnotationIntElem elem = new AnnotationIntElem(constant_val, kind, elemName);
list.add(elem);
} else if (kind == 'D') {
cp_info cval = coffiClass.constant_pool[cev.constant_value_index];
double constant_val = ((CONSTANT_Double_info) cval).convert();
AnnotationDoubleElem elem = new AnnotationDoubleElem(constant_val, kind, elemName);
list.add(elem);
} else if (kind == 'F') {
cp_info cval = coffiClass.constant_pool[cev.constant_value_index];
float constant_val = ((CONSTANT_Float_info) cval).convert();
AnnotationFloatElem elem = new AnnotationFloatElem(constant_val, kind, elemName);
list.add(elem);
} else if (kind == 'J') {
cp_info cval = coffiClass.constant_pool[cev.constant_value_index];
CONSTANT_Long_info lcval = (CONSTANT_Long_info) cval;
long constant_val = (lcval.high << 32) + lcval.low;
AnnotationLongElem elem = new AnnotationLongElem(constant_val, kind, elemName);
list.add(elem);
} else if (kind == 's') {
cp_info cval = coffiClass.constant_pool[cev.constant_value_index];
String constant_val = ((CONSTANT_Utf8_info) cval).convert();
AnnotationStringElem elem = new AnnotationStringElem(constant_val, kind, elemName);
list.add(elem);
}
} else if (kind == 'e') {
enum_constant_element_value ecev = (enum_constant_element_value) ev;
cp_info type_val = coffiClass.constant_pool[ecev.type_name_index];
String type_name = ((CONSTANT_Utf8_info) type_val).convert();
cp_info name_val = coffiClass.constant_pool[ecev.constant_name_index];
String constant_name = ((CONSTANT_Utf8_info) name_val).convert();
AnnotationEnumElem elem = new AnnotationEnumElem(type_name, constant_name, kind, elemName);
list.add(elem);
} else if (kind == 'c') {
class_element_value cev = (class_element_value) ev;
cp_info cval = coffiClass.constant_pool[cev.class_info_index];
CONSTANT_Utf8_info sval = (CONSTANT_Utf8_info) cval;
String desc = sval.convert();
AnnotationClassElem elem = new AnnotationClassElem(desc, kind, elemName);
list.add(elem);
} else if (kind == '[') {
array_element_value aev = (array_element_value) ev;
int num_vals = aev.num_values;
ArrayList<AnnotationElem> elemVals = createElementTags(num_vals, coffiClass, aev.values);
AnnotationArrayElem elem = new AnnotationArrayElem(elemVals, kind, elemName);
list.add(elem);
} else if (kind == '@') {
annotation_element_value aev = (annotation_element_value) ev;
annotation annot = aev.annotation_value;
String annotType = ((CONSTANT_Utf8_info) coffiClass.constant_pool[annot.type_index]).convert();
AnnotationTag annotTag = new AnnotationTag(annotType,
createElementTags(annot.num_element_value_pairs, coffiClass, annot.element_value_pairs));
AnnotationAnnotationElem elem = new AnnotationAnnotationElem(annotTag, kind, elemName);
list.add(elem);
}
}
return list;
}
}
| 43,909
| 39.922647
| 125
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/annotation.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be many annotations in each Visibility attribute
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class annotation extends attribute_info {
/** type_index - CONSTANT_Utf8_info structure constant pool entry. */
public int type_index;
/** num_element_value_pairs */
public int num_element_value_pairs;
/**
* Each entry represents a single runtime visible annotation.
*/
public element_value element_value_pairs[];
}
| 1,286
| 30.390244
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/annotation_element_value.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be many element_value pairs in each annotation
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class annotation_element_value extends element_value {
annotation annotation_value;
}
| 1,038
| 29.558824
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/array_element_value.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be many element_value pairs in each annotation
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class array_element_value extends element_value {
int num_values;
element_value values[];
}
| 1,046
| 28.914286
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/attribute_info.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Generic superclass for all attributes.
*
* @author Clark Verbrugge
*/
class attribute_info {
/**
* String by which a SourceFile attribute is recognized.
*
* @see SourceFile_attribute
*/
public static final String SourceFile = "SourceFile";
/**
* String by which a ConstantValue attribute is recognized.
*
* @see ConstantValue_attribute
*/
public static final String ConstantValue = "ConstantValue";
/**
* String by which a Code attribute is recognized.
*
* @see Code_attribute
*/
public static final String Code = "Code";
/**
* String by which an Exceptions attribute is recognized.
*
* @see Exception_attribute
*/
public static final String Exceptions = "Exceptions";
/**
* String by which a LineNumberTable attribute is recognized.
*
* @see LineNumberTable_attribute
*/
public static final String LineNumberTable = "LineNumberTable";
/**
* String by which a LocalVariableTable attribute is recognized.
*
* @see LocalVariableTable_attribute
*/
public static final String LocalVariableTable = "LocalVariableTable";
/**
* String by which a InnerClasses attribute is recognized.
*
* @see InnerClasses_attribute
*/
public static final String InnerClasses = "InnerClasses";
/**
* String by which a Synthetic attribute is recognized.
*
* @see Synthetic_attribute
*/
public static final String Synthetic = "Synthetic";
/**
* String by which a BootstrapMethods attribute is recognized.
*
* @see BootstrapMethods_attribute
*/
public static final String BootstrapMethods = "BootstrapMethods";
/**
* the following tags are added for java1.5
*/
/**
* String by which a Synthetic attribute is recognized.
*
* @see Signature_attribute
*/
public static final String Signature = "Signature";
/**
* String by which a Deprecated attribute is recognized.
*
* @see Deprecated_attribute
*/
public static final String Deprecated = "Deprecated";
/**
* String by which a EnclosingMethod attribute is recognized.
*
* @see EnclosingMethod_attribute
*/
public static final String EnclosingMethod = "EnclosingMethod";
/**
* String by which a LocalVariableTypeTable attribute is recognized.
*
* @see LocalVariableTypeTable_attribute
*/
public static final String LocalVariableTypeTable = "LocalVariableTypeTable";
/**
* String by which a runtime visible annotation attribute is recognized.
*
* @see RuntimeVisibleAnnotations_attribute
*/
public static final String RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations";
/**
* String by which a runtime invisible annotation attribute is recognized.
*
* @see RuntimeInvisibleAnnotations_attribute
*/
public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
/**
* String by which a runtime visible parameter annotation attribute is recognized.
*
* @see RuntimeVisibleParameterAnnotations_attribute
*/
public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
/**
* String by which a runtime invisible parameter annotation attribute is recognized.
*
* @see RuntimeInvisibleParameterAnnotations_attribute
*/
public static final String RuntimeInvisibleParameterAnnotations = "RuntimeInvisibleParameterAnnotations";
/**
* String by which an annotation default attribute is recognized.
*
* @see AnnotationDefault_attribute
*/
public static final String AnnotationDefault = "AnnotationDefault";
/**
* Constant pool index of the name of this attribute; should be a utf8 String matching one of the constant Strings define
* here.
*
* @see attribute_info#SourceFile
* @see attribute_info#ConstantValue
* @see attribute_info#Code
* @see attribute_info#Exceptions
* @see attribute_info#LineNumberTable
* @see attribute_info#LocalVariableTable
* @see attribute_info#InnerClasses
* @see CONSTANT_Utf8_info
*/
public int attribute_name;
/** Length of attribute in bytes. */
public long attribute_length;
}
| 4,970
| 28.241176
| 123
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/class_element_value.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be many element_value pairs in each annotation
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class class_element_value extends element_value {
int class_info_index;
}
| 1,026
| 29.205882
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/constant_element_value.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be many element_value pairs in each annotation
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class constant_element_value extends element_value {
int constant_value_index;
}
| 1,033
| 29.411765
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/cp_info.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.StringTokenizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import soot.Value;
/**
* Base abstract class for constant pool entries; includes some utility methods.
*
* @see ClassFile#constant_pool
* @author Clark Verbrugge
*/
abstract class cp_info {
private static final Logger logger = LoggerFactory.getLogger(cp_info.class);
public static final byte CONSTANT_Utf8 = 1;
public static final byte CONSTANT_Integer = 3;
public static final byte CONSTANT_Float = 4;
public static final byte CONSTANT_Long = 5;
public static final byte CONSTANT_Double = 6;
public static final byte CONSTANT_Class = 7;
public static final byte CONSTANT_String = 8;
public static final byte CONSTANT_Fieldref = 9;
public static final byte CONSTANT_Methodref = 10;
public static final byte CONSTANT_InterfaceMethodref = 11;
public static final byte CONSTANT_NameAndType = 12;
public static final byte CONSTANT_MethodHandle = 15;
public static final byte CONSTANT_MethodType = 16; // TODO
public static final byte CONSTANT_InvokeDynamic = 18;
/* constants for method handle kinds */
public static final byte REF_getField = 1;
public static final byte REF_getStatic = 2;
public static final byte REF_putField = 3;
public static final byte REF_putStatic = 4;
public static final byte REF_invokeVirtual = 5;
public static final byte REF_invokeStatic = 6;
public static final byte REF_invokeSpecial = 7;
public static final byte REF_newInvokeSpecial = 8;
public static final byte REF_invokeInterface = 9;
// mapping from the above to the kinds of members they refer to
public static final byte[] REF_TO_CONSTANT = { -1, CONSTANT_Fieldref, // getField...
CONSTANT_Fieldref, //
CONSTANT_Fieldref, //
CONSTANT_Fieldref, //
CONSTANT_Methodref, // invokeVirtual...
CONSTANT_Methodref, CONSTANT_Methodref, CONSTANT_Methodref, CONSTANT_InterfaceMethodref,// invokeInterface
};
/** One of the CONSTANT_* constants. */
public byte tag;
/**
* Returns the size of this entry.
*
* @return size (in bytes) of this entry.
*/
public abstract int size();
/**
* Returns a String representation of this entry.
*
* @param constant_pool
* constant pool of ClassFile.
* @return String representation of this entry.
*/
public abstract String toString(cp_info constant_pool[]);
/**
* Returns a String description of what kind of entry this is.
*
* @return String representation of this kind of entry.
*/
public abstract String typeName();
/**
* Compares this entry with another cp_info object (which may reside in a different constant pool).
*
* @param constant_pool
* constant pool of ClassFile for this.
* @param cp
* constant pool entry to compare against.
* @param cp_constant_pool
* constant pool of ClassFile for cp.
* @return a value <0, 0, or >0 indicating whether this is smaller, the same or larger than cp.
*/
public abstract int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]);
/**
* Utility method, converts two integers into a single long.
*
* @param high
* upper 32 bits of the long.
* @param low
* lower 32 bits of the long.
* @return a long value composed from the two ints.
*/
public static long ints2long(long high, long low) {
long h, l;
h = high;
l = low;
return ((h << 32) + l);
}
/**
* Utility method, returns a String binary representation of the given integer.
*
* @param i
* the integer in question.
* @return a String of 0's and 1's.
* @see cp_info#printBits(long)
*/
public static String printBits(int i) {
String s = "";
int j, k;
k = 1;
for (j = 0; j < 32; j++) {
if ((i & k) != 0) {
s = "1" + s;
} else {
s = "0" + s;
}
k = k << 1;
}
return s;
}
/**
* Utility method, returns a String binary representation of the given long.
*
* @param i
* the long in question.
* @return a String of 0's and 1's.
* @see cp_info#printBits(int)
*/
public static String printBits(long i) {
String s = "";
long j, k;
k = 1;
for (j = 0; j < 64; j++) {
if ((i & k) != 0) {
s = "1" + s;
} else {
s = "0" + s;
}
k = k << 1;
}
return s;
}
/**
* Locates the name of the corresponding class, given the constant pool index of either a CONSTANT_Class, _Fieldref,
* Methodref or InterfaceMethodref.
*
* @param constant_pool
* constant pool of ClassFile.
* @param i
* index of cp_info entry in question.
* @return name of the associated class.
*/
public static String getClassname(cp_info constant_pool[], int i) {
cp_info c = constant_pool[i];
switch (c.tag) {
case cp_info.CONSTANT_Class:
return c.toString(constant_pool);
case cp_info.CONSTANT_Fieldref:
return getClassname(constant_pool, ((CONSTANT_Fieldref_info) c).class_index);
case cp_info.CONSTANT_Methodref:
return getClassname(constant_pool, ((CONSTANT_Methodref_info) c).class_index);
case cp_info.CONSTANT_InterfaceMethodref:
return getClassname(constant_pool, ((CONSTANT_InterfaceMethodref_info) c).class_index);
}
logger.debug("Request for classname for non-class object!");
return "Can't find classname. Sorry.";
}
/**
* Returns the name of the given constant pool object, assuming it is of type CONSTANT_NameAndType, _FieldRef, _Methodref
* or _InterfaceMethodref.
*
* @param constant_pool
* constant pool of ClassFile.
* @param i
* index of cp_info entry in question.
* @return name of the associated object.
* @see CONSTANT_Utf8_info
*/
public static String getName(cp_info constant_pool[], int i) {
cp_info c = constant_pool[i];
switch (c.tag) {
case cp_info.CONSTANT_Utf8:
return c.toString(constant_pool);
case cp_info.CONSTANT_NameAndType:
return getName(constant_pool, ((CONSTANT_NameAndType_info) c).name_index);
case cp_info.CONSTANT_Fieldref:
return getName(constant_pool, ((CONSTANT_Fieldref_info) c).name_and_type_index);
case cp_info.CONSTANT_Methodref:
return getName(constant_pool, ((CONSTANT_Methodref_info) c).name_and_type_index);
case cp_info.CONSTANT_InterfaceMethodref:
return getName(constant_pool, ((CONSTANT_InterfaceMethodref_info) c).name_and_type_index);
}
logger.debug("Request for name for non-named object!");
return "Can't find name of that object. Sorry.";
}
/**
* Counts the number of parameters of the given method.
*
* @param constant_pool
* constant pool of ClassFile.
* @param m
* a constant pool index as accepted by getTypeDescr.
* @return the number of parameters.
* @see cp_info#getTypeDescr
*/
public static int countParams(cp_info constant_pool[], int m) {
StringTokenizer st;
String s = getTypeDescr(constant_pool, m);
s = ClassFile.parseMethodDesc_params(s);
st = new StringTokenizer(s, ",", false);
return st.countTokens();
}
/**
* Returns the type descriptor for the given constant pool object, which must be a CONSTANT_Utf8, CONSTANT_NameAndType,
* CONSTANT_Fieldref, CONSTANT_MethodRef, or CONSTANT_InterfaceMethodRef.
*
* @param constant_pool
* constant pool of ClassFile.
* @param i
* a constant pool index for an entry of type CONSTANT_Utf8, CONSTANT_NameAndType, CONSTANT_MethodRef, or
* CONSTANT_InterfaceMethodRef.
* @return the type descriptor.
* @see CONSTANT_Utf8_info
*/
public static String getTypeDescr(cp_info constant_pool[], int i) {
cp_info c = constant_pool[i];
if (c instanceof CONSTANT_Utf8_info) {
return c.toString(constant_pool);
}
if (c instanceof CONSTANT_NameAndType_info) {
return getTypeDescr(constant_pool, ((CONSTANT_NameAndType_info) c).descriptor_index);
}
if (c instanceof CONSTANT_Methodref_info) {
return getTypeDescr(constant_pool, ((CONSTANT_Methodref_info) c).name_and_type_index);
}
if (c instanceof CONSTANT_InterfaceMethodref_info) {
return getTypeDescr(constant_pool, ((CONSTANT_InterfaceMethodref_info) c).name_and_type_index);
}
if (c instanceof CONSTANT_Fieldref_info) {
return getTypeDescr(constant_pool, ((CONSTANT_Fieldref_info) c).name_and_type_index);
}
logger.debug("Invalid request for type descr!");
return "Invalid type descriptor request.";
}
/**
* Returns the name of the field type of the given constant pool object.
*
* @param constant_pool
* constant pool of ClassFile.
* @param i
* a constant pool index for an entry of type CONSTANT_Utf8, CONSTANT_NameAndType, or CONSTANT_FieldRef.
* @return the type of the field.
* @see CONSTANT_Utf8_info
* @see cp_info#getTypeDescr
*/
public static String fieldType(cp_info constant_pool[], int i) {
return ClassFile.parseDesc(getTypeDescr(constant_pool, i), "");
}
/**
* Creates an appropriate jimple representation of this constant. Field and method constants are assumed to point to static
* fields/methods.
*/
public abstract Value createJimpleConstantValue(cp_info[] constant_pool);
}
| 10,297
| 32.875
| 125
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/element_value.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be many element_value pairs in each annotation
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class element_value extends attribute_info {
int name_index;
char tag;
}
| 1,027
| 28.371429
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/enum_constant_element_value.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be many element_value pairs in each annotation
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class enum_constant_element_value extends element_value {
int type_name_index;
int constant_name_index;
}
| 1,060
| 29.314286
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/exception_table_entry.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* An entry in some code's exception table; describes an exception handler and the code it protects.
*
* @see Code_attribute
* @author Clark Verbrugge
*/
class exception_table_entry {
/**
* Code offset of start of code protected by this handler (inclusive).
*
* @see exception_table_entry#start_inst
*/
public int start_pc;
/**
* Code offset of end of code protected by this handler (exclusive).
*
* @see exception_table_entry#end_inst
*/
public int end_pc;
/**
* Code offset of actual exception handler for the specified code block.
*
* @see exception_table_entry#handler_inst
* @see exception_table_entry#b
*/
public int handler_pc;
/**
* Constant pool index of a CONSTANT_Class entry describing the exception this handler handles; if 0, this handler catches
* all exceptions.
*
* @see CONSTANT_Class
*/
public int catch_type;
/**
* First Instruction object (after parsing) of code protected by this handler.
*
* @see exception_table_entry#start_pc
* @see Instruction
*/
public Instruction start_inst;
/**
* First Instruction object (after parsing) of code not protected by this handler (or <i>null</i> for the end of code).
*
* @see exception_table_entry#end_pc
* @see Instruction
*/
public Instruction end_inst;
/**
* Instruction object (after parsing) of start of handler code.
*
* @see exception_table_entry#handler_pc
* @see Instruction
*/
public Instruction handler_inst;
/**
* Once basic blocks are constructed, the handler can be found by referencing its basic block.
*
* @see BasicBlock
*/
public BasicBlock b;
}
| 2,496
| 28.034884
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/field_info.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* Represents a single field_info object.
*
* @see ClassFile
* @author Clark Verbrugge
*/
public class field_info {
/** Access flags for this field. */
public int access_flags;
/**
* Constant pool index of the name of this field.
*
* @see ClassFile#constant_pool
* @see CONSTANT_Utf8_info
*/
public int name_index;
/**
* Constant pool index of the type descriptor of this field.
*
* @see ClassFile#constant_pool
* @see CONSTANT_Utf8_info
*/
public int descriptor_index;
/** Count of attributes this field contains. */
public int attributes_count;
/**
* Array of attribute_info objects for this field.
*
* @see attribute_info
*/
public attribute_info attributes[];
/**
* Returns the name of this field.
*
* @param constant_pool
* the constant_pool for this class.
* @return the name of this field.
*/
public String toName(cp_info constant_pool[]) {
CONSTANT_Utf8_info ci;
ci = (CONSTANT_Utf8_info) (constant_pool[name_index]);
return ci.convert();
}
/**
* Returns the prototype of this field.
*
* @param constant_pool
* the constant_pool for this class.
* @return the prototype (access + type + name) of this field.
*/
public String prototype(cp_info constant_pool[]) {
CONSTANT_Utf8_info cm, dm;
String s;
cm = (CONSTANT_Utf8_info) (constant_pool[name_index]);
dm = (CONSTANT_Utf8_info) (constant_pool[descriptor_index]);
s = ClassFile.access_string(access_flags, " ");
if (s.compareTo("") != 0) {
s = s + " ";
}
return s + ClassFile.parseDesc(dm.convert(), "") + " " + cm.convert();
}
/**
* Locates a constant value attribute if one exists.
*
* @return the constant value attribute or <i>null</i>.
* @see ConstantValue_attribute
*/
public ConstantValue_attribute findConstantValue_attribute() {
int i;
for (i = 0; i < attributes_count; i++) {
if ((attributes[i]) instanceof ConstantValue_attribute) {
return (ConstantValue_attribute) (attributes[i]);
}
}
return null;
}
}
| 2,949
| 26.570093
| 74
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/inner_class_entry.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2004 Archie L. Cobbs
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* An entry in the inner classes table.
*
* @see InnerClasses_attribute
* @author Archie L. Cobbs
*/
class inner_class_entry {
/** Constant pool index for the inner class name */
public int inner_class_index;
/** Constant pool index for the outer class name */
public int outer_class_index;
/** Short name for the inner class if any, otherwise zero */
public int name_index;
/** Access flags for inner class */
public int access_flags;
}
| 1,284
| 30.341463
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/line_number_table_entry.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* An entry in the line number table.
*
* @see LineNumberTable_attribute
* @author Clark Verbrugge
*/
class line_number_table_entry {
/** Offset within bytecode of the start of the code for this line number. */
public int start_pc;
/** Line number within the source code. */
public int line_number;
/** Start instruction corresponding to start_pc */
public Instruction start_inst;
}
| 1,225
| 30.435897
| 78
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/local_variable_table_entry.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* An entry in a local variable table.
*
* @see LocalVariableTable_attribute
* @author Clark Verbrugge
*/
class local_variable_table_entry {
/** Code offset of start of code wherein this entry applies. */
public int start_pc;
/** Length of code sequence in which this name applies. */
public int length;
/**
* Constant pool index of string giving this local variable's name.
*
* @see CONSTANT_Utf8_info
*/
public int name_index;
/**
* Constant pool index of string giving this local variable's type descriptor.
*
* @see CONSTANT_Utf8_info
*/
public int descriptor_index;
/** The index in the local variable array of this local variable. */
public int index;
public String toString() {
return "start: " + start_pc + "length: " + length + "name_index: " + name_index + "descriptor_index: " + descriptor_index
+ "index: " + index;
}
}
| 1,723
| 29.245614
| 125
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/local_variable_type_table_entry.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* An entry in a local variable type table.
*
* @see LocalVariableTypeTable_attribute
* @author Jennifer Lhotak based on local_variabl_table_entry
*/
class local_variable_type_table_entry {
/** Code offset of start of code wherein this entry applies. */
public int start_pc;
/** Length of code sequence in which this name applies. */
public int length;
/**
* Constant pool index of string giving this local variable's name.
*
* @see CONSTANT_Utf8_info
*/
public int name_index;
/**
* Constant pool index of string giving this local variable's signature
*
* @see CONSTANT_Utf8_info
*/
public int signature_index;
/** The index in the local variable array of this local variable. */
public int index;
public String toString() {
return "start: " + start_pc + "length: " + length + "name_index: " + name_index + "signature_index: " + signature_index
+ "index: " + index;
}
}
| 1,762
| 29.929825
| 123
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/method_info.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 Clark Verbrugge
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Represents a single method_info object.
*
* @see ClassFile
* @author Clark Verbrugge
*/
public class method_info {
private static final Logger logger = LoggerFactory.getLogger(method_info.class);
/** Access flags for this field. */
public int access_flags;
/**
* Constant pool index of the name of this method.
*
* @see ClassFile#constant_pool
* @see CONSTANT_Utf8_info
*/
public int name_index;
/**
* Constant pool index of the type descriptor of this method.
*
* @see ClassFile#constant_pool
* @see CONSTANT_Utf8_info
*/
public int descriptor_index;
/** Count of attributes this method contains. */
public int attributes_count;
/**
* Array of attribute_info objects for this method.
*
* @see attribute_info
*/
public attribute_info attributes[];
/**
* A shortcut into attributes array for Code_attribute
*
* @see Code_attribute
*/
public Code_attribute code_attr;
/**
* List of Instructions constructed when the method is parsed.
*
* @see Instruction
*/
public Instruction instructions;
/**
* Control Flow Graph constructed when the method is parsed.
*
* @see CFG
*/
public CFG cfg;
public soot.SootMethod jmethod;
List instructionList;
/**
* Returns the name of this method.
*
* @param constant_pool
* the constant_pool for this class.
* @return the name of this method.
*/
public String toName(cp_info constant_pool[]) {
CONSTANT_Utf8_info ci;
ci = (CONSTANT_Utf8_info) (constant_pool[name_index]);
return ci.convert();
}
/**
* Locates and returns the code attribute for this method.
*
* @return the single code attribute, or null if not found.
* @see Code_attribute
*/
Code_attribute locate_code_attribute() {
attribute_info ai;
int i;
for (i = 0; i < attributes_count; i++) {
ai = attributes[i];
if (ai instanceof Code_attribute) {
return (Code_attribute) ai;
}
}
return null;
}
/**
* Returns the prototype of this field.
*
* @param constant_pool
* the constant_pool for this class.
* @return the prototype (access + return + name + parameters) of this method.
*/
public String prototype(cp_info constant_pool[]) {
String access, rt, name, params;
Code_attribute c = locate_code_attribute();
access = ClassFile.access_string(access_flags, " ");
rt = ClassFile.parseMethodDesc_return(cp_info.getTypeDescr(constant_pool, descriptor_index));
name = toName(constant_pool);
params = ClassFile.parseMethodDesc_params(cp_info.getTypeDescr(constant_pool, descriptor_index));
if (access.length() > 0) {
return access + " " + rt + " " + name + "(" + params + ")";
}
return rt + " " + name + "(" + params + ")";
}
/**
* Displays this method, printing a prototype followed by list of Instructions.
*
* @param constant_pool
* the constant_pool for this class.
* @see prototype
* @see ByteCode#showCode
*/
void print(cp_info constant_pool[]) {
logger.debug("" + prototype(constant_pool));
ByteCode.showCode(instructions, constant_pool);
}
}
| 4,115
| 25.901961
| 101
|
java
|
soot
|
soot-master/src/main/java/soot/coffi/parameter_annotation.java
|
package soot.coffi;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Jennifer Lhotak
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
/**
* There can be several parameter annotations in each Parameter Visibility attribute
*
* @see attribute_info
* @author Jennifer Lhotak
*/
public class parameter_annotation extends attribute_info {
/** number of annotations */
public int num_annotations;
/**
* Each entry represents a single annotation.
*/
public annotation annotations[];
}
| 1,185
| 29.410256
| 84
|
java
|
soot
|
soot-master/src/main/java/soot/dava/CorruptASTException.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2006 Nomair A. Naeem (nomair.naeem@mail.mcgill.ca)
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
//import java.util.*;
//import soot.util.*;
//import soot.dava.toolkits.base.finders.*;
public class CorruptASTException extends DecompilationException {
public CorruptASTException(String message) {
super();
System.out.println("The Abstract Syntax Tree is corrupt");
System.out.println(message);
report();
}
}
| 1,181
| 30.945946
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/dava/Dava.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2003 Jerome Miecznikowski
* Copyright (C) 2004 - 2005 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import soot.Body;
import soot.CompilationDeathException;
import soot.G;
import soot.Local;
import soot.Singletons;
import soot.SootMethod;
import soot.Type;
import soot.jimple.Jimple;
import soot.util.IterableSet;
public class Dava {
private static final Logger logger = LoggerFactory.getLogger(Dava.class);
public Dava(Singletons.Global g) {
}
public static Dava v() {
return G.v().soot_dava_Dava();
}
private static final String LOG_TO_FILE = null;
private static final PrintStream LOG_TO_SCREEN = null;
private Writer iOut = null;
private IterableSet currentPackageContext = null;
private String currentPackage;
public void set_CurrentPackage(String cp) {
currentPackage = cp;
}
public String get_CurrentPackage() {
return currentPackage;
}
public void set_CurrentPackageContext(IterableSet cpc) {
currentPackageContext = cpc;
}
public IterableSet get_CurrentPackageContext() {
return currentPackageContext;
}
public DavaBody newBody(SootMethod m) {
return new DavaBody(m);
}
/** Returns a DavaBody constructed from the given body b. */
public DavaBody newBody(Body b) {
return new DavaBody(b);
}
public Local newLocal(String name, Type t) {
return Jimple.v().newLocal(name, t);
}
public void log(String s) {
if (LOG_TO_SCREEN != null) {
LOG_TO_SCREEN.println(s);
LOG_TO_SCREEN.flush();
}
if (LOG_TO_FILE != null) {
if (iOut == null) {
try {
iOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(LOG_TO_FILE), "US-ASCII"));
} catch (FileNotFoundException fnfe) {
logger.debug("" + "Unable to open " + LOG_TO_FILE);
logger.error(fnfe.getMessage(), fnfe);
throw new CompilationDeathException(CompilationDeathException.COMPILATION_ABORTED);
} catch (UnsupportedEncodingException uee) {
logger.debug("" + "This system doesn't support US-ASCII encoding!!");
logger.error(uee.getMessage(), uee);
throw new CompilationDeathException(CompilationDeathException.COMPILATION_ABORTED);
}
}
try {
iOut.write(s);
iOut.write("\n");
iOut.flush();
} catch (IOException ioe) {
logger.debug("" + "Unable to write to " + LOG_TO_FILE);
logger.error(ioe.getMessage(), ioe);
throw new CompilationDeathException(CompilationDeathException.COMPILATION_ABORTED);
}
}
}
}
| 3,662
| 27.84252
| 107
|
java
|
soot
|
soot-master/src/main/java/soot/dava/DavaBody.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2003 Jerome Miecznikowski
* Copyright (C) 2004 - 2006 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import soot.Body;
import soot.G;
import soot.IntType;
import soot.Local;
import soot.PatchingChain;
import soot.PhaseOptions;
import soot.RefType;
import soot.SootFieldRef;
import soot.SootMethod;
import soot.SootMethodRef;
import soot.Trap;
import soot.Type;
import soot.Unit;
import soot.UnitBox;
import soot.Value;
import soot.ValueBox;
import soot.dava.internal.AST.ASTMethodNode;
import soot.dava.internal.AST.ASTNode;
import soot.dava.internal.SET.SETNode;
import soot.dava.internal.SET.SETTopNode;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.internal.asg.AugmentedStmtGraph;
import soot.dava.internal.javaRep.DCmpExpr;
import soot.dava.internal.javaRep.DCmpgExpr;
import soot.dava.internal.javaRep.DCmplExpr;
import soot.dava.internal.javaRep.DInstanceFieldRef;
import soot.dava.internal.javaRep.DIntConstant;
import soot.dava.internal.javaRep.DInterfaceInvokeExpr;
import soot.dava.internal.javaRep.DLengthExpr;
import soot.dava.internal.javaRep.DNegExpr;
import soot.dava.internal.javaRep.DNewArrayExpr;
import soot.dava.internal.javaRep.DNewInvokeExpr;
import soot.dava.internal.javaRep.DNewMultiArrayExpr;
import soot.dava.internal.javaRep.DSpecialInvokeExpr;
import soot.dava.internal.javaRep.DStaticFieldRef;
import soot.dava.internal.javaRep.DStaticInvokeExpr;
import soot.dava.internal.javaRep.DThisRef;
import soot.dava.internal.javaRep.DVirtualInvokeExpr;
import soot.dava.toolkits.base.AST.UselessTryRemover;
import soot.dava.toolkits.base.AST.transformations.ASTCleaner;
import soot.dava.toolkits.base.AST.transformations.ASTCleanerTwo;
import soot.dava.toolkits.base.AST.transformations.AndAggregator;
import soot.dava.toolkits.base.AST.transformations.BooleanConditionSimplification;
import soot.dava.toolkits.base.AST.transformations.DeInliningFinalFields;
import soot.dava.toolkits.base.AST.transformations.DecrementIncrementStmtCreation;
import soot.dava.toolkits.base.AST.transformations.FinalFieldDefinition;
import soot.dava.toolkits.base.AST.transformations.ForLoopCreator;
import soot.dava.toolkits.base.AST.transformations.IfElseSplitter;
import soot.dava.toolkits.base.AST.transformations.LocalVariableCleaner;
import soot.dava.toolkits.base.AST.transformations.LoopStrengthener;
import soot.dava.toolkits.base.AST.transformations.NewStringBufferSimplification;
import soot.dava.toolkits.base.AST.transformations.OrAggregatorFour;
import soot.dava.toolkits.base.AST.transformations.OrAggregatorOne;
import soot.dava.toolkits.base.AST.transformations.OrAggregatorTwo;
import soot.dava.toolkits.base.AST.transformations.PushLabeledBlockIn;
import soot.dava.toolkits.base.AST.transformations.ShortcutArrayInit;
import soot.dava.toolkits.base.AST.transformations.ShortcutIfGenerator;
import soot.dava.toolkits.base.AST.transformations.SuperFirstStmtHandler;
import soot.dava.toolkits.base.AST.transformations.TypeCastingError;
import soot.dava.toolkits.base.AST.transformations.UselessAbruptStmtRemover;
import soot.dava.toolkits.base.AST.transformations.UselessLabeledBlockRemover;
import soot.dava.toolkits.base.AST.traversals.ClosestAbruptTargetFinder;
import soot.dava.toolkits.base.AST.traversals.CopyPropagation;
import soot.dava.toolkits.base.finders.AbruptEdgeFinder;
import soot.dava.toolkits.base.finders.CycleFinder;
import soot.dava.toolkits.base.finders.ExceptionFinder;
import soot.dava.toolkits.base.finders.ExceptionNode;
import soot.dava.toolkits.base.finders.IfFinder;
import soot.dava.toolkits.base.finders.LabeledBlockFinder;
import soot.dava.toolkits.base.finders.SequenceFinder;
import soot.dava.toolkits.base.finders.SwitchFinder;
import soot.dava.toolkits.base.finders.SynchronizedBlockFinder;
import soot.dava.toolkits.base.misc.MonitorConverter;
import soot.dava.toolkits.base.misc.ThrowNullConverter;
import soot.grimp.GrimpBody;
import soot.grimp.NewInvokeExpr;
import soot.jimple.ArrayRef;
import soot.jimple.BinopExpr;
import soot.jimple.CastExpr;
import soot.jimple.CaughtExceptionRef;
import soot.jimple.CmpExpr;
import soot.jimple.CmpgExpr;
import soot.jimple.CmplExpr;
import soot.jimple.ConditionExpr;
import soot.jimple.Constant;
import soot.jimple.DefinitionStmt;
import soot.jimple.Expr;
import soot.jimple.IdentityStmt;
import soot.jimple.IfStmt;
import soot.jimple.InstanceFieldRef;
import soot.jimple.InstanceInvokeExpr;
import soot.jimple.InstanceOfExpr;
import soot.jimple.IntConstant;
import soot.jimple.InterfaceInvokeExpr;
import soot.jimple.InvokeExpr;
import soot.jimple.InvokeStmt;
import soot.jimple.LengthExpr;
import soot.jimple.LookupSwitchStmt;
import soot.jimple.MonitorStmt;
import soot.jimple.NegExpr;
import soot.jimple.NewArrayExpr;
import soot.jimple.NewExpr;
import soot.jimple.NewMultiArrayExpr;
import soot.jimple.ParameterRef;
import soot.jimple.Ref;
import soot.jimple.ReturnStmt;
import soot.jimple.SpecialInvokeExpr;
import soot.jimple.StaticFieldRef;
import soot.jimple.StaticInvokeExpr;
import soot.jimple.Stmt;
import soot.jimple.TableSwitchStmt;
import soot.jimple.ThisRef;
import soot.jimple.ThrowStmt;
import soot.jimple.UnopExpr;
import soot.jimple.VirtualInvokeExpr;
import soot.jimple.internal.JGotoStmt;
import soot.jimple.internal.JimpleLocal;
import soot.toolkits.graph.BriefUnitGraph;
import soot.toolkits.graph.TrapUnitGraph;
import soot.util.IterableSet;
import soot.util.Switchable;
/*
* CHANGE LOG: Nomair - January 2006: Moved the AST Analyses to a separate method
* These are now invoked as a very last staged (just before generating decompiled
* output. Invoked by PackManager
*
* Nomair - 7th Feb, 2006: Starting work on a naming mechanism
* Nomair - 13th Feb 2006: Added db phase options
*
* renamer: on /off DEFAULT:TRUE
* deobfuscate: DEFAULT: FALSE, dead code eliminateion,
* class/field renaming, constant field elimination
* force-recompilability: DEFAULT TRUE, super, final
*
* Nomair: March 28th, 2006: Removed the applyRenamerAnalyses method from DavaBody to InterProceduralAnalyses
* Although currently renaming is done intra-proceduraly there is strong indication that
* inter procedural analyses will be required to get good names
*
* Nomair: March 29th, 2006: dealing with trying to remove fully qualified names
*
*/
/*
* TODO: Nomair- February 7th. Refactor the call
* AST.perform_Analysis( UselessTryRemover.v());
* use the new AnalysisAdapter routines to write this analysis. Then delete these
* obselete and rather clumsy way of writing analyses
*
* TODO: Nomair 14th Feb 2006, Use the Dava options renamer, deobfuscate, force-recompilability
* Specially the deobfuscate option with the boolean constant propagation analysis
*
*/
public class DavaBody extends Body {
public boolean DEBUG = false;
private Map<Integer, Value> pMap;
private Set<Object> consumedConditions;
private HashSet<Object> thisLocals;
private IterableSet<ExceptionNode> synchronizedBlockFacts;
private IterableSet<ExceptionNode> exceptionFacts;
private IterableSet<AugmentedStmt> monitorFacts;
private IterableSet<String> importList;
private Local controlLocal;
private InstanceInvokeExpr constructorExpr; // holds constructorUnit.getInvokeExpr
private Unit constructorUnit; // holds a stmt (this.init<>)
private List<CaughtExceptionRef> caughtrefs;
/**
* Construct an empty DavaBody
*/
DavaBody(SootMethod m) {
super(m);
this.pMap = new HashMap<Integer, Value>();
this.consumedConditions = new HashSet<Object>();
this.thisLocals = new HashSet<Object>();
this.synchronizedBlockFacts = new IterableSet<ExceptionNode>();
this.exceptionFacts = new IterableSet<ExceptionNode>();
this.monitorFacts = new IterableSet<AugmentedStmt>();
this.importList = new IterableSet<String>();
this.caughtrefs = new LinkedList<CaughtExceptionRef>();
this.controlLocal = null;
this.constructorExpr = null;
}
public Unit get_ConstructorUnit() {
return constructorUnit;
}
public List<CaughtExceptionRef> get_CaughtRefs() {
return caughtrefs;
}
public InstanceInvokeExpr get_ConstructorExpr() {
return constructorExpr;
}
public void set_ConstructorExpr(InstanceInvokeExpr expr) {
constructorExpr = expr;
}
public void set_ConstructorUnit(Unit s) {
constructorUnit = s;
}
public Map<Integer, Value> get_ParamMap() {
return pMap;
}
public void set_ParamMap(Map<Integer, Value> map) {
pMap = map;
}
public HashSet<Object> get_ThisLocals() {
return thisLocals;
}
public Local get_ControlLocal() {
if (controlLocal == null) {
controlLocal = new JimpleLocal("controlLocal", IntType.v());
getLocals().add(controlLocal);
}
return controlLocal;
}
public Set<Object> get_ConsumedConditions() {
return consumedConditions;
}
public void consume_Condition(AugmentedStmt as) {
consumedConditions.add(as);
}
public Object clone() {
Body b = Dava.v().newBody(getMethodUnsafe());
b.importBodyContentsFrom(this);
return b;
}
public IterableSet<ExceptionNode> get_SynchronizedBlockFacts() {
return synchronizedBlockFacts;
}
public IterableSet<ExceptionNode> get_ExceptionFacts() {
return exceptionFacts;
}
public IterableSet<AugmentedStmt> get_MonitorFacts() {
return monitorFacts;
}
public IterableSet<String> getImportList() {
return importList;
}
/**
* Constructs a DavaBody from the given Body.
*/
DavaBody(Body body) {
this(body.getMethod());
debug("DavaBody", "creating DavaBody for" + body.getMethod().toString());
Dava.v().log("\nstart method " + body.getMethod().toString());
if (DEBUG) {
if (!body.getMethod().getExceptions().isEmpty()) {
debug("DavaBody", "printing NON EMPTY exception list for " + body.getMethod().toString() + " "
+ body.getMethod().getExceptions().toString());
}
}
// copy and "convert" the grimp representation
// DEBUG=true;
copy_Body(body);
// DEBUG=false;
// prime the analysis
AugmentedStmtGraph asg = new AugmentedStmtGraph(new BriefUnitGraph(this), new TrapUnitGraph(this));
// System.out.println(asg.toString());
ExceptionFinder.v().preprocess(this, asg);
SETNode SET = new SETTopNode(asg.get_ChainView());
while (true) {
try {
CycleFinder.v().find(this, asg, SET);
IfFinder.v().find(this, asg, SET);
SwitchFinder.v().find(this, asg, SET);
SynchronizedBlockFinder.v().find(this, asg, SET);
ExceptionFinder.v().find(this, asg, SET);
SequenceFinder.v().find(this, asg, SET);
LabeledBlockFinder.v().find(this, asg, SET);
AbruptEdgeFinder.v().find(this, asg, SET);
} catch (RetriggerAnalysisException rae) {
SET = new SETTopNode(asg.get_ChainView());
consumedConditions = new HashSet<Object>();
continue;
}
break;
}
MonitorConverter.v().convert(this);
ThrowNullConverter.v().convert(this);
ASTNode AST = SET.emit_AST();
// get rid of the grimp representation, put in the new AST
getTraps().clear();
getUnits().clear();
getUnits().addLast(AST);
// perform transformations on the AST
/*
* Nomair This should be refactored to use the new AnalysisAdapter classes
*/
do {
G.v().ASTAnalysis_modified = false;
AST.perform_Analysis(UselessTryRemover.v());
} while (G.v().ASTAnalysis_modified);
/*
* Nomair A Naeem 10-MARCH-2005
*
* IT IS ESSENTIAL TO CALL THIS METHOD This method initializes the locals of the current method being processed Failure
* to invoke this method here will result in no locals being printed out
*/
if (AST instanceof ASTMethodNode) {
((ASTMethodNode) AST).storeLocals(this);
/*
* January 12th, 2006 Deal with the super() problem before continuing
*/
Map<String, String> options = PhaseOptions.v().getPhaseOptions("db.force-recompile");
boolean force = PhaseOptions.getBoolean(options, "enabled");
// System.out.println("force is "+force);
if (force) {
AST.apply(new SuperFirstStmtHandler((ASTMethodNode) AST));
}
debug("DavaBody", "PreInit booleans is" + G.v().SootMethodAddedByDava);
}
Dava.v().log("end method " + body.getMethod().toString());
}
public void applyBugFixes() {
ASTNode AST = (ASTNode) this.getUnits().getFirst();
debug("applyBugFixes", "Applying AST analyzes for method" + this.getMethod().toString());
AST.apply(new ShortcutIfGenerator());
debug("applyBugFixes", "after ShortcutIfGenerator" + G.v().ASTTransformations_modified);
AST.apply(new TypeCastingError());
debug("applyBugFixes", "after TypeCastingError" + G.v().ASTTransformations_modified);
}
/*
* Method is invoked by the packmanager just before it is actually about to generate decompiled code. Works as a separate
* stage from the DavaBody() constructor. All AST transformations should be implemented from within this method.
*
* Method is also invoked from the InterProceduralAnlaysis method once those have been invoked
*/
public void analyzeAST() {
ASTNode AST = (ASTNode) this.getUnits().getFirst();
debug("analyzeAST", "Applying AST analyzes for method" + this.getMethod().toString());
/*
* Nomair A. Naeem tranformations on the AST Any AST Transformations added should be added to the applyASTAnalyses method
* unless we are want to delay the analysis till for example THE LAST THING DONE
*/
applyASTAnalyses(AST);
/*
* Nomair A. Naeem apply structural flow analyses now
*
*/
debug("analyzeAST", "Applying structure analysis" + this.getMethod().toString());
applyStructuralAnalyses(AST);
debug("analyzeAST", "Applying structure analysis DONE" + this.getMethod().toString());
/*
* Renamer March 28th Nomair A. Naeem. Since there is a chance that the analyze method gets involved multiple times we
* dont want renaming done more than once.
*
* hence removing the call of the renamer from here Also looking ahead i have a feeling that we will be going
* interprocedural for the renamer hence i am placing the renamer code inside the interprocedural class
*/
/*
* In the end check 1, if there are labels which can be safely removed 2, int temp; temp=0 to be converted to int temp=0;
*/
// AST.apply(new ExtraLabelNamesRemover());
// System.out.println("\nEND analyzing method"+this.getMethod().toString());
}
private void applyASTAnalyses(ASTNode AST) {
debug("applyASTAnalyses", "initial one time analyses started");
/*
* Nomair A. Naeem Transformations on the AST
*/
// The BooleanConditionSimplification changes flag==false to just flag
// AST.apply(new DepthFirstAdapter(true));
AST.apply(new BooleanConditionSimplification());
AST.apply(new DecrementIncrementStmtCreation());
debug("applyASTAnalyses", "initial one time analyses completed");
boolean flag = true;
G.v().ASTTransformations_modified = false;
G.v().ASTIfElseFlipped = false;
int countFlipping = 0;
if (flag) {
// perform transformations on the AST
do {
debug("applyASTAnalyses", "ITERATION");
G.v().ASTTransformations_modified = false;
AST.apply(new AndAggregator());
debug("applyASTAnalyses", "after AndAggregator" + G.v().ASTTransformations_modified);
/*
* The OrAggregatorOne internally calls UselessLabelFinder which sets the label to null Always apply a
* UselessLabeledBlockRemover in the end to remove such labeled blocks
*/
AST.apply(new OrAggregatorOne());
debug("applyASTAnalyses", "after OraggregatorOne" + G.v().ASTTransformations_modified);
/*
* Note OrAggregatorTwo should always be followed by an emptyElseRemover since orAggregatorTwo can create empty else
* bodies and the ASTIfElseNode can be replaced by ASTIfNodes OrAggregator has two patterns see the class for them
*/
AST.apply(new OrAggregatorTwo());
debug("applyASTAnalyses", "after OraggregatorTwo" + G.v().ASTTransformations_modified);
debug("applyASTAnalyses", "after OraggregatorTwo ifElseFlipped is" + G.v().ASTIfElseFlipped);
AST.apply(new OrAggregatorFour());
debug("applyASTAnalyses", "after OraggregatorFour" + G.v().ASTTransformations_modified);
/*
* ASTCleaner currently does the following tasks: 1, Remove empty Labeled Blocks UselessLabeledBlockRemover 2,
* convert ASTIfElseNodes with empty else bodies to ASTIfNodes 3, Apply OrAggregatorThree
*/
AST.apply(new ASTCleaner());
debug("applyASTAnalyses", "after ASTCleaner" + G.v().ASTTransformations_modified);
/*
* PushLabeledBlockIn should not be called unless we are sure that all labeledblocks have non null labels. A good way
* of ensuring this is to run the ASTCleaner directly before calling this
*/
AST.apply(new PushLabeledBlockIn());
debug("applyASTAnalyses", "after PushLabeledBlockIn" + G.v().ASTTransformations_modified);
AST.apply(new LoopStrengthener());
debug("applyASTAnalyses", "after LoopStrengthener" + G.v().ASTTransformations_modified);
/*
* Pattern two carried out in OrAggregatorTwo restricts some patterns in for loop creation. Pattern two was
* implemented to give loopStrengthening a better chance SEE IfElseBreaker
*/
AST.apply(new ASTCleanerTwo());
debug("applyASTAnalyses", "after ASTCleanerTwo" + G.v().ASTTransformations_modified);
AST.apply(new ForLoopCreator());
debug("applyASTAnalyses", "after ForLoopCreator" + G.v().ASTTransformations_modified);
AST.apply(new NewStringBufferSimplification());
debug("applyASTAnalyses", "after NewStringBufferSimplification" + G.v().ASTTransformations_modified);
AST.apply(new ShortcutArrayInit());
debug("applyASTAnalyses", "after ShortcutArrayInit" + G.v().ASTTransformations_modified);
AST.apply(new UselessLabeledBlockRemover());
debug("applyASTAnalyses", "after UselessLabeledBlockRemover" + G.v().ASTTransformations_modified);
if (!G.v().ASTTransformations_modified) {
AST.apply(new IfElseSplitter());
debug("applyASTAnalyses", "after IfElseSplitter" + G.v().ASTTransformations_modified);
}
if (!G.v().ASTTransformations_modified) {
AST.apply(new UselessAbruptStmtRemover());
debug("applyASTAnalyses", "after UselessAbruptStmtRemover" + G.v().ASTTransformations_modified);
}
AST.apply(new ShortcutIfGenerator());
debug("applyASTAnalyses", "after ShortcutIfGenerator" + G.v().ASTTransformations_modified);
AST.apply(new TypeCastingError());
debug("applyASTAnalyses", "after TypeCastingError" + G.v().ASTTransformations_modified);
/*
* if we matched some useful pattern we reserve the right to flip conditions again
*/
if (G.v().ASTTransformations_modified) {
G.v().ASTIfElseFlipped = false;
countFlipping = 0;
debug("applyASTanalyses", "Transformation modified was true hence will reiterate. set flipped to false");
} else {
// check if only the ifelse was flipped
if (G.v().ASTIfElseFlipped) {
debug("", "ifelseflipped and transformations NOT modified");
// we couldnt transform but we did flip
if (countFlipping == 0) {
debug("", "ifelseflipped and transformations NOT modified count is 0");
// let this go on just once more in the hope of some other pattern being matched
G.v().ASTIfElseFlipped = false;
countFlipping++;
G.v().ASTTransformations_modified = true;
} else {
debug("", "ifelseflipped and transformations NOT modified count is not 0 TERMINATE");
}
}
} // if ASTTransformations was not modified
} while (G.v().ASTTransformations_modified);
// System.out.println("The AST trasnformations has run"+times);
}
/*
* ClosestAbruptTargetFinder should be reinitialized everytime there is a change to the AST This is utilized internally
* by the DavaFlowSet implementation to handle Abrupt Implicit Stmts
*/
AST.apply(ClosestAbruptTargetFinder.v());
debug("applyASTAnalyses", "after ClosestAbruptTargetFinder" + G.v().ASTTransformations_modified);
// 29th Jan 2006
// make sure when recompiling there is no variable might not be initialized error
Map<String, String> options = PhaseOptions.v().getPhaseOptions("db.force-recompile");
boolean force = PhaseOptions.getBoolean(options, "enabled");
// System.out.println("Force is"+force);
if (force) {
debug("applyASTAnalyses", "before FinalFieldDefinition" + G.v().ASTTransformations_modified);
new FinalFieldDefinition((ASTMethodNode) AST);
debug("applyASTAnalyses", "after FinalFieldDefinition" + G.v().ASTTransformations_modified);
}
// this analysis has to be after ShortcutArrayInit to give that analysis more chances
AST.apply(new DeInliningFinalFields());
debug("applyASTAnalyses", "end applyASTAnlayses" + G.v().ASTTransformations_modified);
}
private void applyStructuralAnalyses(ASTNode AST) {
// TESTING REACHING DEFS
// ReachingDefs defs = new ReachingDefs(AST);
// AST.apply(new tester(true,defs));
// TESTING REACHING COPIES
// ReachingCopies copies = new ReachingCopies(AST);
// AST.apply(new tester(true,copies));
// TESTING ASTUSESANDDEFS
// AST.apply(new ASTUsesAndDefs(AST));
/*
* Structural flow analyses.....
*/
// CopyPropagation.DEBUG=true;
debug("applyStructureAnalyses", "invoking copy propagation");
CopyPropagation prop = new CopyPropagation(AST);
AST.apply(prop);
debug("applyStructureAnalyses", "invoking copy propagation DONE");
// copy propagation should be followed by LocalVariableCleaner to get max effect
// ASTUsesAndDefs.DEBUG=true;
debug("applyStructureAnalyses", "Local Variable Cleaner started");
AST.apply(new LocalVariableCleaner(AST));
debug("applyStructureAnalyses", "Local Variable Cleaner DONE");
}
/*
* Copy and patch a GrimpBody so that it can be used to output Java.
*/
private void copy_Body(Body body) {
if (!(body instanceof GrimpBody)) {
throw new RuntimeException("You can only create a DavaBody from a GrimpBody!");
}
GrimpBody grimpBody = (GrimpBody) body;
/*
* Import body contents from Grimp.
*/
{
HashMap<Switchable, Switchable> bindings = new HashMap<Switchable, Switchable>();
HashMap<Unit, Unit> reverse_binding = new HashMap<Unit, Unit>();
// Clone units in body's statement list
for (Unit original : grimpBody.getUnits()) {
Unit copy = (Unit) original.clone();
// Add cloned unit to our unitChain.
getUnits().addLast(copy);
// Build old <-> new map to be able to patch up references to other units
// within the cloned units. (these are still refering to the original
// unit objects).
bindings.put(original, copy);
reverse_binding.put(copy, original);
}
// patch up the switch statments
for (Unit u : getUnits()) {
Stmt s = (Stmt) u;
if (s instanceof TableSwitchStmt) {
TableSwitchStmt ts = (TableSwitchStmt) s;
TableSwitchStmt original_switch = (TableSwitchStmt) reverse_binding.get(u);
ts.setDefaultTarget((Unit) bindings.get(original_switch.getDefaultTarget()));
LinkedList<Unit> new_target_list = new LinkedList<Unit>();
int target_count = ts.getHighIndex() - ts.getLowIndex() + 1;
for (int i = 0; i < target_count; i++) {
new_target_list.add((Unit) bindings.get(original_switch.getTarget(i)));
}
ts.setTargets(new_target_list);
} else if (s instanceof LookupSwitchStmt) {
LookupSwitchStmt ls = (LookupSwitchStmt) s;
LookupSwitchStmt original_switch = (LookupSwitchStmt) reverse_binding.get(u);
ls.setDefaultTarget((Unit) bindings.get(original_switch.getDefaultTarget()));
Unit[] new_target_list = new Unit[original_switch.getTargetCount()];
for (int i = 0; i < original_switch.getTargetCount(); i++) {
new_target_list[i] = (Unit) bindings.get(original_switch.getTarget(i));
}
ls.setTargets(new_target_list);
ls.setLookupValues(original_switch.getLookupValues());
}
}
// Clone locals.
for (Local original : grimpBody.getLocals()) {
Local copy = Dava.v().newLocal(original.getName(), original.getType());
getLocals().add(copy);
// Build old <-> new mapping.
bindings.put(original, copy);
}
// Patch up references within units using our (old <-> new) map.
for (UnitBox box : getAllUnitBoxes()) {
Unit newObject = (Unit) bindings.get(box.getUnit());
// if we have a reference to an old object, replace it with its clone.
if (newObject != null) {
box.setUnit(newObject);
}
}
// backpatch all local variables.
for (ValueBox vb : getUseAndDefBoxes()) {
Value val = vb.getValue();
if (val instanceof Local) {
vb.setValue((Value) bindings.get(val));
}
}
// clone the traps
for (Trap originalTrap : grimpBody.getTraps()) {
Trap cloneTrap = (Trap) originalTrap.clone();
cloneTrap.setHandlerUnit((Unit) bindings.get(originalTrap.getHandlerUnit()));
cloneTrap.setBeginUnit((Unit) bindings.get(originalTrap.getBeginUnit()));
cloneTrap.setEndUnit((Unit) bindings.get(originalTrap.getEndUnit()));
getTraps().add(cloneTrap);
}
}
/*
* Add one level of indirection to "if", "switch", and exceptional control flow. This allows for easy handling of breaks,
* continues and exceptional loops.
*/
{
PatchingChain<Unit> units = getUnits();
for (Iterator<Unit> it = units.snapshotIterator(); it.hasNext();) {
Unit u = it.next();
if (u instanceof IfStmt) {
IfStmt ifs = (IfStmt) u;
JGotoStmt jgs = new JGotoStmt(units.getSuccOf(u));
units.insertAfter(jgs, u);
JGotoStmt jumper = new JGotoStmt(ifs.getTarget());
units.insertAfter(jumper, jgs);
ifs.setTarget(jumper);
} else if (u instanceof TableSwitchStmt) {
TableSwitchStmt tss = (TableSwitchStmt) u;
int targetCount = tss.getHighIndex() - tss.getLowIndex() + 1;
for (int i = 0; i < targetCount; i++) {
JGotoStmt jgs = new JGotoStmt(tss.getTarget(i));
units.insertAfter(jgs, tss);
tss.setTarget(i, jgs);
}
JGotoStmt jgs = new JGotoStmt(tss.getDefaultTarget());
units.insertAfter(jgs, tss);
tss.setDefaultTarget(jgs);
} else if (u instanceof LookupSwitchStmt) {
LookupSwitchStmt lss = (LookupSwitchStmt) u;
for (int i = 0; i < lss.getTargetCount(); i++) {
JGotoStmt jgs = new JGotoStmt(lss.getTarget(i));
units.insertAfter(jgs, lss);
lss.setTarget(i, jgs);
}
JGotoStmt jgs = new JGotoStmt(lss.getDefaultTarget());
units.insertAfter(jgs, lss);
lss.setDefaultTarget(jgs);
}
}
for (Trap t : getTraps()) {
JGotoStmt jgs = new JGotoStmt(t.getHandlerUnit());
units.addLast(jgs);
t.setHandlerUnit(jgs);
}
}
/*
* Fix up the grimp representations of statements so they can be compiled as java.
*/
{
for (Local l : getLocals()) {
Type t = l.getType();
if (t instanceof RefType) {
RefType rt = (RefType) t;
String className = rt.getSootClass().toString();
String packageName = rt.getSootClass().getJavaPackageName();
String classPackageName = packageName;
if (className.lastIndexOf('.') > 0) {
// 0 doesnt make sense
classPackageName = className.substring(0, className.lastIndexOf('.'));
}
if (!packageName.equals(classPackageName)) {
throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer.");
}
addToImportList(className);
// addPackage(rt.getSootClass().getJavaPackageName());
}
}
for (Unit u : getUnits()) {
if (u instanceof IfStmt) {
javafy(((IfStmt) u).getConditionBox());
} else if (u instanceof ThrowStmt) {
javafy(((ThrowStmt) u).getOpBox());
} else if (u instanceof TableSwitchStmt) {
javafy(((TableSwitchStmt) u).getKeyBox());
} else if (u instanceof LookupSwitchStmt) {
javafy(((LookupSwitchStmt) u).getKeyBox());
} else if (u instanceof MonitorStmt) {
javafy(((MonitorStmt) u).getOpBox());
} else if (u instanceof DefinitionStmt) {
DefinitionStmt ds = (DefinitionStmt) u;
javafy(ds.getRightOpBox());
javafy(ds.getLeftOpBox());
Value rightOp = ds.getRightOp();
if (rightOp instanceof IntConstant) {
ds.getRightOpBox().setValue(DIntConstant.v(((IntConstant) rightOp).value, ds.getLeftOp().getType()));
}
} else if (u instanceof ReturnStmt) {
ReturnStmt rs = (ReturnStmt) u;
Value op = rs.getOp();
if (op instanceof IntConstant) {
rs.getOpBox().setValue(DIntConstant.v(((IntConstant) op).value, body.getMethod().getReturnType()));
} else {
javafy(rs.getOpBox());
}
} else if (u instanceof InvokeStmt) {
javafy(((InvokeStmt) u).getInvokeExprBox());
}
}
}
/*
* Convert references to "this" and parameters.
*/
for (Unit u : getUnits()) {
if (u instanceof IdentityStmt) {
IdentityStmt ids = (IdentityStmt) u;
Value ids_rightOp = ids.getRightOp();
Value ids_leftOp = ids.getLeftOp();
if ((ids_leftOp instanceof Local) && (ids_rightOp instanceof ThisRef)) {
Local thisLocal = (Local) ids_leftOp;
thisLocals.add(thisLocal);
thisLocal.setName("this");
}
}
if (u instanceof DefinitionStmt) {
DefinitionStmt ds = (DefinitionStmt) u;
Value rightOp = ds.getRightOp();
if (rightOp instanceof ParameterRef) {
pMap.put(((ParameterRef) rightOp).getIndex(), ds.getLeftOp());
}
if (rightOp instanceof CaughtExceptionRef) {
caughtrefs.add((CaughtExceptionRef) rightOp);
}
}
}
/*
* Fix up the calls to other constructors. Note, this is seriously underbuilt.
*/
for (Unit u : getUnits()) {
if (u instanceof InvokeStmt) {
InvokeStmt ivs = (InvokeStmt) u;
Value ie = ivs.getInvokeExpr();
if (ie instanceof InstanceInvokeExpr) {
InstanceInvokeExpr iie = (InstanceInvokeExpr) ie;
Value base = iie.getBase();
if ((base instanceof Local) && "this".equals(((Local) base).getName())) {
String name = iie.getMethodRef().name();
if (SootMethod.constructorName.equals(name) || SootMethod.staticInitializerName.equals(name)) {
if (constructorUnit != null) {
throw new RuntimeException("More than one candidate for constructor found.");
}
constructorExpr = iie;
constructorUnit = u;
}
}
}
}
}
}
/*
* The following set of routines takes care of converting the syntax of single grimp statements to java.
*/
private void javafy(ValueBox vb) {
Value v = vb.getValue();
if (v instanceof Expr) {
javafy_expr(vb);
} else if (v instanceof Ref) {
javafy_ref(vb);
} else if (v instanceof Local) {
javafy_local(vb);
} else if (v instanceof Constant) {
javafy_constant(vb);
}
}
private void javafy_expr(ValueBox vb) {
Expr e = (Expr) vb.getValue();
if (e instanceof BinopExpr) {
javafy_binop_expr(vb);
} else if (e instanceof UnopExpr) {
javafy_unop_expr(vb);
} else if (e instanceof CastExpr) {
javafy_cast_expr(vb);
} else if (e instanceof NewArrayExpr) {
javafy_newarray_expr(vb);
} else if (e instanceof NewMultiArrayExpr) {
javafy_newmultiarray_expr(vb);
} else if (e instanceof InstanceOfExpr) {
javafy_instanceof_expr(vb);
} else if (e instanceof InvokeExpr) {
javafy_invoke_expr(vb);
} else if (e instanceof NewExpr) {
javafy_new_expr(vb);
}
}
private void javafy_ref(ValueBox vb) {
Ref r = (Ref) vb.getValue();
if (r instanceof StaticFieldRef) {
SootFieldRef fieldRef = ((StaticFieldRef) r).getFieldRef();
// addPackage(fieldRef.declaringClass().getJavaPackageName());
String className = fieldRef.declaringClass().toString();
String packageName = fieldRef.declaringClass().getJavaPackageName();
String classPackageName = packageName;
if (className.lastIndexOf('.') > 0) {
// 0 doesnt make sense
classPackageName = className.substring(0, className.lastIndexOf('.'));
}
if (!packageName.equals(classPackageName)) {
throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer.");
}
addToImportList(className);
vb.setValue(new DStaticFieldRef(fieldRef, getMethod().getDeclaringClass().getName()));
} else if (r instanceof ArrayRef) {
ArrayRef ar = (ArrayRef) r;
javafy(ar.getBaseBox());
javafy(ar.getIndexBox());
} else if (r instanceof InstanceFieldRef) {
InstanceFieldRef ifr = (InstanceFieldRef) r;
javafy(ifr.getBaseBox());
vb.setValue(new DInstanceFieldRef(ifr.getBase(), ifr.getFieldRef(), thisLocals));
} else if (r instanceof ThisRef) {
ThisRef tr = (ThisRef) r;
vb.setValue(new DThisRef((RefType) tr.getType()));
}
}
private void javafy_local(ValueBox vb) {
}
private void javafy_constant(ValueBox vb) {
}
private void javafy_binop_expr(ValueBox vb) {
BinopExpr boe = (BinopExpr) vb.getValue();
ValueBox leftOpBox = boe.getOp1Box(), rightOpBox = boe.getOp2Box();
Value leftOp = leftOpBox.getValue(), rightOp = rightOpBox.getValue();
if (rightOp instanceof IntConstant) {
if (!(leftOp instanceof IntConstant)) {
javafy(leftOpBox);
leftOp = leftOpBox.getValue();
if (boe instanceof ConditionExpr) {
rightOpBox.setValue(DIntConstant.v(((IntConstant) rightOp).value, leftOp.getType()));
} else {
rightOpBox.setValue(DIntConstant.v(((IntConstant) rightOp).value, null));
}
}
} else if (leftOp instanceof IntConstant) {
javafy(rightOpBox);
rightOp = rightOpBox.getValue();
if (boe instanceof ConditionExpr) {
leftOpBox.setValue(DIntConstant.v(((IntConstant) leftOp).value, rightOp.getType()));
} else {
leftOpBox.setValue(DIntConstant.v(((IntConstant) leftOp).value, null));
}
} else {
javafy(rightOpBox);
rightOp = rightOpBox.getValue();
javafy(leftOpBox);
leftOp = leftOpBox.getValue();
}
if (boe instanceof CmpExpr) {
vb.setValue(new DCmpExpr(leftOp, rightOp));
} else if (boe instanceof CmplExpr) {
vb.setValue(new DCmplExpr(leftOp, rightOp));
} else if (boe instanceof CmpgExpr) {
vb.setValue(new DCmpgExpr(leftOp, rightOp));
}
}
private void javafy_unop_expr(ValueBox vb) {
UnopExpr uoe = (UnopExpr) vb.getValue();
javafy(uoe.getOpBox());
if (uoe instanceof LengthExpr) {
vb.setValue(new DLengthExpr(((LengthExpr) uoe).getOp()));
} else if (uoe instanceof NegExpr) {
vb.setValue(new DNegExpr(((NegExpr) uoe).getOp()));
}
}
private void javafy_cast_expr(ValueBox vb) {
CastExpr ce = (CastExpr) vb.getValue();
javafy(ce.getOpBox());
}
private void javafy_newarray_expr(ValueBox vb) {
NewArrayExpr nae = (NewArrayExpr) vb.getValue();
javafy(nae.getSizeBox());
vb.setValue(new DNewArrayExpr(nae.getBaseType(), nae.getSize()));
}
private void javafy_newmultiarray_expr(ValueBox vb) {
NewMultiArrayExpr nmae = (NewMultiArrayExpr) vb.getValue();
for (int i = 0; i < nmae.getSizeCount(); i++) {
javafy(nmae.getSizeBox(i));
}
vb.setValue(new DNewMultiArrayExpr(nmae.getBaseType(), nmae.getSizes()));
}
private void javafy_instanceof_expr(ValueBox vb) {
InstanceOfExpr ioe = (InstanceOfExpr) vb.getValue();
javafy(ioe.getOpBox());
}
private void javafy_invoke_expr(ValueBox vb) {
InvokeExpr ie = (InvokeExpr) vb.getValue();
String className = ie.getMethodRef().declaringClass().toString();
String packageName = ie.getMethodRef().declaringClass().getJavaPackageName();
String classPackageName = packageName;
if (className.lastIndexOf('.') > 0) {
// 0 doesnt make sense
classPackageName = className.substring(0, className.lastIndexOf('.'));
}
if (!packageName.equals(classPackageName)) {
throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer.");
}
addToImportList(className);
for (int i = 0; i < ie.getArgCount(); i++) {
Value arg = ie.getArg(i);
if (arg instanceof IntConstant) {
ie.getArgBox(i).setValue(DIntConstant.v(((IntConstant) arg).value, ie.getMethodRef().parameterType(i)));
} else {
javafy(ie.getArgBox(i));
}
}
if (ie instanceof InstanceInvokeExpr) {
javafy(((InstanceInvokeExpr) ie).getBaseBox());
if (ie instanceof VirtualInvokeExpr) {
VirtualInvokeExpr vie = (VirtualInvokeExpr) ie;
vb.setValue(new DVirtualInvokeExpr(vie.getBase(), vie.getMethodRef(), vie.getArgs(), thisLocals));
} else if (ie instanceof SpecialInvokeExpr) {
SpecialInvokeExpr sie = (SpecialInvokeExpr) ie;
vb.setValue(new DSpecialInvokeExpr(sie.getBase(), sie.getMethodRef(), sie.getArgs()));
} else if (ie instanceof InterfaceInvokeExpr) {
InterfaceInvokeExpr iie = (InterfaceInvokeExpr) ie;
vb.setValue(new DInterfaceInvokeExpr(iie.getBase(), iie.getMethodRef(), iie.getArgs()));
} else {
throw new RuntimeException("InstanceInvokeExpr " + ie + " not javafied correctly");
}
} else if (ie instanceof StaticInvokeExpr) {
StaticInvokeExpr sie = (StaticInvokeExpr) ie;
if (sie instanceof NewInvokeExpr) {
NewInvokeExpr nie = (NewInvokeExpr) sie;
RefType rt = nie.getBaseType();
className = rt.getSootClass().toString();
packageName = rt.getSootClass().getJavaPackageName();
classPackageName = packageName;
if (className.lastIndexOf('.') > 0) {
// 0 doesnt make sense
classPackageName = className.substring(0, className.lastIndexOf('.'));
}
if (!packageName.equals(classPackageName)) {
throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer.");
}
addToImportList(className);
vb.setValue(new DNewInvokeExpr((RefType) nie.getType(), nie.getMethodRef(), nie.getArgs()));
} else {
SootMethodRef methodRef = sie.getMethodRef();
className = methodRef.declaringClass().toString();
packageName = methodRef.declaringClass().getJavaPackageName();
classPackageName = packageName;
if (className.lastIndexOf('.') > 0) {
// 0 doesnt make sense
classPackageName = className.substring(0, className.lastIndexOf('.'));
}
if (!packageName.equals(classPackageName)) {
throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer.");
}
addToImportList(className);
// addPackage(methodRef.declaringClass().getJavaPackageName());
vb.setValue(new DStaticInvokeExpr(methodRef, sie.getArgs()));
}
} else {
throw new RuntimeException("InvokeExpr " + ie + " not javafied correctly");
}
}
private void javafy_new_expr(ValueBox vb) {
NewExpr ne = (NewExpr) vb.getValue();
String className = ne.getBaseType().getSootClass().toString();
String packageName = ne.getBaseType().getSootClass().getJavaPackageName();
String classPackageName = packageName;
if (className.lastIndexOf('.') > 0) {
// 0 doesnt make sense
classPackageName = className.substring(0, className.lastIndexOf('.'));
}
if (!packageName.equals(classPackageName)) {
throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer.");
}
addToImportList(className);
}
public void addToImportList(String className) {
if (!className.isEmpty()) {
importList.add(className);
}
}
public void debug(String methodName, String debug) {
if (DEBUG) {
System.out.println(methodName + " DEBUG: " + debug);
}
}
}
| 42,828
| 35.234349
| 125
|
java
|
soot
|
soot-master/src/main/java/soot/dava/DavaBuildFile.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2006 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
/*
* TODO: Jalopy would be awesome here!!
*/
public class DavaBuildFile {
public static void generate(PrintWriter out, ArrayList<String> decompiledClasses) {
out.print("<project default=\"compile\" name=\"Build file for decompiled code\">\n");
out.print(" <description>\n");
out.print(" This is the build file produced by Dava for the decompiled code.\n");
out.print(" New features like (formatting using jalopy etc) will be added to this build file\n");
out.print("</description>\n");
out.print("<!-- properties for project directories -->\n");
out.print("<property name=\"srcDir\" location=\"src\"/>\n");
out.print("<property name=\"classesDir\" location=\"classes\"/>\n");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
/*
* out.print("<target name=\"init\" description=\"Create necessary directories\">\n"); out.print("<tstamp/>\n");
* out.print(" <!-- set the timestamps -->\n"); out.print(" <mkdir dir=\"${classesDir}\"/>\n");
* out.print(" <mkdir dir=\"${docDir}\"/>\n"); // out.print(" <mkdir dir=\"${libDir}\"/>\n");
* out.print("</target>\n");
*/
out.print(" <!-- ========== Compile Target ================= -->\n");
out.print(" <target name=\"compile\" description=\"Compile .java files\">\n");
out.print(" <javac srcdir=\"${srcDir}\" destdir=\"${classesDir}\">\n");
out.print(" <classpath>\n");
out.print(" <pathelement location=\"${junitJar}\"/>\n");
out.print(" </classpath>\n");
out.print(" </javac>\n");
out.print(" </target>\n");
out.print(" <!-- ==========AST METRICS FOR DECOMPILED CODE================= -->\n");
out.print("<target name=\"ast-metrics\" description=\"Compute the ast metrics\">\n");
/*
* NEED TO MAKE SURE SRC-PREC IS SET so that java to jimple gets evaluate The command is going to be java soot.Main
* -ast-metrics followed by all the classes on which we had originally done the decompile Need a specialized task
*/
out.print(" <exec executable=\"java\" dir=\"src\">\n");
out.print(" <arg value=\"-Xmx400m\" />\n");
out.print(" <arg value=\"soot.Main\" />\n");
out.print(" <arg value=\"-ast-metrics\" />\n");
out.print(" <arg value=\"--src-prec\" />\n");
out.print(" <arg value=\"java\" />\n");
Iterator<String> it = decompiledClasses.iterator();
while (it.hasNext()) {
String temp = it.next();
if (temp.endsWith(".java")) {
temp = temp.substring(0, temp.length() - 5);
}
// System.out.println(temp);
out.print(" <arg value=\"" + temp + "\" />\n");
}
out.print("");
out.print(" </exec>\n");
out.print(" </target>\n");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("</project>");
}
}
| 3,853
| 36.417476
| 119
|
java
|
soot
|
soot-master/src/main/java/soot/dava/DavaFlowAnalysisException.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2006 Nomair A. Naeem (nomair.naeem@mail.mcgill.ca)
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
//import java.util.*;
//import soot.util.*;
//import soot.dava.toolkits.base.finders.*;
public class DavaFlowAnalysisException extends DecompilationException {
public DavaFlowAnalysisException() {
super();
}
public DavaFlowAnalysisException(String message) {
super();
System.out.println("There was an Error During the Structural Flow Analysis in Dava");
System.out.println(message);
report();
}
}
| 1,278
| 29.452381
| 89
|
java
|
soot
|
soot-master/src/main/java/soot/dava/DavaPrinter.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2003 Jerome Miecznikowski
* Copyright (C) 2004 - 2005 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import soot.Body;
import soot.BooleanType;
import soot.ByteType;
import soot.CharType;
import soot.DoubleType;
import soot.FloatType;
import soot.G;
import soot.IntType;
import soot.LongType;
import soot.Modifier;
import soot.RefType;
import soot.Scene;
import soot.ShortType;
import soot.Singletons;
import soot.SootClass;
import soot.SootField;
import soot.SootMethod;
import soot.Type;
import soot.Unit;
import soot.UnitPrinter;
import soot.dava.internal.AST.ASTNode;
import soot.dava.toolkits.base.renamer.RemoveFullyQualifiedName;
import soot.options.Options;
import soot.tagkit.DoubleConstantValueTag;
import soot.tagkit.FloatConstantValueTag;
import soot.tagkit.IntegerConstantValueTag;
import soot.tagkit.LongConstantValueTag;
import soot.tagkit.StringConstantValueTag;
import soot.tagkit.Tag;
import soot.util.Chain;
import soot.util.IterableSet;
public class DavaPrinter {
public DavaPrinter(Singletons.Global g) {
}
public static DavaPrinter v() {
return G.v().soot_dava_DavaPrinter();
}
private void printStatementsInBody(Body body, java.io.PrintWriter out) {
if (Options.v().verbose()) {
System.out.println("Printing " + body.getMethod().getName());
}
Chain<Unit> units = body.getUnits();
if (units.size() != 1) {
throw new RuntimeException("DavaBody AST doesn't have single root.");
}
UnitPrinter up = new DavaUnitPrinter((DavaBody) body);
((ASTNode) units.getFirst()).toString(up);
out.print(up.toString());
}
public void printTo(SootClass cl, PrintWriter out) {
// IterableSet<String> packagesUsed = new IterableSet<String>();
IterableSet<String> importList = new IterableSet<String>();
{
final String curPackage = cl.getJavaPackageName();
if (!curPackage.isEmpty()) {
out.println("package " + curPackage + ';');
out.println();
}
if (cl.hasSuperclass()) {
SootClass superClass = cl.getSuperclass();
importList.add(superClass.toString());
// packagesUsed.add(superClass.getJavaPackageName());
}
for (SootClass sc : cl.getInterfaces()) {
String interfacePackage = sc.toString();
if (!importList.contains(interfacePackage)) {
importList.add(interfacePackage);
}
// if (!packagesUsed.contains(interfacePackage))
// packagesUsed.add(interfacePackage);
}
for (Iterator<SootMethod> methodIt = cl.methodIterator(); methodIt.hasNext();) {
SootMethod dm = methodIt.next();
if (dm.hasActiveBody()) {
// packagesUsed = packagesUsed.union(((DavaBody) dm.getActiveBody()).get_PackagesUsed());
importList = importList.union(((DavaBody) dm.getActiveBody()).getImportList());
}
for (SootClass sc : dm.getExceptions()) {
String thrownPackage = sc.toString();
if (!importList.contains(thrownPackage)) {
importList.add(thrownPackage);
}
// if (!packagesUsed.contains(thrownPackage))
// packagesUsed.add(thrownPackage);
}
for (Type t : dm.getParameterTypes()) {
if (t instanceof RefType) {
String paramPackage = ((RefType) t).getSootClass().toString();
if (!importList.contains(paramPackage)) {
importList.add(paramPackage);
}
// if (packagesUsed.contains(paramPackage) == false)
// packagesUsed.add(paramPackage);
}
}
Type t = dm.getReturnType();
if (t instanceof RefType) {
String returnPackage = ((RefType) t).getSootClass().toString();
if (!importList.contains(returnPackage)) {
importList.add(returnPackage);
}
// if (packagesUsed.contains(returnPackage) == false)
// packagesUsed.add(returnPackage);
}
}
for (SootField f : cl.getFields()) {
if (!f.isPhantom()) {
Type t = f.getType();
if (t instanceof RefType) {
String fieldPackage = ((RefType) t).getSootClass().toString();
if (!importList.contains(fieldPackage)) {
importList.add(fieldPackage);
}
}
}
}
List<String> toImport = new ArrayList<String>();
for (String temp : importList) {
/*
* dont import any file which has currentPackage.className dont import any file which starts with java.lang
*/
// System.out.println("temp is "+temp);
if (temp.contains("java.lang")) {
// problem is that we need to import sub packages java.lang.ref
// for instance if the type is java.lang.ref.WeakReference
String tempClassName = RemoveFullyQualifiedName.getClassName(temp);
if (temp.equals("java.lang." + tempClassName)) {
// System.out.println("temp was not printed as it belongs to java.lang");
continue;
}
}
if (!curPackage.isEmpty() && temp.contains(curPackage)) {
// System.out.println("here "+temp);
continue;
}
if (cl.toString().equals(temp)) {
continue;
}
// System.out.println("printing"+);
toImport.add(temp);
}
/*
* Check that we are not importing two classes with the same last name If yes then remove explicit import and import
* the whole package else output explicit import statement
*/
for (String temp : toImport) {
if (RemoveFullyQualifiedName.containsMultiple(toImport.iterator(), temp, null)) {
// there are atleast two imports with this className
// import package add *
if (temp.lastIndexOf('.') > -1) {
temp = temp.substring(0, temp.lastIndexOf('.'));
out.println("import " + temp + ".*;");
} else {
throw new DecompilationException("Cant find the DOT . for fullyqualified name");
}
} else {
if (temp.lastIndexOf('.') == -1) {
// dot not found this is a class belonging to this package so dont add
} else {
out.println("import " + temp + ';');
}
}
}
// out.println("import " + temp + ';');
out.println();
/*
* if (!packagesUsed.isEmpty()) out.println();
*
* packagesUsed.add("java.lang"); packagesUsed.add(curPackage);
*/
Dava.v().set_CurrentPackageContext(importList);
// Dava.v().set_CurrentPackageContext(packagesUsed);
Dava.v().set_CurrentPackage(curPackage);
}
// Print class name + modifiers
{
String classPrefix = Modifier.toString(cl.getModifiers()).trim();
if (!cl.isInterface()) {
classPrefix = (classPrefix + " class").trim();
}
out.print(classPrefix + " " + cl.getShortJavaStyleName());
}
// Print extension
if (cl.hasSuperclass()) {
String superClassName = cl.getSuperclass().getName();
if (!"java.lang.Object".equals(superClassName)) {
// Nomair Naeem 8th Feb 2006
// Also check if the super class name is not a fully qualified name,
// in which case if the package is imported no need for the long name.
out.print(" extends " + RemoveFullyQualifiedName.getReducedName(importList, superClassName, cl.getType()));
}
}
// Print interfaces
{
Iterator<SootClass> interfaceIt = cl.getInterfaces().iterator();
if (interfaceIt.hasNext()) {
if (cl.isInterface()) {
out.print(" extends ");
} else {
out.print(" implements ");
}
out.print(interfaceIt.next().getName());
while (interfaceIt.hasNext()) {
out.print(", " + interfaceIt.next().getName());
}
}
}
out.println();
out.println("{");
// Print fields
for (SootField f : cl.getFields()) {
if (f.isPhantom()) {
continue;
}
Type fieldType = f.getType();
String qualifiers = (Modifier.toString(f.getModifiers()) + " "
+ RemoveFullyQualifiedName.getReducedName(importList, fieldType.toString(), fieldType)).trim();
String declaration;
if (qualifiers.isEmpty()) {
declaration = Scene.v().quotedNameOf(f.getName());
} else {
declaration = qualifiers + " " + Scene.v().quotedNameOf(f.getName());
}
if (f.isFinal() && f.isStatic()) {
printTags(f, declaration, out);
} else {
out.println(" " + declaration + ';');
}
}
// Print methods
{
Iterator<SootMethod> methodIt = cl.methodIterator();
if (methodIt.hasNext()) {
if (cl.getMethodCount() != 0) {
out.println();
}
do { // condition is already checked
SootMethod method = methodIt.next();
if (method.isPhantom()) {
continue;
}
if (!Modifier.isAbstract(method.getModifiers()) && !Modifier.isNative(method.getModifiers())) {
if (!method.hasActiveBody()) {
throw new RuntimeException("method " + method.getName() + " has no active body!");
} else {
printTo(method.getActiveBody(), out);
}
if (methodIt.hasNext()) {
out.println();
}
} else {
// if method is abstract then print the declaration
out.print(" ");
out.print(method.getDavaDeclaration());
out.println(";");
if (methodIt.hasNext()) {
out.println();
}
}
} while (methodIt.hasNext());
}
}
/*
* January 23rd, 2006 In trying to handle the suepr class problem we need to introduce an inner class Instead of creating
* a data structure for it we are right now just going to print it in the form of a string
*
* It would be interesting to later have an internal inner class structure so that we could decompile inner classes into
* inner classes
*/
if (G.v().SootClassNeedsDavaSuperHandlerClass.contains(cl)) {
out.println("\n private static class DavaSuperHandler{");
out.println(" java.util.Vector myVector = new java.util.Vector();");
out.println("\n public Object get(int pos){");
out.println(" return myVector.elementAt(pos);");
out.println(" }");
out.println("\n public void store(Object obj){");
out.println(" myVector.add(obj);");
out.println(" }");
out.println(" }");
}
out.println("}");
}
private void printTags(SootField f, String declaration, PrintWriter out) {
Type fieldType = f.getType();
if (fieldType instanceof DoubleType) {
DoubleConstantValueTag t = (DoubleConstantValueTag) f.getTag(DoubleConstantValueTag.NAME);
if (t != null) {
out.println(" " + declaration + " = " + t.getDoubleValue() + ';');
return;
}
} else if (fieldType instanceof FloatType) {
FloatConstantValueTag t = (FloatConstantValueTag) f.getTag(FloatConstantValueTag.NAME);
if (t != null) {
out.println(" " + declaration + " = " + t.getFloatValue() + "f;");
return;
}
} else if (fieldType instanceof LongType) {
LongConstantValueTag t = (LongConstantValueTag) f.getTag(LongConstantValueTag.NAME);
if (t != null) {
out.println(" " + declaration + " = " + t.getLongValue() + "l;");
return;
}
} else if (fieldType instanceof CharType) {
IntegerConstantValueTag t = (IntegerConstantValueTag) f.getTag(IntegerConstantValueTag.NAME);
if (t != null) {
out.println(" " + declaration + " = '" + ((char) t.getIntValue()) + "';");
return;
}
} else if (fieldType instanceof BooleanType) {
IntegerConstantValueTag t = (IntegerConstantValueTag) f.getTag(IntegerConstantValueTag.NAME);
if (t != null) {
out.println(" " + declaration + (t.getIntValue() == 0 ? " = false;" : " = true;"));
return;
}
} else if (fieldType instanceof IntType || fieldType instanceof ByteType || fieldType instanceof ShortType) {
IntegerConstantValueTag t = (IntegerConstantValueTag) f.getTag(IntegerConstantValueTag.NAME);
if (t != null) {
out.println(" " + declaration + " = " + t.getIntValue() + ';');
return;
}
} else {
StringConstantValueTag t = (StringConstantValueTag) f.getTag(StringConstantValueTag.NAME);
if (t != null) {
out.println(" " + declaration + " = \"" + t.getStringValue() + "\";");
return;
}
}
// System.out.println("Couldn't find type of field: " + f.getDeclaration());
out.println(" " + declaration + ';');
}
/**
* Prints out the method corresponding to b Body, (declaration and body), in the textual format corresponding to the IR
* used to encode b body.
*
* @param out
* a PrintWriter instance to print to.
*/
private void printTo(Body b, PrintWriter out) {
b.validate();
out.println(" " + b.getMethod().getDavaDeclaration());
if (Options.v().print_tags_in_output()) {
for (Tag t : b.getMethod().getTags()) {
out.println(t);
}
}
out.println(" {");
/*
* The locals are now printed out from within the toString method of ASTMethodNode Nomair A Naeem 10-MARCH-2005
*/
// printLocalsInBody(b, out);
printStatementsInBody(b, out);
out.println(" }");
}
}
| 14,572
| 32.733796
| 125
|
java
|
soot
|
soot-master/src/main/java/soot/dava/DavaStaticBlockCleaner.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Body;
import soot.G;
import soot.Modifier;
import soot.Singletons;
import soot.SootClass;
import soot.SootMethod;
import soot.dava.internal.AST.ASTMethodNode;
import soot.dava.internal.AST.ASTNode;
import soot.dava.internal.AST.ASTStatementSequenceNode;
import soot.util.Chain;
/*
* Coded to remove the static "final" bug from Dava. Usually occurs in AspectJ code
* **********The staticBlockInlining Method is invoked by PackManager**************
*
* In the bug this is what used to happen:
*
* public static final ClassName myField;
* static{
CLASSNAME.postClinit();
}
* postClinit(){ myField = new ClassName(); }
*
* Now this causes a problem since final fields can not be defined using a method call
* So the solution was to inline just this method. to get something like
* static{
myField = new ClassName();
}
* At the same time the code in the method postClinit is removed and an exception is thrown if this method is invoked
*/
public class DavaStaticBlockCleaner {
SootClass sootClass;
public DavaStaticBlockCleaner(Singletons.Global g) {
}
public static DavaStaticBlockCleaner v() {
return G.v().soot_dava_DavaStaticBlockCleaner();
}
// invoked by the PackManager
public void staticBlockInlining(SootClass sootClass) {
this.sootClass = sootClass;
// retrieve the clinit method if any for sootClass
// the clinit method gets converted into the static block which could initialize the final variable
if (!sootClass.declaresMethod("void <clinit>()")) {
// System.out.println("no clinit");
return;
}
SootMethod clinit = sootClass.getMethod("void <clinit>()");
// System.out.println(clinit);
// retireve the active body
if (!clinit.hasActiveBody()) {
throw new RuntimeException("method " + clinit.getName() + " has no active body!");
}
Body clinitBody = clinit.getActiveBody();
Chain units = ((DavaBody) clinitBody).getUnits();
if (units.size() != 1) {
throw new RuntimeException("DavaBody AST doesn't have single root.");
}
ASTNode AST = (ASTNode) units.getFirst();
if (!(AST instanceof ASTMethodNode)) {
throw new RuntimeException("Starting node of DavaBody AST is not an ASTMethodNode");
}
// running methodCallFinder on the Clinit method
AST.apply(new MethodCallFinder(this));
}
/*
* Method called with a sootMethod to decide whether this method should be inlined or not returns null if it shouldnt be
* inlined
*
* A method can be inlined if it belongs to the same class and also if its static....(why???)
*/
public ASTMethodNode inline(SootMethod maybeInline) {
// check if this method should be inlined
if (sootClass != null) {
// 1, method should belong to the same class as the clinit method
if (sootClass.declaresMethod(maybeInline.getSubSignature())) {
// System.out.println("The method invoked is from the same class");
// 2, method should be static
if (Modifier.isStatic(maybeInline.getModifiers())) {
// decided to inline
// send the ASTMethod node of the TO BE INLINED METHOD
// retireve the active body
if (!maybeInline.hasActiveBody()) {
throw new RuntimeException("method " + maybeInline.getName() + " has no active body!");
}
Body bod = maybeInline.getActiveBody();
Chain units = ((DavaBody) bod).getUnits();
if (units.size() != 1) {
throw new RuntimeException("DavaBody AST doesn't have single root.");
}
ASTNode ASTtemp = (ASTNode) units.getFirst();
if (!(ASTtemp instanceof ASTMethodNode)) {
throw new RuntimeException("Starting node of DavaBody AST is not an ASTMethodNode");
}
// restricting to methods which do not have any variables declared
ASTMethodNode toReturn = (ASTMethodNode) ASTtemp;
ASTStatementSequenceNode declarations = toReturn.getDeclarations();
if (declarations.getStatements().size() == 0) {
// inline only if there are no declarations in the method inlined
// System.out.println("No declarations in the method. we can inline this method");
return toReturn;
}
}
}
}
return null;// meaning dont inline
}
}
| 5,245
| 32.845161
| 122
|
java
|
soot
|
soot-master/src/main/java/soot/dava/DavaUnitPrinter.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2003 Ondrej Lhotak
* Copyright (C) 2004 - 2005 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractUnitPrinter;
import soot.ArrayType;
import soot.RefType;
import soot.SootClass;
import soot.SootFieldRef;
import soot.SootMethodRef;
import soot.Type;
import soot.Unit;
import soot.dava.toolkits.base.renamer.RemoveFullyQualifiedName;
import soot.jimple.ClassConstant;
import soot.jimple.Constant;
import soot.jimple.IdentityRef;
import soot.jimple.Jimple;
import soot.jimple.ThisRef;
/**
* UnitPrinter implementation for Dava.
*/
public class DavaUnitPrinter extends AbstractUnitPrinter {
private boolean eatSpace = false;
DavaBody body;
/*
* 30th March 2006, Nomair A Naeem Adding constructor so that the current methods DabaBody can be stored
*/
public DavaUnitPrinter(DavaBody body) {
this.body = body;
}
@Override
public void methodRef(SootMethodRef m) {
handleIndent();
output.append(m.getName());
}
@Override
public void fieldRef(SootFieldRef f) {
handleIndent();
output.append(f.name());
}
@Override
public void identityRef(IdentityRef r) {
handleIndent();
if (r instanceof ThisRef) {
literal("this");
} else {
throw new RuntimeException();
}
}
@Override
public void literal(String s) {
handleIndent();
if (eatSpace && " ".equals(s)) {
eatSpace = false;
return;
}
eatSpace = false;
switch (s) {
case Jimple.STATICINVOKE:
case Jimple.VIRTUALINVOKE:
case Jimple.INTERFACEINVOKE:
eatSpace = true;
return;
}
output.append(s);
}
@Override
public void type(Type t) {
handleIndent();
if (t instanceof RefType) {
SootClass sootClass = ((RefType) t).getSootClass();
String name = sootClass.getJavaStyleName();
/*
* March 30th 2006, Nomair Adding check to check that the fully qualified name can actually be removed
*/
if (!name.equals(sootClass.toString())) {
// means javaStyle name is probably shorter check that there is no class clash in imports for this
// System.out.println(">>>>Type is"+t.toString());
// System.out.println(">>>>Name is"+name);
name = RemoveFullyQualifiedName.getReducedName(body.getImportList(), sootClass.toString(), t);
}
output.append(name);
} else if (t instanceof ArrayType) {
((ArrayType) t).toString(this);
} else {
output.append(t.toString());
}
}
@Override
public void unitRef(Unit u, boolean branchTarget) {
throw new RuntimeException("Dava doesn't have unit references!");
}
@Override
public void constant(Constant c) {
if (c instanceof ClassConstant) {
handleIndent();
output.append(((ClassConstant) c).value.replace('/', '.')).append(".class");
} else {
super.constant(c);
}
}
public void addNot() {
output.append(" !");
}
public void addAggregatedOr() {
output.append(" || ");
}
public void addAggregatedAnd() {
output.append(" && ");
}
public void addLeftParen() {
output.append(" (");
}
public void addRightParen() {
output.append(") ");
}
public void printString(String s) {
output.append(s);
}
}
| 4,017
| 24.1125
| 108
|
java
|
soot
|
soot-master/src/main/java/soot/dava/DecompilationException.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2006 Nomair A. Naeem (nomair.naeem@mail.mcgill.ca)
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import java.util.*;
//import soot.util.*;
//import soot.dava.toolkits.base.finders.*;
public class DecompilationException extends RuntimeException {
private static final Logger logger = LoggerFactory.getLogger(DecompilationException.class);
public DecompilationException() {
System.out.println("DECOMPILATION INCOMPLETE:");
// printStackTrace();
}
public DecompilationException(String message) {
super("DECOMPILATION INCOMPLETE" + message);
// printStackTrace();
}
public void report() {
System.out.println("\n\nPlease report this exception to nomair.naeem@mail.mcgill.ca");
System.out.println("Please include the soot version, sample code and this output.\n\n");
}
}
| 1,620
| 31.42
| 93
|
java
|
soot
|
soot-master/src/main/java/soot/dava/MethodCallFinder.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import soot.RefType;
import soot.Scene;
import soot.SootClass;
import soot.SootMethod;
import soot.SootMethodRef;
import soot.dava.internal.AST.ASTDoWhileNode;
import soot.dava.internal.AST.ASTForLoopNode;
import soot.dava.internal.AST.ASTIfElseNode;
import soot.dava.internal.AST.ASTIfNode;
import soot.dava.internal.AST.ASTLabeledBlockNode;
import soot.dava.internal.AST.ASTMethodNode;
import soot.dava.internal.AST.ASTNode;
import soot.dava.internal.AST.ASTStatementSequenceNode;
import soot.dava.internal.AST.ASTSwitchNode;
import soot.dava.internal.AST.ASTSynchronizedBlockNode;
import soot.dava.internal.AST.ASTTryNode;
import soot.dava.internal.AST.ASTUnconditionalLoopNode;
import soot.dava.internal.AST.ASTWhileNode;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.toolkits.base.AST.analysis.DepthFirstAdapter;
import soot.dava.toolkits.base.AST.traversals.ASTParentNodeFinder;
import soot.grimp.internal.GNewInvokeExpr;
import soot.grimp.internal.GThrowStmt;
import soot.jimple.InvokeExpr;
import soot.jimple.InvokeStmt;
import soot.jimple.Stmt;
import soot.jimple.StringConstant;
public class MethodCallFinder extends DepthFirstAdapter {
ASTMethodNode underAnalysis;
DavaStaticBlockCleaner cleaner;
public MethodCallFinder(DavaStaticBlockCleaner cleaner) {
this.cleaner = cleaner;
underAnalysis = null;
}
public MethodCallFinder(boolean verbose, DavaStaticBlockCleaner cleaner) {
super(verbose);
this.cleaner = cleaner;
underAnalysis = null;
}
public void inASTMethodNode(ASTMethodNode node) {
underAnalysis = node;
}
/*
* some ASTConstuct{ ASTConstruct{ Some bodies Some Bodies Statement SequenceNode New Stmt seq node with some stmts some
* stmts ----------> Body of method to inline the invoke stmt New Stmt seq node with other stmts some other stmts Some
* other bodies Some other bodies End ASTConstruct End ASTConstruct
*/
/*
* Notice that since this class is only invoked for clinit methods this invoke statement is some invocation that occured
* within the clinit method
*/
public void inInvokeStmt(InvokeStmt s) {
InvokeExpr invokeExpr = s.getInvokeExpr();
SootMethod maybeInline = invokeExpr.getMethod();
// check whether we want to inline
ASTMethodNode toInlineASTMethod = cleaner.inline(maybeInline);
if (toInlineASTMethod == null) {
// not to inline
return;
} else {
// yes we want to inline
// we know that the method to be inlined has no declarations.
List<Object> subBodies = toInlineASTMethod.get_SubBodies();
if (subBodies.size() != 1) {
throw new RuntimeException("Found ASTMEthod node with more than one subBodies");
}
List body = (List) subBodies.get(0);
ASTParentNodeFinder finder = new ASTParentNodeFinder();
underAnalysis.apply(finder);
List<ASTStatementSequenceNode> newChangedBodyPart = createChangedBodyPart(s, body, finder);
boolean replaced = replaceSubBody(s, newChangedBodyPart, finder);
if (replaced) {
// so the invoke stmt has been replaced with the body of the
// method invoked
/*
* if the inlined method contained an assignment to a static field we want to replace that with a throw stmt
*/
StaticDefinitionFinder defFinder = new StaticDefinitionFinder(maybeInline);
toInlineASTMethod.apply(defFinder);
if (defFinder.anyFinalFieldDefined()) {
// create throw stmt to be added to inlined method
// create a SootMethodRef
SootClass runtime = Scene.v().loadClassAndSupport("java.lang.RuntimeException");
if (runtime.declaresMethod("void <init>(java.lang.String)")) {
SootMethod sootMethod = runtime.getMethod("void <init>(java.lang.String)");
SootMethodRef methodRef = sootMethod.makeRef();
RefType myRefType = RefType.v(runtime);
StringConstant tempString = StringConstant.v("This method used to have a definition of a final variable. "
+ "Dava inlined the definition into the static initializer");
List list = new ArrayList();
list.add(tempString);
GNewInvokeExpr newInvokeExpr = new GNewInvokeExpr(myRefType, methodRef, list);
GThrowStmt throwStmt = new GThrowStmt(newInvokeExpr);
AugmentedStmt augStmt = new AugmentedStmt(throwStmt);
List<AugmentedStmt> sequence = new ArrayList<AugmentedStmt>();
sequence.add(augStmt);
ASTStatementSequenceNode seqNode = new ASTStatementSequenceNode(sequence);
List<Object> subBody = new ArrayList<Object>();
subBody.add(seqNode);
toInlineASTMethod.replaceBody(subBody);
}
}
}
}
}
public List<Object> getSubBodyFromSingleSubBodyNode(ASTNode node) {
List<Object> subBodies = node.get_SubBodies();
if (subBodies.size() != 1) {
throw new RuntimeException("Found a single subBody node with more than 1 subBodies");
}
return (List<Object>) subBodies.get(0);
}
public List<Object> createNewSubBody(List<Object> orignalBody, List<ASTStatementSequenceNode> partNewBody,
Object stmtSeqNode) {
List<Object> newBody = new ArrayList<Object>();
Iterator<Object> it = orignalBody.iterator();
while (it.hasNext()) {
Object temp = it.next();
if (temp != stmtSeqNode) {
newBody.add(temp);
} else {
// breaks out of the loop as soon as stmtSeqNode is reached
break;
}
}
// dont add this stmt sequence node instead add the modified stmt seq
// nodes and the to be inline method
newBody.addAll(partNewBody);
// add remaining stuff drom the orignalBody
while (it.hasNext()) {
newBody.add(it.next());
}
return newBody;
}
public boolean replaceSubBody(InvokeStmt s, List<ASTStatementSequenceNode> newChangedBodyPart,
ASTParentNodeFinder finder) {
// get the stmt seq node of invoke stmt
Object stmtSeqNode = finder.getParentOf(s);
// find the parent node of the stmt seq node
Object ParentOfStmtSeq = finder.getParentOf(stmtSeqNode);
if (ParentOfStmtSeq == null) {
throw new RuntimeException("MethodCall FInder: parent of stmt seq node not found");
}
ASTNode node = (ASTNode) ParentOfStmtSeq;
// the decision what to replace and how to replace depends on the type
// of ASTNode
if (node instanceof ASTMethodNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTMethodNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTSynchronizedBlockNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTSynchronizedBlockNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTLabeledBlockNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTLabeledBlockNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTUnconditionalLoopNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTUnconditionalLoopNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTIfNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTIfNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTWhileNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTWhileNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTDoWhileNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTDoWhileNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTForLoopNode) {
// get the subBody to replace
List<Object> subBodyToReplace = getSubBodyFromSingleSubBodyNode(node);
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
((ASTForLoopNode) node).replaceBody(newBody);
return true;
} else if (node instanceof ASTIfElseNode) {
List<Object> subBodies = node.get_SubBodies();
if (subBodies.size() != 2) {
throw new RuntimeException("Found an ifelse ASTNode which does not have two bodies");
}
List<Object> ifBody = (List<Object>) subBodies.get(0);
List<Object> elseBody = (List<Object>) subBodies.get(1);
// find out which of these bodies has the stmt seq node with the
// invoke stmt
int subBodyNumber = -1;
Iterator<Object> it = ifBody.iterator();
while (it.hasNext()) {
Object temp = it.next();
if (temp == stmtSeqNode) {
subBodyNumber = 0;
break;
}
}
if (subBodyNumber != 0) {
it = elseBody.iterator();
while (it.hasNext()) {
Object temp = it.next();
if (temp == stmtSeqNode) {
subBodyNumber = 1;
break;
}
}
}
List<Object> subBodyToReplace = null;
if (subBodyNumber == 0) {
subBodyToReplace = ifBody;
} else if (subBodyNumber == 1) {
subBodyToReplace = elseBody;
} else {
throw new RuntimeException("Could not find the related ASTNode in the method");
}
List<Object> newBody = createNewSubBody(subBodyToReplace, newChangedBodyPart, stmtSeqNode);
if (subBodyNumber == 0) {
((ASTIfElseNode) node).replaceBody(newBody, elseBody);
return true;
} else if (subBodyNumber == 1) {
((ASTIfElseNode) node).replaceBody(ifBody, newBody);
return true;
}
} else if (node instanceof ASTTryNode) {
// NOTE THAT method INLINING Is currently only done in the tryBody
// and not the catchBody
// THe only reason for this being that mostly method calls are made
// in the try and not the catch
// get try body
List<Object> tryBody = ((ASTTryNode) node).get_TryBody();
Iterator<Object> it = tryBody.iterator();
// find whether stmtSeqNode is in the tryBody
boolean inTryBody = false;
while (it.hasNext()) {
ASTNode temp = (ASTNode) it.next();
if (temp == stmtSeqNode) {
inTryBody = true;
break;
}
}
if (!inTryBody) {
// return without making any changes
return false;
}
List<Object> newBody = createNewSubBody(tryBody, newChangedBodyPart, stmtSeqNode);
((ASTTryNode) node).replaceTryBody(newBody);
return true;
} else if (node instanceof ASTSwitchNode) {
List<Object> indexList = ((ASTSwitchNode) node).getIndexList();
Map<Object, List<Object>> index2BodyList = ((ASTSwitchNode) node).getIndex2BodyList();
Iterator<Object> it = indexList.iterator();
while (it.hasNext()) {
// going through all the cases of the switch
// statement
Object currentIndex = it.next();
List<Object> body = index2BodyList.get(currentIndex);
if (body != null) {
// this body is a list of ASTNodes
// see if it contains stmtSeqNode
boolean found = false;
Iterator<Object> itBody = body.iterator();
while (itBody.hasNext()) {
ASTNode temp = (ASTNode) itBody.next();
if (temp == stmtSeqNode) {
found = true;
break;
}
}
if (found) {
// this is the body which has the stmt seq node
List<Object> newBody = createNewSubBody(body, newChangedBodyPart, stmtSeqNode);
// put this body in the Map
index2BodyList.put(currentIndex, newBody);
// replace in actual switchNode
((ASTSwitchNode) node).replaceIndex2BodyList(index2BodyList);
return true;
}
} // if body not null
} // going through all cases
}
return false;
}
/*
* Given an invoke stmt this method finds the parent of this stmt which should always be a StatementSequenceNode Then the
* sequence is broken into three parts. The first part contains stmts till above the invoke stmt. The second part contains
* the body argument which is the body of the inlined method and the third part are the stmts below the invoke stmt
*/
public List<ASTStatementSequenceNode> createChangedBodyPart(InvokeStmt s, List body, ASTParentNodeFinder finder) {
// get parent node of invoke stmt
Object parent = finder.getParentOf(s);
if (parent == null) {
throw new RuntimeException("MethodCall FInder: parent of invoke stmt not found");
}
ASTNode parentNode = (ASTNode) parent;
if (!(parentNode instanceof ASTStatementSequenceNode)) {
throw new RuntimeException("MethodCall FInder: parent node not a stmt seq node");
}
ASTStatementSequenceNode orignal = (ASTStatementSequenceNode) parentNode;
// copying the stmts till above the inoke stmt into one stmt sequence
// node
List<AugmentedStmt> newInitialNode = new ArrayList<AugmentedStmt>();
Iterator<AugmentedStmt> it = orignal.getStatements().iterator();
while (it.hasNext()) {
AugmentedStmt as = it.next();
Stmt tempStmt = as.get_Stmt();
if (tempStmt != s) {
newInitialNode.add(as);
} else {
// the first time we get to a stmt which points to the invoke
// stmt we break
break;
}
}
// copy remaining stmts into the AFTER stmt sequence node
List<AugmentedStmt> newSecondNode = new ArrayList<AugmentedStmt>();
while (it.hasNext()) {
newSecondNode.add(it.next());
}
List<ASTStatementSequenceNode> toReturn = new ArrayList<ASTStatementSequenceNode>();
if (newInitialNode.size() != 0) {
toReturn.add(new ASTStatementSequenceNode(newInitialNode));
}
// add inline methods body
toReturn.addAll(body);
if (newSecondNode.size() != 0) {
toReturn.add(new ASTStatementSequenceNode(newSecondNode));
}
return toReturn;
}
}
| 16,075
| 36.041475
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/dava/RetriggerAnalysisException.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2003 Jerome Miecznikowski
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public class RetriggerAnalysisException extends Exception {
public RetriggerAnalysisException() {
Dava.v().log("RetriggerAnalysisException");
}
}
| 979
| 31.666667
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/dava/StaticDefinitionFinder.java
|
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.SootField;
import soot.SootMethod;
import soot.Value;
import soot.dava.toolkits.base.AST.analysis.DepthFirstAdapter;
import soot.jimple.DefinitionStmt;
import soot.jimple.FieldRef;
public class StaticDefinitionFinder extends DepthFirstAdapter {
SootMethod method;
boolean finalFieldDefined;
public StaticDefinitionFinder(SootMethod method) {
this.method = method;
finalFieldDefined = false;
}
public StaticDefinitionFinder(boolean verbose, SootMethod method) {
super(verbose);
this.method = method;
finalFieldDefined = false;
}
public void inDefinitionStmt(DefinitionStmt s) {
Value leftOp = s.getLeftOp();
if (leftOp instanceof FieldRef) {
// System.out.println("leftOp is a fieldRef:"+s);
SootField field = ((FieldRef) leftOp).getField();
// check if this is a final field
if (field.isFinal()) {
// System.out.println("the field is a final variable");
finalFieldDefined = true;
}
}
}
public boolean anyFinalFieldDefined() {
return finalFieldDefined;
}
}
| 1,897
| 27.757576
| 71
|
java
|
soot
|
soot-master/src/main/java/soot/dava/internal/AST/ASTAggregatedCondition.java
|
package soot.dava.internal.AST;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Nomair A. Naeem
* %%
* This program 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 2.1 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public abstract class ASTAggregatedCondition extends ASTCondition {
ASTCondition left;
ASTCondition right;
boolean not;// used to see if the condition has a not infront of it
public ASTAggregatedCondition(ASTCondition left, ASTCondition right) {
not = false;// by default condition does not have a not
this.left = left;
this.right = right;
}
public ASTCondition getLeftOp() {
return left;
}
public ASTCondition getRightOp() {
return right;
}
public void setLeftOp(ASTCondition left) {
this.left = left;
}
public void setRightOp(ASTCondition right) {
this.right = right;
}
public void flip() {
if (not) {
not = false;
} else {
not = true;
}
}
public boolean isNotted() {
return not;
}
}
| 1,616
| 24.265625
| 72
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.