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/baf/toolkits/base/PeepholeOptimizer.java
package soot.baf.toolkits.base; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 1999 Patrice Pominville * %% * 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.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import soot.Body; import soot.BodyTransformer; import soot.G; import soot.Singletons; /** * Driver class to run peepholes on the Baf IR. The peepholes applied must implement the Peephole interface. Peepholes are * loaded dynamically by the soot runtime; the runtime reads the file peephole.dat, in order to determine which peepholes to * apply. * * @see Peephole * @see ExamplePeephole */ public class PeepholeOptimizer extends BodyTransformer { private static final Logger logger = LoggerFactory.getLogger(PeepholeOptimizer.class); public PeepholeOptimizer(Singletons.Global g) { } public static PeepholeOptimizer v() { return G.v().soot_baf_toolkits_base_PeepholeOptimizer(); } private final String packageName = "soot.baf.toolkits.base"; private static boolean peepholesLoaded = false; private static final Object loaderLock = new Object(); private final Map<String, Class<?>> peepholeMap = new HashMap<String, Class<?>>(); /* This is the public interface to PeepholeOptimizer */ /** * The method that drives the optimizations. */ @Override protected void internalTransform(Body body, String phaseName, Map<String, String> options) { if (!peepholesLoaded) { synchronized (loaderLock) { if (!peepholesLoaded) { peepholesLoaded = true; InputStream peepholeListingStream = null; peepholeListingStream = PeepholeOptimizer.class.getResourceAsStream("/peephole.dat"); if (peepholeListingStream == null) { logger.warn("Could not find peephole.dat in the classpath"); return; } BufferedReader reader = new BufferedReader(new InputStreamReader(peepholeListingStream)); String line = null; List<String> peepholes = new LinkedList<String>(); try { line = reader.readLine(); while (line != null) { if (line.length() > 0) { if (!(line.charAt(0) == '#')) { peepholes.add(line); } } line = reader.readLine(); } } catch (IOException e) { throw new RuntimeException( "IO error occured while reading file: " + line + System.getProperty("line.separator") + e); } try { reader.close(); peepholeListingStream.close(); } catch (IOException e) { logger.debug(e.getMessage(), e); } for (String peepholeName : peepholes) { Class<?> peepholeClass; if ((peepholeClass = peepholeMap.get(peepholeName)) == null) { try { peepholeClass = Class.forName(packageName + '.' + peepholeName); } catch (ClassNotFoundException e) { throw new RuntimeException(e.toString()); } peepholeMap.put(peepholeName, peepholeClass); } } } } } boolean changed = true; while (changed) { changed = false; for (String peepholeName : peepholeMap.keySet()) { boolean peepholeWorked = true; while (peepholeWorked) { peepholeWorked = false; Peephole p = null; try { p = (Peephole) peepholeMap.get(peepholeName).newInstance(); } catch (IllegalAccessException e) { throw new RuntimeException(e.toString()); } catch (InstantiationException e) { throw new RuntimeException(e.toString()); } if (p.apply(body)) { peepholeWorked = true; changed = true; } } } } } }
4,809
30.854305
124
java
soot
soot-master/src/main/java/soot/baf/toolkits/base/StackTypesValidator.java
package soot.baf.toolkits.base; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 2021 Timothy Hoffman * %% * 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.Arrays; import java.util.EmptyStackException; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Objects; import java.util.Stack; import soot.Body; import soot.DoubleType; import soot.ErroneousType; import soot.FloatType; import soot.IntType; import soot.IntegerType; import soot.Local; import soot.LongType; import soot.NullType; import soot.RefLikeType; import soot.RefType; import soot.Type; import soot.Unit; import soot.UnknownType; import soot.baf.AddInst; import soot.baf.AndInst; import soot.baf.ArrayLengthInst; import soot.baf.ArrayReadInst; import soot.baf.ArrayWriteInst; import soot.baf.BafBody; import soot.baf.CmpInst; import soot.baf.CmpgInst; import soot.baf.CmplInst; import soot.baf.DivInst; import soot.baf.Dup1Inst; import soot.baf.Dup1_x1Inst; import soot.baf.Dup1_x2Inst; import soot.baf.Dup2Inst; import soot.baf.Dup2_x1Inst; import soot.baf.Dup2_x2Inst; import soot.baf.DynamicInvokeInst; import soot.baf.EnterMonitorInst; import soot.baf.ExitMonitorInst; import soot.baf.FieldGetInst; import soot.baf.FieldPutInst; import soot.baf.GotoInst; import soot.baf.IdentityInst; import soot.baf.IfCmpEqInst; import soot.baf.IfCmpGeInst; import soot.baf.IfCmpGtInst; import soot.baf.IfCmpLeInst; import soot.baf.IfCmpLtInst; import soot.baf.IfCmpNeInst; import soot.baf.IfEqInst; import soot.baf.IfGeInst; import soot.baf.IfGtInst; import soot.baf.IfLeInst; import soot.baf.IfLtInst; import soot.baf.IfNeInst; import soot.baf.IfNonNullInst; import soot.baf.IfNullInst; import soot.baf.IncInst; import soot.baf.Inst; import soot.baf.InstSwitch; import soot.baf.InstanceCastInst; import soot.baf.InstanceOfInst; import soot.baf.InterfaceInvokeInst; import soot.baf.JSRInst; import soot.baf.LoadInst; import soot.baf.LookupSwitchInst; import soot.baf.MulInst; import soot.baf.NegInst; import soot.baf.NewArrayInst; import soot.baf.NewInst; import soot.baf.NewMultiArrayInst; import soot.baf.NopInst; import soot.baf.OrInst; import soot.baf.PopInst; import soot.baf.PrimitiveCastInst; import soot.baf.PushInst; import soot.baf.RemInst; import soot.baf.ReturnInst; import soot.baf.ReturnVoidInst; import soot.baf.ShlInst; import soot.baf.ShrInst; import soot.baf.SpecialInvokeInst; import soot.baf.StaticGetInst; import soot.baf.StaticInvokeInst; import soot.baf.StaticPutInst; import soot.baf.StoreInst; import soot.baf.SubInst; import soot.baf.SwapInst; import soot.baf.TableSwitchInst; import soot.baf.ThrowInst; import soot.baf.UshrInst; import soot.baf.VirtualInvokeInst; import soot.baf.XorInst; import soot.jimple.IdentityRef; import soot.toolkits.exceptions.PedanticThrowAnalysis; import soot.toolkits.graph.ExceptionalUnitGraphFactory; import soot.toolkits.scalar.ForwardFlowAnalysis; import soot.validation.BodyValidator; import soot.validation.ValidationException; /** * Checks if the locals and the operand stack will contain the correct types for each instruction in the {@link BafBody}. * * NOTE: This validator assumes that each local will hold a single {@link Type} throughout the method. However, that is * actually a stronger requirement than necessary for bytecode. In fact, after running the * {@link soot.toolkits.scalar.LocalPacker} pass, there will likely be cases that are reported by this validator which are * actually safe for bytecode. * * @author Timothy Hoffman */ public enum StackTypesValidator implements BodyValidator { INSTANCE; public static StackTypesValidator v() { return INSTANCE; } @Override public boolean isBasicValidator() { return false; } @Override public void validate(Body body, List<ValidationException> exceptions) { assert (body instanceof BafBody); VMStateAnalysis a = new VMStateAnalysis((BafBody) body, exceptions); // Scan through all Units in the body and make sure the stack types // and local types are valid for the semantics of each Unit. InstSwitch verif = a.createVerifier(); for (Unit u : body.getUnits()) { u.apply(verif); } } private static final class BitArray implements Cloneable { // number of bits required to store each value // NOTE: Although 3 is sufficient, using a power of 2 gives a reasonable // speedup for only a small trade-off in terms of memory usage. public static final int BITS_PER_VAL = 4; // number of values to store at each array index public static final int VALS_PER_IDX = Integer.SIZE / BITS_PER_VAL; // rightmost 'BITS_PER_VAL' bits will be '1' public static final int VAL_MASK = 0xFFFFFFFF >>> (Integer.SIZE - BITS_PER_VAL); private final int[] data; public BitArray(int numValues) { assert (numValues >= 0); this.data = new int[numValues / VALS_PER_IDX + (numValues % VALS_PER_IDX == 0 ? 0 : 1)]; } private BitArray(int[] otherData) { int count = otherData.length; int[] temp = new int[count]; System.arraycopy(otherData, 0, temp, 0, count); this.data = temp; } public int get(int index) { final int arrIdx = index / VALS_PER_IDX; final int bitShift = (index % VALS_PER_IDX) * BITS_PER_VAL; // Shift (unsigned) the relevant value to the right-most bits and then mask. return (this.data[arrIdx] >>> bitShift) & VAL_MASK; } public void set(int index, int value) { if ((value & VAL_MASK) != value) { throw new IllegalArgumentException(value + " does not fit in " + BITS_PER_VAL + " bits!"); } final int arrIdx = index / VALS_PER_IDX; final int bitShift = (index % VALS_PER_IDX) * BITS_PER_VAL; // First, use the inverse of 'VAL_MASK' to set position 'i' to all zeros and then set the new value. this.data[arrIdx] = (this.data[arrIdx] & Integer.rotateLeft(~VAL_MASK, bitShift)) | (value << bitShift); } @Override public int hashCode() { return Arrays.hashCode(this.data); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || BitArray.class != obj.getClass()) { return false; } final BitArray other = (BitArray) obj; return Arrays.equals(this.data, other.data); } @Override public BitArray clone() { return new BitArray(this.data); } public void copyTo(BitArray dest) { if (this != dest) { assert (this.data.length == dest.data.length); System.arraycopy(this.data, 0, dest.data, 0, this.data.length); } } } private static final class VMStateAnalysis extends ForwardFlowAnalysis<Unit, BitArray> { protected static final Type TYPE_UNK = UnknownType.v(); protected static final Type TYPE_REF = RefType.v(); protected static final Type TYPE_INT = IntType.v(); protected static final Type TYPE_DUB = DoubleType.v(); protected static final Type TYPE_FLT = FloatType.v(); protected static final Type TYPE_LNG = LongType.v(); protected static final Type TYPE_ERR = ErroneousType.v(); // NOTE: UnknownType is 0 so that a new BitArray is trivially all UnknownType protected static final int TYPE_UNK_BITS = 0b000; protected static final int TYPE_ERR_BITS = 0b111; /** * Convert all reference-like types to the canonical reference instance and all subclasses of {@link IntegerType} to * {@link IntType} but preserve other types. * * @param t * * @return */ protected static Type canonicalize(Type t) { return (t instanceof RefLikeType || t instanceof NullType) ? TYPE_REF : (t instanceof IntegerType) ? TYPE_INT : t; } /** * Performs {@link #canonicalize(Type)} and converts the canonical {@link Type} to its 3-bit representation. * * @param type * * @return */ protected static int typeToBits(Type type) { if (type == TYPE_UNK) { return TYPE_UNK_BITS; } else if (type == TYPE_INT || type instanceof IntegerType) { return 0b010; } else if (type == TYPE_REF || type instanceof RefLikeType || type instanceof NullType) { return 0b001; } else if (type == TYPE_DUB) { return 0b011; } else if (type == TYPE_FLT) { return 0b100; } else if (type == TYPE_LNG) { return 0b101; } else if (type == TYPE_ERR) { return TYPE_ERR_BITS; } else { throw new IllegalArgumentException(Objects.toString(type)); } } /** * Convert the given 3-bit representation (right-most bits of the argument) to its canonical {@link Type}. * * @param bits * * @return */ protected static Type bitsToType(int bits) { switch (bits) { case TYPE_UNK_BITS: return TYPE_UNK; case 0b001: return TYPE_REF; case 0b010: return TYPE_INT; case 0b011: return TYPE_DUB; case 0b100: return TYPE_FLT; case 0b101: return TYPE_LNG; case TYPE_ERR_BITS: return TYPE_ERR; default: throw new IllegalArgumentException(Integer.toString(bits)); } } // protected final List<ValidationException> exceptions; // Map each Unit to the operand stack prior to executing the Unit protected final Map<Unit, Stack<Type>> opStacks; // Map each Local to array index for the Local->Type arrays protected final Map<Local, Integer> varToIdx; // protected final BitArray initFlow; public VMStateAnalysis(BafBody body, List<ValidationException> exceptions) { super(ExceptionalUnitGraphFactory.createExceptionalUnitGraph(body, PedanticThrowAnalysis.v(), false)); this.exceptions = exceptions; this.opStacks = OpStackCalculator.calculateStacks(body); assert (opStacks.keySet().equals(new HashSet<>(body.getUnits()))); { HashMap<Local, Integer> varToIdx = new HashMap<>(); int varNum = 0; for (Local l : body.getLocals()) { varToIdx.put(l, varNum++); } this.varToIdx = varToIdx; this.initFlow = new BitArray(varNum); } doAnalysis(); } protected static String toString(Type t) { return (t == TYPE_REF) ? "RefType" : t.toString(); } protected int indexOf(Local loc) { Integer idx = varToIdx.get(loc); assert (idx != null) : "Unrecognized Local: " + loc; return idx; } protected Type peekStackAt(Unit u) { try { return opStacks.get(u).peek(); } catch (EmptyStackException ex) { exceptions.add(new ValidationException(u, "Stack is empty!")); return ErroneousType.v(); } } @Override protected void flowThrough(final BitArray in, final Unit u, final BitArray out) { assert (u instanceof Inst); // Initialize the output Local types from input local Types copy(in, out); // Update Locals based on the current instruction if (u instanceof IdentityInst) { IdentityInst i = (IdentityInst) u; assert (i.getLeftOp() instanceof Local); assert (i.getRightOp() instanceof IdentityRef); // Type of the LHS Local is updated to the RHS type int x = indexOf((Local) i.getLeftOp()); out.set(x, merge(out.get(x), typeToBits(i.getRightOp().getType()), u)); } else if (u instanceof StoreInst) { StoreInst i = (StoreInst) u; // Type of the Local is updated to the Type from the top of the stack int x = indexOf(i.getLocal()); out.set(x, merge(out.get(x), typeToBits(peekStackAt(u)), u)); } } @Override @SuppressWarnings("unchecked") protected BitArray newInitialFlow() { return initFlow.clone(); } @Override protected boolean omissible(Unit u) { return !(u instanceof IdentityInst) && !(u instanceof StoreInst); } @Override protected void copy(BitArray in, BitArray out) { in.copyTo(out); } @Override protected void merge(BitArray in1, BitArray in2, BitArray out) { merge(null, in1, in2, out); } @Override protected void merge(Unit successor, BitArray in1, BitArray in2, BitArray out) { if (in1.equals(in2)) { copy(in1, out); } else { for (int i = 0, e = this.varToIdx.size(); i < e; i++) { out.set(i, merge(in1.get(i), in2.get(i), successor)); } } } private int merge(final int in1, final int in2, final Unit u) { // If they are identical, the output type is the same. if (in1 == in2) { return in1; } // If either type is unknown (i.e. uninitialized), return the other. if (in1 == TYPE_UNK_BITS) { return in2; } else if (in2 == TYPE_UNK_BITS) { return in1; } // If either type is erroneous, the output type is too. if (in1 == TYPE_ERR_BITS || in2 == TYPE_ERR_BITS) { return TYPE_ERR_BITS; } // If there is a mismatch, return erroneous type. exceptions.add(new ValidationException(u, "Ambiguous type: '" + toString(bitsToType(in1)) + "' vs '" + toString(bitsToType(in2)) + "'")); return TYPE_ERR_BITS; } public InstSwitch createVerifier() { return new InstSwitch() { private void checkType(Inst i, Type expect, Type actual) { Type canonExpect = canonicalize(expect); Type canonActual = canonicalize(actual); if (!Objects.equals(canonExpect, canonActual)) { exceptions.add(new ValidationException(i, "Expected " + VMStateAnalysis.toString(canonExpect) + " but found " + VMStateAnalysis.toString(canonActual))); } } // Top of the stack must be 'expect' Type private void checkStack1(Inst i, Type expect) { checkType(i, expect, peekStackAt(i)); } // Top 2 on the stack must be 'expect' Type private void checkStack2(Inst i, Type expect) { checkStackN(i, expect, 2); } // Top 2 on the stack must be 'expect1' then 'expect2' private void checkStack2(Inst i, Type expect1, Type expect2) { Stack<Type> stk = opStacks.get(i); int idx = stk.size(); checkType(i, expect1, stk.elementAt(--idx)); checkType(i, expect2, stk.elementAt(--idx)); } // Top 3 on the stack must be 'expect1' then 'expect2' then 'expect3' private void checkStack3(Inst i, Type expect1, Type expect2, Type expect3) { Stack<Type> stk = opStacks.get(i); int idx = stk.size(); checkType(i, expect1, stk.elementAt(--idx)); checkType(i, expect2, stk.elementAt(--idx)); checkType(i, expect3, stk.elementAt(--idx)); } // Top N on the stack must be 'expect' Type private void checkStackN(Inst i, Type expect, int count) { Stack<Type> stk = opStacks.get(i); int idx = stk.size(); for (int j = 0; j < count; j++) { checkType(i, expect, stk.elementAt(--idx)); } } @Override public void caseIdentityInst(IdentityInst i) { // No stack or Local use } @Override public void caseNopInst(NopInst i) { // No stack or Local use } @Override public void caseGotoInst(GotoInst i) { // No stack or Local use } @Override public void caseJSRInst(JSRInst i) { throw new UnsupportedOperationException("deprecated bytecode"); } @Override public void caseReturnVoidInst(ReturnVoidInst i) { // No stack or Local use } @Override public void caseReturnInst(ReturnInst i) { // The top of the stack must match the type expected by the instruction. checkStack1(i, i.getOpType()); } @Override public void casePushInst(PushInst i) { // No stack or Local use } @Override public void casePopInst(PopInst i) { // No stack or Local use } @Override public void caseStoreInst(StoreInst i) { // The top of the stack must match the type expected by the instruction. checkStack1(i, i.getOpType()); } @Override public void caseLoadInst(LoadInst i) { // The type of the Local must match the type expected by the instruction. checkType(i, i.getOpType(), bitsToType(getFlowBefore(i).get(indexOf(i.getLocal())))); } @Override public void caseArrayWriteInst(ArrayWriteInst i) { // Top of stack contains the value with the Type expected by the // instruction, beneath that is the index then array reference. checkStack3(i, i.getOpType(), TYPE_INT, TYPE_REF); } @Override public void caseArrayReadInst(ArrayReadInst i) { // Top of stack is an index with an array reference beneath. checkStack2(i, TYPE_INT, TYPE_REF); } @Override public void caseArrayLengthInst(ArrayLengthInst i) { checkStack1(i, TYPE_REF); } @Override public void caseNewArrayInst(NewArrayInst i) { checkStack1(i, TYPE_INT); } @Override public void caseNewMultiArrayInst(NewMultiArrayInst i) { checkStackN(i, TYPE_INT, i.getDimensionCount()); } @Override public void caseIfNullInst(IfNullInst i) { checkStack1(i, TYPE_REF); } @Override public void caseIfNonNullInst(IfNonNullInst i) { checkStack1(i, TYPE_REF); } @Override public void caseIfEqInst(IfEqInst i) { checkStack1(i, TYPE_INT); } @Override public void caseIfNeInst(IfNeInst i) { checkStack1(i, TYPE_INT); } @Override public void caseIfGtInst(IfGtInst i) { checkStack1(i, TYPE_INT); } @Override public void caseIfGeInst(IfGeInst i) { checkStack1(i, TYPE_INT); } @Override public void caseIfLtInst(IfLtInst i) { checkStack1(i, TYPE_INT); } @Override public void caseIfLeInst(IfLeInst i) { checkStack1(i, TYPE_INT); } @Override public void caseIfCmpEqInst(IfCmpEqInst i) { checkStack2(i, i.getOpType()); } @Override public void caseIfCmpNeInst(IfCmpNeInst i) { checkStack2(i, i.getOpType()); } @Override public void caseIfCmpGtInst(IfCmpGtInst i) { checkStack2(i, i.getOpType()); } @Override public void caseIfCmpGeInst(IfCmpGeInst i) { checkStack2(i, i.getOpType()); } @Override public void caseIfCmpLtInst(IfCmpLtInst i) { checkStack2(i, i.getOpType()); } @Override public void caseIfCmpLeInst(IfCmpLeInst i) { checkStack2(i, i.getOpType()); } @Override public void caseCmpInst(CmpInst i) { checkStack2(i, i.getOpType()); } @Override public void caseCmpgInst(CmpgInst i) { checkStack2(i, i.getOpType()); } @Override public void caseCmplInst(CmplInst i) { checkStack2(i, i.getOpType()); } @Override public void caseStaticGetInst(StaticGetInst i) { // No stack or Local use } @Override public void caseStaticPutInst(StaticPutInst i) { checkStack1(i, i.getFieldRef().type()); } @Override public void caseFieldGetInst(FieldGetInst i) { checkStack1(i, TYPE_REF); } @Override public void caseFieldPutInst(FieldPutInst i) { // Top of stack contains the value with the Type expected by the // instruction, beneath that is base object reference. checkStack2(i, i.getFieldRef().type(), TYPE_REF); } @Override public void caseInstanceCastInst(InstanceCastInst i) { checkStack1(i, TYPE_REF); } @Override public void caseInstanceOfInst(InstanceOfInst i) { checkStack1(i, TYPE_REF); } @Override public void casePrimitiveCastInst(PrimitiveCastInst i) { checkStack1(i, i.getFromType()); } // Top of stack should have pTypes in reverse followed by the base // type (if not null). private void checkStackForParams(Inst i, List<Type> pTypes, Type baseType) { Stack<Type> stk = opStacks.get(i); int idx = stk.size(); final int numParams = pTypes.size(); if (numParams > 0) { for (ListIterator<Type> it = pTypes.listIterator(numParams); it.hasPrevious();) { Type t = it.previous(); checkType(i, t, stk.elementAt(--idx)); } } if (baseType != null) { checkType(i, baseType, stk.elementAt(--idx)); } } @Override public void caseDynamicInvokeInst(DynamicInvokeInst i) { // Stack contains the parameters in reverse order. checkStackForParams(i, i.getMethodRef().getParameterTypes(), null); } @Override public void caseStaticInvokeInst(StaticInvokeInst i) { // Stack contains the parameters in reverse order. checkStackForParams(i, i.getMethodRef().getParameterTypes(), null); } @Override public void caseVirtualInvokeInst(VirtualInvokeInst i) { // Stack contains the parameters in reverse order then the base object reference. checkStackForParams(i, i.getMethodRef().getParameterTypes(), TYPE_REF); } @Override public void caseInterfaceInvokeInst(InterfaceInvokeInst i) { // Stack contains the parameters in reverse order then the base object reference. checkStackForParams(i, i.getMethodRef().getParameterTypes(), TYPE_REF); } @Override public void caseSpecialInvokeInst(SpecialInvokeInst i) { // Stack contains the parameters in reverse order then the base object reference. checkStackForParams(i, i.getMethodRef().getParameterTypes(), TYPE_REF); } @Override public void caseThrowInst(ThrowInst i) { checkStack1(i, TYPE_REF); } @Override public void caseAndInst(AndInst i) { checkStack2(i, i.getOpType()); } @Override public void caseOrInst(OrInst i) { checkStack2(i, i.getOpType()); } @Override public void caseXorInst(XorInst i) { checkStack2(i, i.getOpType()); } @Override public void caseAddInst(AddInst i) { checkStack2(i, i.getOpType()); } @Override public void caseSubInst(SubInst i) { checkStack2(i, i.getOpType()); } @Override public void caseMulInst(MulInst i) { checkStack2(i, i.getOpType()); } @Override public void caseDivInst(DivInst i) { checkStack2(i, i.getOpType()); } @Override public void caseRemInst(RemInst i) { checkStack2(i, i.getOpType()); } @Override public void caseShlInst(ShlInst i) { // Top of stack is an integer with the operand value underneath. checkStack2(i, TYPE_INT, i.getOpType()); } @Override public void caseShrInst(ShrInst i) { // Top of stack is an integer with the operand value underneath. checkStack2(i, TYPE_INT, i.getOpType()); } @Override public void caseUshrInst(UshrInst i) { // Top of stack is an integer with the operand value underneath. checkStack2(i, TYPE_INT, i.getOpType()); } @Override public void caseNegInst(NegInst i) { checkStack1(i, i.getOpType()); } @Override public void caseIncInst(IncInst i) { // The type of the Local must be an integer type. checkType(i, TYPE_INT, bitsToType(getFlowBefore(i).get(indexOf(i.getLocal())))); } @Override public void caseNewInst(NewInst i) { // No stack or Local use } @Override public void caseSwapInst(SwapInst i) { // No stack or Local use (only stack modification) } @Override public void caseDup1Inst(Dup1Inst i) { // No stack or Local use (only stack modification) } @Override public void caseDup2Inst(Dup2Inst i) { // No stack or Local use (only stack modification) } @Override public void caseDup1_x1Inst(Dup1_x1Inst i) { // No stack or Local use (only stack modification) } @Override public void caseDup1_x2Inst(Dup1_x2Inst i) { // No stack or Local use (only stack modification) } @Override public void caseDup2_x1Inst(Dup2_x1Inst i) { // No stack or Local use (only stack modification) } @Override public void caseDup2_x2Inst(Dup2_x2Inst i) { // No stack or Local use (only stack modification) } @Override public void caseLookupSwitchInst(LookupSwitchInst i) { checkStack1(i, TYPE_INT); } @Override public void caseTableSwitchInst(TableSwitchInst i) { checkStack1(i, TYPE_INT); } @Override public void caseEnterMonitorInst(EnterMonitorInst i) { checkStack1(i, TYPE_REF); } @Override public void caseExitMonitorInst(ExitMonitorInst i) { checkStack1(i, TYPE_REF); } }; } } }
26,972
29.616345
122
java
soot
soot-master/src/main/java/soot/baf/toolkits/base/StoreChainOptimizer.java
package soot.baf.toolkits.base; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 1997 - 2018 Raja Vallée-Rai and others * %% * 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.Map; import java.util.Set; import soot.Body; import soot.BodyTransformer; import soot.G; import soot.Local; import soot.Singletons; import soot.Unit; import soot.baf.PushInst; import soot.baf.StoreInst; import soot.toolkits.scalar.Pair; /** * Due to local packing, we may have chains of assignments to the same local. * * push null; store.r $r2; * * push null; store.r $r2; * * This transformer eliminates the redundant push/store instructions. * * @author Steven Arzt */ public class StoreChainOptimizer extends BodyTransformer { public StoreChainOptimizer(Singletons.Global g) { } public static StoreChainOptimizer v() { return G.v().soot_baf_toolkits_base_StoreChainOptimizer(); } @Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { // We keep track of all the stored values Map<Local, Pair<Unit, Unit>> stores = new HashMap<Local, Pair<Unit, Unit>>(); Set<Unit> toRemove = new HashSet<Unit>(); Unit lastPush = null; for (Unit u : b.getUnits()) { // If we can jump here from somewhere, do not modify this code if (!u.getBoxesPointingToThis().isEmpty()) { stores.clear(); lastPush = null; } else if (u instanceof PushInst) { // Emulate pushing stuff on the stack lastPush = u; } else if (u instanceof StoreInst && lastPush != null) { StoreInst si = (StoreInst) u; Pair<Unit, Unit> pushStorePair = stores.get(si.getLocal()); if (pushStorePair != null) { // We can remove the push and the store toRemove.add(pushStorePair.getO1()); toRemove.add(pushStorePair.getO2()); } stores.put(si.getLocal(), new Pair<Unit, Unit>(lastPush, u)); } else { // We're outside of the trivial initialization chain stores.clear(); lastPush = null; } } b.getUnits().removeAll(toRemove); } }
2,867
29.189474
91
java
soot
soot-master/src/main/java/soot/coffi/AnnotationDefault_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 AnnotationDefault attribute in every method indicating the default value of the element * represented by the method_info structure * * @see attribute_info * @see method_info#attributes * @author Jennifer Lhotak */ public class AnnotationDefault_attribute extends attribute_info { /** Default value. */ public element_value default_value; }
1,206
31.621622
118
java
soot
soot-master/src/main/java/soot/coffi/BBQ.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.ArrayList; import java.util.NoSuchElementException; /** * A queue of BasicBlocks. * * @author Clark Verbrugge * @see BasicBlock */ final class BBQ { private final ArrayList<BasicBlock> q = new ArrayList<BasicBlock>(); /** * Adds a block to the end of the queue, but only if its <i>inq</i> flag is false. * * @param b * the Basic Block in question. * @see BasicBlock#inq */ public void push(BasicBlock b) { if (b.inq != true) { // ensure only in queue once... b.inq = true; q.add(b); } } /** * Removes the first block in the queue (and resets its <i>inq</i> flag). * * @return BasicBlock which was first. * @exception java.util.NoSuchElementException * if the queue is empty. * @see BasicBlock#inq */ public BasicBlock pull() throws NoSuchElementException { if (q.size() == 0) { throw new NoSuchElementException("Pull from empty BBQ"); } BasicBlock b = (q.get(0)); q.remove(0); b.inq = false; return b; } /** * Answers whether a block is in the queue or not. * * @param BasicBlock * in question. * @return <i>true</i> if it is, <i>false</i> if it ain't. * @see BasicBlock#inq */ public boolean contains(BasicBlock b) { return b.inq; } /** * Answers the size of the queue. * * @return size of the queue. */ public int size() { return q.size(); } /** * Answers whether the queue is empty * * @return <i>true</i> if it is, <i>false</i> if it ain't. */ public boolean isEmpty() { return q.isEmpty(); } /** Empties the queue of all blocks (and resets their <i>inq</i> flags). */ public void clear() { BasicBlock b; for (BasicBlock basicBlock : q) { b = (basicBlock); b.inq = false; } q.clear(); } }
2,693
23.490909
84
java
soot
soot-master/src/main/java/soot/coffi/BasicBlock.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 java.util.Set; import java.util.Vector; import soot.G; import soot.jimple.Stmt; import soot.util.ArraySet; /** * Represents one basic block in a control flow graph. * * @see CFG * @see ClassFile#parse * @author Clark Verbrugge */ class BasicBlock { /** Number of instructions in this block. */ public int size; /** Head of the list of instructions. */ public Instruction head; /** * Tail of the list of instructions. * <p> * Normally, the last instruction will have a next pointer with value <i>null</i>. After a Instruction sequences are * reconstructed though, the instruction lists are rejoined in order, and so the tail instruction will not have a * <i>null</i> next pointer. * * @see CFG#reconstructInstructions */ public Instruction tail; /** * Vector of predecessor BasicBlocks. * * @see java.util.Vector */ public Vector<BasicBlock> succ; /** * Vector of successor BasicBlocks. * * @see java.util.Vector */ public Vector<BasicBlock> pred; public boolean inq; /** Flag for whether starting an exception or not. */ public boolean beginException; /** Flag for whether starting main code block or not. */ public boolean beginCode; /** * Flag for semantic stack analysis fixup pass. * * @see CFG#jimplify */ boolean done; /** Next BasicBlock in the CFG, in the parse order. */ public BasicBlock next; /** Unique (among basic blocks) id. */ public long id; // unique id List<Stmt> statements; Set addressesToFixup = new ArraySet(); soot.jimple.Stmt getHeadJStmt() { return statements.get(0); } soot.jimple.Stmt getTailJStmt() { return statements.get(statements.size() - 1); } public BasicBlock(Instruction insts) { id = G.v().coffi_BasicBlock_ids++; head = insts; tail = head; size = 0; if (head != null) { size++; while (tail.next != null) { size++; tail = tail.next; } } succ = new Vector<BasicBlock>(2, 10); pred = new Vector<BasicBlock>(2, 3); } public BasicBlock(Instruction headinsn, Instruction tailinsn) { id = G.v().coffi_BasicBlock_ids++; head = headinsn; tail = tailinsn; succ = new Vector<BasicBlock>(2, 10); pred = new Vector<BasicBlock>(2, 3); } /** * Computes a hash code for this block from the label of the first instruction in its contents. * * @return the hash code. * @see Instruction#label */ public int hashCode() { return (new Integer(head.label)).hashCode(); } /** * True if this block represents the same piece of code. Basically compares labels of the head instructions. * * @param b * block to compare against. * @return <i>true</i> if they do, <i>false</i> if they don't. */ public boolean equals(BasicBlock b) { return (this == b); } /** * For printing the string "BB: " + id. */ public String toString() { return "BB: " + id; } }
3,827
24.52
118
java
soot
soot-master/src/main/java/soot/coffi/BootstrapMethods_attribute.java
package soot.coffi; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 2012 Eric Bodden * %% * 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 exactly one BootstrapMethods attribute in every class file. * * @author Eric Bodden * @see http://www.xiebiao.com/docs/javase/7/api/java/lang/invoke/package-summary.html#bsmattr */ class BootstrapMethods_attribute extends attribute_info { // indices to method handles public short[] method_handles; // arguments to method handles, in same order as above, i.e., arg_indices[i] holds the arguments to method_handles[i] public short[][] arg_indices; }
1,305
31.65
119
java
soot
soot-master/src/main/java/soot/coffi/ByteCode.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; /** * Procedural code for parsing and otherwise handling bytecode. * * @author Clark Verbrugge */ class ByteCode { private static final Logger logger = LoggerFactory.getLogger(ByteCode.class); public static final int NOP = 0; public static final int ACONST_NULL = 1; public static final int ICONST_M1 = 2; public static final int ICONST_0 = 3; public static final int ICONST_1 = 4; public static final int ICONST_2 = 5; public static final int ICONST_3 = 6; public static final int ICONST_4 = 7; public static final int ICONST_5 = 8; public static final int LCONST_0 = 9; public static final int LCONST_1 = 10; public static final int FCONST_0 = 11; public static final int FCONST_1 = 12; public static final int FCONST_2 = 13; public static final int DCONST_0 = 14; public static final int DCONST_1 = 15; public static final int BIPUSH = 16; public static final int SIPUSH = 17; public static final int LDC1 = 18; public static final int LDC2 = 19; public static final int LDC2W = 20; public static final int ILOAD = 21; public static final int LLOAD = 22; public static final int FLOAD = 23; public static final int DLOAD = 24; public static final int ALOAD = 25; public static final int ILOAD_0 = 26; public static final int ILOAD_1 = 27; public static final int ILOAD_2 = 28; public static final int ILOAD_3 = 29; public static final int LLOAD_0 = 30; public static final int LLOAD_1 = 31; public static final int LLOAD_2 = 32; public static final int LLOAD_3 = 33; public static final int FLOAD_0 = 34; public static final int FLOAD_1 = 35; public static final int FLOAD_2 = 36; public static final int FLOAD_3 = 37; public static final int DLOAD_0 = 38; public static final int DLOAD_1 = 39; public static final int DLOAD_2 = 40; public static final int DLOAD_3 = 41; public static final int ALOAD_0 = 42; public static final int ALOAD_1 = 43; public static final int ALOAD_2 = 44; public static final int ALOAD_3 = 45; public static final int IALOAD = 46; public static final int LALOAD = 47; public static final int FALOAD = 48; public static final int DALOAD = 49; public static final int AALOAD = 50; public static final int BALOAD = 51; public static final int CALOAD = 52; public static final int SALOAD = 53; public static final int ISTORE = 54; public static final int LSTORE = 55; public static final int FSTORE = 56; public static final int DSTORE = 57; public static final int ASTORE = 58; public static final int ISTORE_0 = 59; public static final int ISTORE_1 = 60; public static final int ISTORE_2 = 61; public static final int ISTORE_3 = 62; public static final int LSTORE_0 = 63; public static final int LSTORE_1 = 64; public static final int LSTORE_2 = 65; public static final int LSTORE_3 = 66; public static final int FSTORE_0 = 67; public static final int FSTORE_1 = 68; public static final int FSTORE_2 = 69; public static final int FSTORE_3 = 70; public static final int DSTORE_0 = 71; public static final int DSTORE_1 = 72; public static final int DSTORE_2 = 73; public static final int DSTORE_3 = 74; public static final int ASTORE_0 = 75; public static final int ASTORE_1 = 76; public static final int ASTORE_2 = 77; public static final int ASTORE_3 = 78; public static final int IASTORE = 79; public static final int LASTORE = 80; public static final int FASTORE = 81; public static final int DASTORE = 82; public static final int AASTORE = 83; public static final int BASTORE = 84; public static final int CASTORE = 85; public static final int SASTORE = 86; public static final int POP = 87; public static final int POP2 = 88; public static final int DUP = 89; public static final int DUP_X1 = 90; public static final int DUP_X2 = 91; public static final int DUP2 = 92; public static final int DUP2_X1 = 93; public static final int DUP2_X2 = 94; public static final int SWAP = 95; public static final int IADD = 96; public static final int LADD = 97; public static final int FADD = 98; public static final int DADD = 99; public static final int ISUB = 100; public static final int LSUB = 101; public static final int FSUB = 102; public static final int DSUB = 103; public static final int IMUL = 104; public static final int LMUL = 105; public static final int FMUL = 106; public static final int DMUL = 107; public static final int IDIV = 108; public static final int LDIV = 109; public static final int FDIV = 110; public static final int DDIV = 111; public static final int IREM = 112; public static final int LREM = 113; public static final int FREM = 114; public static final int DREM = 115; public static final int INEG = 116; public static final int LNEG = 117; public static final int FNEG = 118; public static final int DNEG = 119; public static final int ISHL = 120; public static final int LSHL = 121; public static final int ISHR = 122; public static final int LSHR = 123; public static final int IUSHR = 124; public static final int LUSHR = 125; public static final int IAND = 126; public static final int LAND = 127; public static final int IOR = 128; public static final int LOR = 129; public static final int IXOR = 130; public static final int LXOR = 131; public static final int IINC = 132; public static final int I2L = 133; public static final int I2F = 134; public static final int I2D = 135; public static final int L2I = 136; public static final int L2F = 137; public static final int L2D = 138; public static final int F2I = 139; public static final int F2L = 140; public static final int F2D = 141; public static final int D2I = 142; public static final int D2L = 143; public static final int D2F = 144; public static final int INT2BYTE = 145; public static final int INT2CHAR = 146; public static final int INT2SHORT = 147; public static final int LCMP = 148; public static final int FCMPL = 149; public static final int FCMPG = 150; public static final int DCMPL = 151; public static final int DCMPG = 152; public static final int IFEQ = 153; public static final int IFNE = 154; public static final int IFLT = 155; public static final int IFGE = 156; public static final int IFGT = 157; public static final int IFLE = 158; public static final int IF_ICMPEQ = 159; public static final int IF_ICMPNE = 160; public static final int IF_ICMPLT = 161; public static final int IF_ICMPGE = 162; public static final int IF_ICMPGT = 163; public static final int IF_ICMPLE = 164; public static final int IF_ACMPEQ = 165; public static final int IF_ACMPNE = 166; public static final int GOTO = 167; public static final int JSR = 168; public static final int RET = 169; public static final int TABLESWITCH = 170; public static final int LOOKUPSWITCH = 171; public static final int IRETURN = 172; public static final int LRETURN = 173; public static final int FRETURN = 174; public static final int DRETURN = 175; public static final int ARETURN = 176; public static final int RETURN = 177; public static final int GETSTATIC = 178; public static final int PUTSTATIC = 179; public static final int GETFIELD = 180; public static final int PUTFIELD = 181; public static final int INVOKEVIRTUAL = 182; public static final int INVOKENONVIRTUAL = 183; public static final int INVOKESTATIC = 184; public static final int INVOKEINTERFACE = 185; public static final int INVOKEDYNAMIC = 186; public static final int NEW = 187; public static final int NEWARRAY = 188; public static final int ANEWARRAY = 189; public static final int ARRAYLENGTH = 190; public static final int ATHROW = 191; public static final int CHECKCAST = 192; public static final int INSTANCEOF = 193; public static final int MONITORENTER = 194; public static final int MONITOREXIT = 195; public static final int WIDE = 196; public static final int MULTIANEWARRAY = 197; public static final int IFNULL = 198; public static final int IFNONNULL = 199; public static final int GOTO_W = 200; public static final int JSR_W = 201; public static final int BREAKPOINT = 202; /* * public static final int = 203; public static final int = 204; public static final int = 205; public static final int = * 206; public static final int = 207; public static final int = 208; */ public static final int RET_W = 209; /* * public static final int = 210; public static final int = 211; public static final int = 212; public static final int = * 213; public static final int = 214; public static final int = 215; public static final int = 216; public static final * int = 217; public static final int = 218; public static final int = 219; public static final int = 220; public static * final int = 221; public static final int = 222; public static final int = 223; public static final int = 224; public * static final int = 225; public static final int = 226; public static final int = 227; public static final int = 228; * public static final int = 229; public static final int = 230; public static final int = 231; public static final int = * 232; public static final int = 233; public static final int = 234; public static final int = 235; public static final * int = 236; public static final int = 237; public static final int = 238; public static final int = 239; public static * final int = 240; public static final int = 241; public static final int = 242; public static final int = 243; public * static final int = 244; public static final int = 245; public static final int = 246; public static final int = 247; * public static final int = 248; public static final int = 249; public static final int = 250; public static final int = * 251; public static final int = 252; public static final int = 253; public static final int = 254; public static final * int = 255; */ private int icount; private Instruction instructions[]; /** Constructor---does nothing. */ ByteCode() { } /** * Main.v() entry point for disassembling bytecode into Instructions; this method converts the given single bytecode into * an Instruction (with label set to index). * * @param bc * complete array of bytecode. * @param index * offset within bc of the bytecode to parse. * @return a single Instruction object; note that Instruction references will not be filled in (use build to post-process). * @see ClassFile#parseMethod * @see Instruction#parse * @see ByteCode#build */ public Instruction disassemble_bytecode(byte bc[], int index) { // returns a string representing the disassembly of the // bytecode at the given index byte b = bc[index]; boolean isWide = false; Instruction i; int x; x = (b) & 0xff; switch (x) { case BIPUSH: i = new Instruction_Bipush(); break; case SIPUSH: i = new Instruction_Sipush(); break; case LDC1: i = new Instruction_Ldc1(); break; case LDC2: i = new Instruction_Ldc2(); break; case LDC2W: i = new Instruction_Ldc2w(); break; case ACONST_NULL: i = new Instruction_Aconst_null(); break; case ICONST_M1: i = new Instruction_Iconst_m1(); break; case ICONST_0: i = new Instruction_Iconst_0(); break; case ICONST_1: i = new Instruction_Iconst_1(); break; case ICONST_2: i = new Instruction_Iconst_2(); break; case ICONST_3: i = new Instruction_Iconst_3(); break; case ICONST_4: i = new Instruction_Iconst_4(); break; case ICONST_5: i = new Instruction_Iconst_5(); break; case LCONST_0: i = new Instruction_Lconst_0(); break; case LCONST_1: i = new Instruction_Lconst_1(); break; case FCONST_0: i = new Instruction_Fconst_0(); break; case FCONST_1: i = new Instruction_Fconst_1(); break; case FCONST_2: i = new Instruction_Fconst_2(); break; case DCONST_0: i = new Instruction_Dconst_0(); break; case DCONST_1: i = new Instruction_Dconst_1(); break; case ILOAD: i = new Instruction_Iload(); break; case ILOAD_0: i = new Instruction_Iload_0(); break; case ILOAD_1: i = new Instruction_Iload_1(); break; case ILOAD_2: i = new Instruction_Iload_2(); break; case ILOAD_3: i = new Instruction_Iload_3(); break; case LLOAD: i = new Instruction_Lload(); break; case LLOAD_0: i = new Instruction_Lload_0(); break; case LLOAD_1: i = new Instruction_Lload_1(); break; case LLOAD_2: i = new Instruction_Lload_2(); break; case LLOAD_3: i = new Instruction_Lload_3(); break; case FLOAD: i = new Instruction_Fload(); break; case FLOAD_0: i = new Instruction_Fload_0(); break; case FLOAD_1: i = new Instruction_Fload_1(); break; case FLOAD_2: i = new Instruction_Fload_2(); break; case FLOAD_3: i = new Instruction_Fload_3(); break; case DLOAD: i = new Instruction_Dload(); break; case DLOAD_0: i = new Instruction_Dload_0(); break; case DLOAD_1: i = new Instruction_Dload_1(); break; case DLOAD_2: i = new Instruction_Dload_2(); break; case DLOAD_3: i = new Instruction_Dload_3(); break; case ALOAD: i = new Instruction_Aload(); break; case ALOAD_0: i = new Instruction_Aload_0(); break; case ALOAD_1: i = new Instruction_Aload_1(); break; case ALOAD_2: i = new Instruction_Aload_2(); break; case ALOAD_3: i = new Instruction_Aload_3(); break; case ISTORE: i = new Instruction_Istore(); break; case ISTORE_0: i = new Instruction_Istore_0(); break; case ISTORE_1: i = new Instruction_Istore_1(); break; case ISTORE_2: i = new Instruction_Istore_2(); break; case ISTORE_3: i = new Instruction_Istore_3(); break; case LSTORE: i = new Instruction_Lstore(); break; case LSTORE_0: i = new Instruction_Lstore_0(); break; case LSTORE_1: i = new Instruction_Lstore_1(); break; case LSTORE_2: i = new Instruction_Lstore_2(); break; case LSTORE_3: i = new Instruction_Lstore_3(); break; case FSTORE: i = new Instruction_Fstore(); break; case FSTORE_0: i = new Instruction_Fstore_0(); break; case FSTORE_1: i = new Instruction_Fstore_1(); break; case FSTORE_2: i = new Instruction_Fstore_2(); break; case FSTORE_3: i = new Instruction_Fstore_3(); break; case DSTORE: i = new Instruction_Dstore(); break; case DSTORE_0: i = new Instruction_Dstore_0(); break; case DSTORE_1: i = new Instruction_Dstore_1(); break; case DSTORE_2: i = new Instruction_Dstore_2(); break; case DSTORE_3: i = new Instruction_Dstore_3(); break; case ASTORE: i = new Instruction_Astore(); break; case ASTORE_0: i = new Instruction_Astore_0(); break; case ASTORE_1: i = new Instruction_Astore_1(); break; case ASTORE_2: i = new Instruction_Astore_2(); break; case ASTORE_3: i = new Instruction_Astore_3(); break; case IINC: i = new Instruction_Iinc(); break; case WIDE: { int nextIndex = (bc[index + 1]) & 0xff; switch (nextIndex) { case ILOAD: i = new Instruction_Iload(); break; case FLOAD: i = new Instruction_Fload(); break; case ALOAD: i = new Instruction_Aload(); break; case LLOAD: i = new Instruction_Lload(); break; case DLOAD: i = new Instruction_Dload(); break; case ISTORE: i = new Instruction_Istore(); break; case FSTORE: i = new Instruction_Fstore(); break; case ASTORE: i = new Instruction_Astore(); break; case LSTORE: i = new Instruction_Lstore(); break; case DSTORE: i = new Instruction_Dstore(); break; case RET: i = new Instruction_Ret(); break; case IINC: i = new Instruction_Iinc(); break; default: throw new RuntimeException("invalid wide instruction: " + nextIndex); } ((Instruction_bytevar) i).isWide = true; isWide = true; } break; case NEWARRAY: i = new Instruction_Newarray(); break; case ANEWARRAY: i = new Instruction_Anewarray(); break; case MULTIANEWARRAY: i = new Instruction_Multianewarray(); break; case ARRAYLENGTH: i = new Instruction_Arraylength(); break; case IALOAD: i = new Instruction_Iaload(); break; case LALOAD: i = new Instruction_Laload(); break; case FALOAD: i = new Instruction_Faload(); break; case DALOAD: i = new Instruction_Daload(); break; case AALOAD: i = new Instruction_Aaload(); break; case BALOAD: i = new Instruction_Baload(); break; case CALOAD: i = new Instruction_Caload(); break; case SALOAD: i = new Instruction_Saload(); break; case IASTORE: i = new Instruction_Iastore(); break; case LASTORE: i = new Instruction_Lastore(); break; case FASTORE: i = new Instruction_Fastore(); break; case DASTORE: i = new Instruction_Dastore(); break; case AASTORE: i = new Instruction_Aastore(); break; case BASTORE: i = new Instruction_Bastore(); break; case CASTORE: i = new Instruction_Castore(); break; case SASTORE: i = new Instruction_Sastore(); break; case NOP: i = new Instruction_Nop(); break; case POP: i = new Instruction_Pop(); break; case POP2: i = new Instruction_Pop2(); break; case DUP: i = new Instruction_Dup(); break; case DUP2: i = new Instruction_Dup2(); break; case DUP_X1: i = new Instruction_Dup_x1(); break; case DUP_X2: i = new Instruction_Dup_x2(); break; case DUP2_X1: i = new Instruction_Dup2_x1(); break; case DUP2_X2: i = new Instruction_Dup2_x2(); break; case SWAP: i = new Instruction_Swap(); break; case IADD: i = new Instruction_Iadd(); break; case LADD: i = new Instruction_Ladd(); break; case FADD: i = new Instruction_Fadd(); break; case DADD: i = new Instruction_Dadd(); break; case ISUB: i = new Instruction_Isub(); break; case LSUB: i = new Instruction_Lsub(); break; case FSUB: i = new Instruction_Fsub(); break; case DSUB: i = new Instruction_Dsub(); break; case IMUL: i = new Instruction_Imul(); break; case LMUL: i = new Instruction_Lmul(); break; case FMUL: i = new Instruction_Fmul(); break; case DMUL: i = new Instruction_Dmul(); break; case IDIV: i = new Instruction_Idiv(); break; case LDIV: i = new Instruction_Ldiv(); break; case FDIV: i = new Instruction_Fdiv(); break; case DDIV: i = new Instruction_Ddiv(); break; case IREM: i = new Instruction_Irem(); break; case LREM: i = new Instruction_Lrem(); break; case FREM: i = new Instruction_Frem(); break; case DREM: i = new Instruction_Drem(); break; case INEG: i = new Instruction_Ineg(); break; case LNEG: i = new Instruction_Lneg(); break; case FNEG: i = new Instruction_Fneg(); break; case DNEG: i = new Instruction_Dneg(); break; case ISHL: i = new Instruction_Ishl(); break; case ISHR: i = new Instruction_Ishr(); break; case IUSHR: i = new Instruction_Iushr(); break; case LSHL: i = new Instruction_Lshl(); break; case LSHR: i = new Instruction_Lshr(); break; case LUSHR: i = new Instruction_Lushr(); break; case IAND: i = new Instruction_Iand(); break; case LAND: i = new Instruction_Land(); break; case IOR: i = new Instruction_Ior(); break; case LOR: i = new Instruction_Lor(); break; case IXOR: i = new Instruction_Ixor(); break; case LXOR: i = new Instruction_Lxor(); break; case I2L: i = new Instruction_I2l(); break; case I2F: i = new Instruction_I2f(); break; case I2D: i = new Instruction_I2d(); break; case L2I: i = new Instruction_L2i(); break; case L2F: i = new Instruction_L2f(); break; case L2D: i = new Instruction_L2d(); break; case F2I: i = new Instruction_F2i(); break; case F2L: i = new Instruction_F2l(); break; case F2D: i = new Instruction_F2d(); break; case D2I: i = new Instruction_D2i(); break; case D2L: i = new Instruction_D2l(); break; case D2F: i = new Instruction_D2f(); break; case INT2BYTE: i = new Instruction_Int2byte(); break; case INT2CHAR: i = new Instruction_Int2char(); break; case INT2SHORT: i = new Instruction_Int2short(); break; case IFEQ: i = new Instruction_Ifeq(); break; case IFNULL: i = new Instruction_Ifnull(); break; case IFLT: i = new Instruction_Iflt(); break; case IFLE: i = new Instruction_Ifle(); break; case IFNE: i = new Instruction_Ifne(); break; case IFNONNULL: i = new Instruction_Ifnonnull(); break; case IFGT: i = new Instruction_Ifgt(); break; case IFGE: i = new Instruction_Ifge(); break; case IF_ICMPEQ: i = new Instruction_If_icmpeq(); break; case IF_ICMPLT: i = new Instruction_If_icmplt(); break; case IF_ICMPLE: i = new Instruction_If_icmple(); break; case IF_ICMPNE: i = new Instruction_If_icmpne(); break; case IF_ICMPGT: i = new Instruction_If_icmpgt(); break; case IF_ICMPGE: i = new Instruction_If_icmpge(); break; case LCMP: i = new Instruction_Lcmp(); break; case FCMPL: i = new Instruction_Fcmpl(); break; case FCMPG: i = new Instruction_Fcmpg(); break; case DCMPL: i = new Instruction_Dcmpl(); break; case DCMPG: i = new Instruction_Dcmpg(); break; case IF_ACMPEQ: i = new Instruction_If_acmpeq(); break; case IF_ACMPNE: i = new Instruction_If_acmpne(); break; case GOTO: i = new Instruction_Goto(); break; case GOTO_W: i = new Instruction_Goto_w(); break; case JSR: i = new Instruction_Jsr(); break; case JSR_W: i = new Instruction_Jsr_w(); break; case RET: i = new Instruction_Ret(); break; case RET_W: i = new Instruction_Ret_w(); break; case RETURN: i = new Instruction_Return(); break; case IRETURN: i = new Instruction_Ireturn(); break; case LRETURN: i = new Instruction_Lreturn(); break; case FRETURN: i = new Instruction_Freturn(); break; case DRETURN: i = new Instruction_Dreturn(); break; case ARETURN: i = new Instruction_Areturn(); break; case BREAKPOINT: i = new Instruction_Breakpoint(); break; case TABLESWITCH: i = (Instruction) new Instruction_Tableswitch(); break; case LOOKUPSWITCH: i = (Instruction) new Instruction_Lookupswitch(); break; case PUTFIELD: i = (Instruction) new Instruction_Putfield(); break; case GETFIELD: i = (Instruction) new Instruction_Getfield(); break; case PUTSTATIC: i = (Instruction) new Instruction_Putstatic(); break; case GETSTATIC: i = (Instruction) new Instruction_Getstatic(); break; case INVOKEVIRTUAL: i = (Instruction) new Instruction_Invokevirtual(); break; case INVOKENONVIRTUAL: i = (Instruction) new Instruction_Invokenonvirtual(); break; case INVOKESTATIC: i = (Instruction) new Instruction_Invokestatic(); break; case INVOKEINTERFACE: i = (Instruction) new Instruction_Invokeinterface(); break; case INVOKEDYNAMIC: i = (Instruction) new Instruction_Invokedynamic(); break; case ATHROW: i = (Instruction) new Instruction_Athrow(); break; case NEW: i = (Instruction) new Instruction_New(); break; case CHECKCAST: i = (Instruction) new Instruction_Checkcast(); break; case INSTANCEOF: i = (Instruction) new Instruction_Instanceof(); break; case MONITORENTER: i = (Instruction) new Instruction_Monitorenter(); break; case MONITOREXIT: i = (Instruction) new Instruction_Monitorexit(); break; default: // int j; // j = ((int)b)&0xff; // logger.debug("Unknown instruction op=" + j + // " at offset " + index); i = (Instruction) new Instruction_Unknown(b); break; } i.label = index; if (isWide) { i.parse(bc, index + 2); } else { i.parse(bc, index + 1); } return i; } /** * Given a list of Instructions, this method converts all offsets to pointers. * * @param insts * list of instructions; labels must be accurate. * @see Instruction#offsetToPointer * @see ClassFile#parseMethod * @see ClassFile#relabel */ public void build(Instruction insts) { Instruction i; i = insts; // find out how many instructions that is icount = 0; while (i != null) { icount++; i = i.next; } // build array of instructions if (icount > 0) { instructions = new Instruction[icount]; // and put the instructions into the array // identify targets of branch instructions. Why build an array // when we already have a list? In order to be able to locate // an instruction given its numeric label quickly. int k; k = 0; i = insts; while (i != null) { instructions[k] = i; k++; i = i.next; } // now convert all offsets to pointers i = insts; while (i != null) { i.offsetToPointer(this); i = i.next; } } } /** * Displays the code (in the form of Instructions) for the given list of Instructions. * * @param inst * input list of instructions. * @param constant_pool * constant pool of the ClassFile object. * @see ByteCode#showCode(Instruction, int, cp_info) */ public static void showCode(Instruction inst, cp_info constant_pool[]) { showCode(inst, 0, constant_pool); } /** * Displays the code (in the form of Instructions) for the given list of Instructions. * * @param inst * input list of instructions. * @param startinst * index of the label of the instruction at which to begin. * @param constant_pool * constant pool of the ClassFile object. * @see ByteCode#showCode(Instruction, cp_info) */ public static void showCode(Instruction inst, int startinst, cp_info constant_pool[]) { int i; Instruction j = inst; String pref; i = startinst; while (j != null) { if (i > 999) { pref = ""; } else if (i > 99) { pref = " "; } else if (i > 9) { pref = " "; } else { pref = " "; } logger.debug("" + pref + i + ": "); logger.debug("" + j.toString(constant_pool)); i = j.nextOffset(i); j = j.next; } } /** * Locates the Instruction in the list with the given label. * * @param index * label of desired instruction * @return Instruction object wiht that label, or <i>null</i> if not found. */ // locates the instruction with an index value of the given public Instruction locateInst(int index) { return locateInstr(index, 0, icount); } /** Performs a binary search of the instructions[] array. */ private Instruction locateInstr(int index, int mini, int maxi) { int mid = (maxi - mini) / 2 + mini; if (mini > maxi) { return null; } if (instructions[mid].label == index) { return instructions[mid]; } if (instructions[mid].label > index) { return locateInstr(index, mini, mid - 1); } return locateInstr(index, mid + 1, maxi); } /** Returns true if the bytecode is a local store */ public static boolean isLocalStore(int bc) { switch (bc) { case ByteCode.ISTORE: case ByteCode.FSTORE: case ByteCode.ASTORE: case ByteCode.LSTORE: case ByteCode.DSTORE: case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: return true; default: return false; } } }
32,722
27.88173
125
java
soot
soot-master/src/main/java/soot/coffi/CFG.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.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import java.util.Vector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import soot.ArrayType; import soot.BooleanType; import soot.ByteType; import soot.CharType; import soot.DoubleType; import soot.FloatType; import soot.IntType; import soot.Local; import soot.LongType; import soot.Modifier; import soot.PatchingChain; import soot.RefType; import soot.Scene; import soot.ShortType; import soot.SootClass; import soot.SootFieldRef; import soot.SootMethod; import soot.SootMethodRef; import soot.StmtAddressType; import soot.Trap; import soot.Type; import soot.Unit; import soot.UnknownType; import soot.Value; import soot.VoidType; import soot.jimple.ArrayRef; import soot.jimple.ClassConstant; import soot.jimple.ConditionExpr; import soot.jimple.DoubleConstant; import soot.jimple.Expr; import soot.jimple.FloatConstant; import soot.jimple.GotoStmt; import soot.jimple.IdentityStmt; import soot.jimple.IfStmt; import soot.jimple.InstanceFieldRef; import soot.jimple.IntConstant; import soot.jimple.Jimple; import soot.jimple.JimpleBody; import soot.jimple.LongConstant; import soot.jimple.LookupSwitchStmt; import soot.jimple.NullConstant; import soot.jimple.StaticFieldRef; import soot.jimple.Stmt; import soot.jimple.StringConstant; import soot.jimple.TableSwitchStmt; import soot.options.Options; import soot.tagkit.BytecodeOffsetTag; import soot.tagkit.LineNumberTag; import soot.tagkit.Tag; import soot.util.ArraySet; import soot.util.Chain; /** * A Control Flow Graph. * * @author Clark Verbrugge */ public class CFG { private static final Logger logger = LoggerFactory.getLogger(CFG.class); /** * Method for which this is a control flow graph. * * @see method_info */ private method_info method; /** * Ordered list of BasicBlocks comprising the code of this CFG. */ BasicBlock cfg; Chain<Unit> units; JimpleBody listBody; Map<Instruction, Stmt> instructionToFirstStmt; Map<Instruction, Stmt> instructionToLastStmt; SootMethod jmethod; Scene cm; Instruction firstInstruction; Instruction lastInstruction; private Instruction sentinel; private Hashtable<Instruction, BasicBlock> h2bb, t2bb; /** * Constructs a new control flow graph for the given method. * * @param m * the method in question. * @see method_info */ public CFG(method_info m) { this.method = m; this.sentinel = new Instruction_Nop(); this.sentinel.next = m.instructions; m.instructions.prev = this.sentinel; // printInstructions(); // printExceptionTable(); eliminateJsrRets(); // printInstructions(); // printExceptionTable(); buildBBCFG(); // printBBs(); // printBBCFGSucc(); m.cfg = this; if (cfg != null) { cfg.beginCode = true; firstInstruction = cfg.head; } else { firstInstruction = null; } // calculate complexity metrics if (soot.jbco.Main.metrics) { complexity(); } } public static HashMap<SootMethod, int[]> methodsToVEM = new HashMap<SootMethod, int[]>(); private void complexity() { // ignore all non-app classes if (!method.jmethod.getDeclaringClass().isApplicationClass()) { return; } BasicBlock b = this.cfg; HashMap<BasicBlock, Integer> block2exc = new HashMap<BasicBlock, Integer>(); int tmp, nodes = 0, edges = 0, highest = 0; while (b != null) { tmp = 0; for (exception_table_entry element : method.code_attr.exception_table) { Instruction start = element.start_inst; Instruction end = element.start_inst; if ((start.label >= b.head.label && start.label <= b.tail.label) || (end.label > b.head.label && (b.tail.next == null || end.label <= b.tail.next.label))) { tmp++; } } block2exc.put(b, new Integer(tmp)); b = b.next; } b = this.cfg; while (b != null) { nodes++; tmp = b.succ.size() + block2exc.get(b).intValue(); // exceptions are not counted in succs and preds so we need to do so manually int deg = b.pred.size() + tmp + (b.beginException ? 1 : 0); if (deg > highest) { highest = deg; } edges += tmp; b = b.next; } methodsToVEM.put(method.jmethod, new int[] { nodes, edges, highest }); } // Constructs the actual control flow graph. Assumes the hash table // currently associates leaders with BasicBlocks, this function // builds the next[] and prev[] pointer arrays. private void buildBBCFG() { Object branches[]; Code_attribute ca = method.locate_code_attribute(); { h2bb = new Hashtable<Instruction, BasicBlock>(100, 25); t2bb = new Hashtable<Instruction, BasicBlock>(100, 25); Instruction insn = this.sentinel.next; BasicBlock blast = null; if (insn != null) { Instruction tail = buildBasicBlock(insn); cfg = new BasicBlock(insn, tail); h2bb.put(insn, cfg); t2bb.put(tail, cfg); insn = tail.next; blast = cfg; } while (insn != null) { Instruction tail = buildBasicBlock(insn); BasicBlock block = new BasicBlock(insn, tail); blast.next = block; blast = block; h2bb.put(insn, block); t2bb.put(tail, block); insn = tail.next; } } BasicBlock block = cfg; while (block != null) { Instruction insn = block.tail; if (insn.branches) { if (insn instanceof Instruction_Athrow) { // see how many targets it can reach. Note that this is a // subset of the exception_table. HashSet<Instruction> ethandlers = new HashSet<Instruction>(); // not quite a subset---could also be that control // exits this method, so start icount at 1 for (int i = 0; i < ca.exception_table_length; i++) { exception_table_entry etentry = ca.exception_table[i]; if (insn.label >= etentry.start_inst.label && (etentry.end_inst == null || insn.label < etentry.end_inst.label)) { ethandlers.add(etentry.handler_inst); } } branches = ethandlers.toArray(); } else { branches = insn.branchpoints(insn.next); } if (branches != null) { block.succ.ensureCapacity(block.succ.size() + branches.length); for (Object element : branches) { if (element != null) { BasicBlock bb = h2bb.get(element); if (bb == null) { logger.warn("target of a branch is null"); logger.debug("" + insn); } else { block.succ.addElement(bb); bb.pred.addElement(block); } } } } } else if (block.next != null) { // BB ended not with a branch, so just go to next block.succ.addElement(block.next); block.next.pred.addElement(block); } block = block.next; } // One final step, run through exception handlers and mark which // basic blocks begin their code for (int i = 0; i < ca.exception_table_length; i++) { BasicBlock bb = h2bb.get(ca.exception_table[i].handler_inst); if (bb == null) { logger.warn("No basic block found for" + " start of exception handler code."); } else { bb.beginException = true; ca.exception_table[i].b = bb; } } } /* * given the list of instructions head, this pulls off the front basic block, terminates it with a null, and returns the * next instruction after. */ private static Instruction buildBasicBlock(Instruction head) { Instruction insn, next; insn = head; next = insn.next; if (next == null) { return insn; } do { if (insn.branches || next.labelled) { break; } else { insn = next; next = insn.next; } } while (next != null); return insn; } /* We only handle simple cases. */ Map<Instruction, Instruction> jsr2astore = new HashMap<Instruction, Instruction>(); Map<Instruction, Instruction> astore2ret = new HashMap<Instruction, Instruction>(); LinkedList<Instruction> jsrorder = new LinkedList<Instruction>(); /* * Eliminate subroutines ( JSR/RET instructions ) by inlining the routine bodies. */ private boolean eliminateJsrRets() { Instruction insn = this.sentinel; // find the last instruction, for copying blocks. while (insn.next != null) { insn = insn.next; } this.lastInstruction = insn; HashMap<Instruction, Instruction> todoBlocks = new HashMap<Instruction, Instruction>(); todoBlocks.put(this.sentinel.next, this.lastInstruction); LinkedList<Instruction> todoList = new LinkedList<Instruction>(); todoList.add(this.sentinel.next); while (!todoList.isEmpty()) { Instruction firstInsn = todoList.removeFirst(); Instruction lastInsn = todoBlocks.get(firstInsn); jsrorder.clear(); jsr2astore.clear(); astore2ret.clear(); if (findOutmostJsrs(firstInsn, lastInsn)) { HashMap<Instruction, Instruction> newblocks = inliningJsrTargets(); todoBlocks.putAll(newblocks); todoList.addAll(newblocks.keySet()); } } /* patch exception table and others. */ { method.instructions = this.sentinel.next; adjustExceptionTable(); adjustLineNumberTable(); adjustBranchTargets(); } // we should prune the code and exception table here. // remove any exception handler whose region is in a jsr/ret block. // pruneExceptionTable(); return true; } // find outmost jsr/ret pairs in a code area, all information is // saved in jsr2astore, and astore2ret // start : start instruction, inclusively. // end : the last instruction, inclusively. // return the last instruction encounted ( before end ) // the caller cleans jsr2astore, astore2ret private boolean findOutmostJsrs(Instruction start, Instruction end) { // use to put innerJsrs. HashSet<Instruction> innerJsrs = new HashSet<Instruction>(); boolean unusual = false; Instruction insn = start; do { if (insn instanceof Instruction_Jsr || insn instanceof Instruction_Jsr_w) { if (innerJsrs.contains(insn)) { // skip it insn = insn.next; continue; } Instruction astore = ((Instruction_branch) insn).target; if (!(astore instanceof Interface_Astore)) { unusual = true; break; } Instruction ret = findMatchingRet(astore, insn, innerJsrs); /* * if (ret == null) { unusual = true; break; } */ jsrorder.addLast(insn); jsr2astore.put(insn, astore); astore2ret.put(astore, ret); } insn = insn.next; } while (insn != end.next); if (unusual) { logger.debug("Sorry, I cannot handle this method."); return false; } return true; } private Instruction findMatchingRet(Instruction astore, Instruction jsr, HashSet<Instruction> innerJsrs) { int astorenum = ((Interface_Astore) astore).getLocalNumber(); Instruction insn = astore.next; while (insn != null) { if (insn instanceof Instruction_Ret || insn instanceof Instruction_Ret_w) { int retnum = ((Interface_OneIntArg) insn).getIntArg(); if (astorenum == retnum) { return insn; } } else if (insn instanceof Instruction_Jsr || insn instanceof Instruction_Jsr_w) { /* adjust the jsr inlining order. */ innerJsrs.add(insn); } insn = insn.next; } return null; } // make copies of jsr/ret blocks // return new blocks private HashMap<Instruction, Instruction> inliningJsrTargets() { /* * for (int i=0, n=jsrorder.size(); i<n; i++) { Instruction jsr = (Instruction)jsrorder.get(i); Instruction astore = * (Instruction)jsr2astore.get(jsr); Instruction ret = (Instruction)astore2ret.get(astore); * logger.debug("jsr"+jsr.label+"\t" +"as"+astore.label+"\t" +"ret"+ret.label); } */ HashMap<Instruction, Instruction> newblocks = new HashMap<Instruction, Instruction>(); while (!jsrorder.isEmpty()) { Instruction jsr = jsrorder.removeFirst(); Instruction astore = jsr2astore.get(jsr); Instruction ret = astore2ret.get(astore); // make a copy of the code, append to the last instruction. Instruction newhead = makeCopyOf(astore, ret, jsr.next); // jsr is replaced by goto newhead // astore has been removed // ret is replaced by goto jsr.next Instruction_Goto togo = new Instruction_Goto(); togo.target = newhead; newhead.labelled = true; togo.label = jsr.label; togo.labelled = jsr.labelled; togo.prev = jsr.prev; togo.next = jsr.next; togo.prev.next = togo; togo.next.prev = togo; replacedInsns.put(jsr, togo); // just quick hack if (ret != null) { newblocks.put(newhead, this.lastInstruction); } } return newblocks; } /* * make a copy of code between from and to exclusively, fixup targets of branch instructions in the code. */ private Instruction makeCopyOf(Instruction astore, Instruction ret, Instruction target) { // do a quick hacker for ret == null if (ret == null) { return astore.next; } Instruction last = this.lastInstruction; Instruction headbefore = last; int curlabel = this.lastInstruction.label; // mapping from original instructions to new instructions. HashMap<Instruction, Instruction> insnmap = new HashMap<Instruction, Instruction>(); Instruction insn = astore.next; while (insn != ret && insn != null) { try { Instruction newone = (Instruction) insn.clone(); newone.label = ++curlabel; newone.prev = last; last.next = newone; last = newone; insnmap.put(insn, newone); } catch (CloneNotSupportedException e) { logger.debug("Error !"); } insn = insn.next; } // replace ret by a goto Instruction_Goto togo = new Instruction_Goto(); togo.target = target; target.labelled = true; togo.label = ++curlabel; last.next = togo; togo.prev = last; last = togo; this.lastInstruction = last; // The ret instruction is removed, insnmap.put(astore, headbefore.next); insnmap.put(ret, togo); // fixup targets in new instruction (only in the scope of // new instructions). // do not forget set target labelled as TRUE insn = headbefore.next; while (insn != last) { if (insn instanceof Instruction_branch) { Instruction oldtgt = ((Instruction_branch) insn).target; Instruction newtgt = insnmap.get(oldtgt); if (newtgt != null) { ((Instruction_branch) insn).target = newtgt; newtgt.labelled = true; } } else if (insn instanceof Instruction_Lookupswitch) { Instruction_Lookupswitch switchinsn = (Instruction_Lookupswitch) insn; Instruction newdefault = insnmap.get(switchinsn.default_inst); if (newdefault != null) { switchinsn.default_inst = newdefault; newdefault.labelled = true; } for (int i = 0; i < switchinsn.match_insts.length; i++) { Instruction newtgt = insnmap.get(switchinsn.match_insts[i]); if (newtgt != null) { switchinsn.match_insts[i] = newtgt; newtgt.labelled = true; } } } else if (insn instanceof Instruction_Tableswitch) { Instruction_Tableswitch switchinsn = (Instruction_Tableswitch) insn; Instruction newdefault = insnmap.get(switchinsn.default_inst); if (newdefault != null) { switchinsn.default_inst = newdefault; newdefault.labelled = true; } for (int i = 0; i < switchinsn.jump_insts.length; i++) { Instruction newtgt = insnmap.get(switchinsn.jump_insts[i]); if (newtgt != null) { switchinsn.jump_insts[i] = newtgt; newtgt.labelled = true; } } } insn = insn.next; } // do we need to copy a new exception table entry? // new exception table has new exception range, // and the new exception handler. { Code_attribute ca = method.locate_code_attribute(); LinkedList<exception_table_entry> newentries = new LinkedList<exception_table_entry>(); int orig_start_of_subr = astore.next.originalIndex; // inclusive int orig_end_of_subr = ret.originalIndex; // again, inclusive for (int i = 0; i < ca.exception_table_length; i++) { exception_table_entry etentry = ca.exception_table[i]; int orig_start_of_trap = etentry.start_pc; // inclusive int orig_end_of_trap = etentry.end_pc; // exclusive if (orig_start_of_trap < orig_end_of_subr && orig_end_of_trap > orig_start_of_subr) { // At least a portion of the cloned subroutine is trapped. exception_table_entry newone = new exception_table_entry(); if (orig_start_of_trap <= orig_start_of_subr) { newone.start_inst = headbefore.next; } else { Instruction ins = insnmap.get(etentry.start_inst); if (ins != null) { newone.start_inst = insnmap.get(etentry.start_inst); } else { newone.start_inst = etentry.start_inst; } } if (orig_end_of_trap > orig_end_of_subr) { newone.end_inst = null; // Representing the insn after // the last instruction in the // subr; we need to fix it if // we inline another subr. } else { newone.end_inst = insnmap.get(etentry.end_inst); } newone.handler_inst = insnmap.get(etentry.handler_inst); if (newone.handler_inst == null) { newone.handler_inst = etentry.handler_inst; } // We can leave newone.start_pc == 0 and newone.end_pc == 0. // since that cannot overlap the range of any other // subroutines that get inlined later. newentries.add(newone); } // Finally, fix up the old entry if its protected area // ran to the end of the method we have just lengthened: // patch its end marker to be the first // instruction in the subroutine we've just inlined. if (etentry.end_inst == null) { etentry.end_inst = headbefore.next; } } if (newentries.size() > 0) { ca.exception_table_length += newentries.size(); exception_table_entry[] newtable = new exception_table_entry[ca.exception_table_length]; System.arraycopy(ca.exception_table, 0, newtable, 0, ca.exception_table.length); for (int i = 0, j = ca.exception_table.length; i < newentries.size(); i++, j++) { newtable[j] = newentries.get(i); } ca.exception_table = newtable; } } return headbefore.next; } /* if a jsr/astore/ret is replaced by some other instruction, it will be put on this table. */ private final Hashtable<Instruction, Instruction_Goto> replacedInsns = new Hashtable<Instruction, Instruction_Goto>(); /* bootstrap methods table */ private BootstrapMethods_attribute bootstrap_methods_attribute; /* do not forget set the target labelled as TRUE. */ private void adjustBranchTargets() { Instruction insn = this.sentinel.next; while (insn != null) { if (insn instanceof Instruction_branch) { Instruction_branch binsn = (Instruction_branch) insn; Instruction newtgt = replacedInsns.get(binsn.target); if (newtgt != null) { binsn.target = newtgt; newtgt.labelled = true; } } else if (insn instanceof Instruction_Lookupswitch) { Instruction_Lookupswitch switchinsn = (Instruction_Lookupswitch) insn; Instruction newdefault = replacedInsns.get(switchinsn.default_inst); if (newdefault != null) { switchinsn.default_inst = newdefault; newdefault.labelled = true; } for (int i = 0; i < switchinsn.npairs; i++) { Instruction newtgt = replacedInsns.get(switchinsn.match_insts[i]); if (newtgt != null) { switchinsn.match_insts[i] = newtgt; newtgt.labelled = true; } } } else if (insn instanceof Instruction_Tableswitch) { Instruction_Tableswitch switchinsn = (Instruction_Tableswitch) insn; Instruction newdefault = replacedInsns.get(switchinsn.default_inst); if (newdefault != null) { switchinsn.default_inst = newdefault; newdefault.labelled = true; } for (int i = 0; i <= switchinsn.high - switchinsn.low; i++) { Instruction newtgt = replacedInsns.get(switchinsn.jump_insts[i]); if (newtgt != null) { switchinsn.jump_insts[i] = newtgt; newtgt.labelled = true; } } } insn = insn.next; } } private void adjustExceptionTable() { Code_attribute codeAttribute = method.locate_code_attribute(); for (int i = 0; i < codeAttribute.exception_table_length; i++) { exception_table_entry entry = codeAttribute.exception_table[i]; Instruction oldinsn = entry.start_inst; Instruction newinsn = replacedInsns.get(oldinsn); if (newinsn != null) { entry.start_inst = newinsn; } oldinsn = entry.end_inst; if (entry.end_inst != null) { newinsn = replacedInsns.get(oldinsn); if (newinsn != null) { entry.end_inst = newinsn; } } oldinsn = entry.handler_inst; newinsn = replacedInsns.get(oldinsn); if (newinsn != null) { entry.handler_inst = newinsn; } } } private void adjustLineNumberTable() { if (!Options.v().keep_line_number()) { return; } if (method.code_attr == null) { return; } attribute_info[] attributes = method.code_attr.attributes; for (attribute_info element : attributes) { if (element instanceof LineNumberTable_attribute) { LineNumberTable_attribute lntattr = (LineNumberTable_attribute) element; for (line_number_table_entry element0 : lntattr.line_number_table) { Instruction oldinst = element0.start_inst; Instruction newinst = replacedInsns.get(oldinst); if (newinst != null) { element0.start_inst = newinst; } } } } } /** * Reconstructs the instruction stream by appending the Instruction lists associated with each basic block. * <p> * Note that this joins up the basic block Instruction lists, and so they will no longer end with <i>null</i> after this. * * @return the head of the list of instructions. */ public Instruction reconstructInstructions() { if (cfg != null) { return cfg.head; } else { return null; } } /** * Main.v() entry point for converting list of Instructions to Jimple statements; performs flow analysis, constructs Jimple * statements, and fixes jumps. * * @param constant_pool * constant pool of ClassFile. * @param this_class * constant pool index of the CONSTANT_Class_info object for this' class. * @param bootstrap_methods_attribute * @return <i>true</i> if all ok, <i>false</i> if there was an error. * @see Stmt */ public boolean jimplify(cp_info constant_pool[], int this_class, BootstrapMethods_attribute bootstrap_methods_attribute, JimpleBody listBody) { this.bootstrap_methods_attribute = bootstrap_methods_attribute; Chain<Unit> units = listBody.getUnits(); this.listBody = listBody; this.units = units; instructionToFirstStmt = new HashMap<Instruction, Stmt>(); instructionToLastStmt = new HashMap<Instruction, Stmt>(); jmethod = listBody.getMethod(); cm = Scene.v(); // TypeArray.setClassManager(cm); // TypeStack.setClassManager(cm); Set<Local> initialLocals = new ArraySet<Local>(); List<Type> parameterTypes = jmethod.getParameterTypes(); // Initialize nameToLocal which is an index*Type->Local map, which is used // to determine local in bytecode references. { Code_attribute ca = method.locate_code_attribute(); LocalVariableTable_attribute la = ca.findLocalVariableTable(); LocalVariableTypeTable_attribute lt = ca.findLocalVariableTypeTable(); Util.v().bodySetup(la, lt, constant_pool); boolean isStatic = Modifier.isStatic(jmethod.getModifiers()); int currentLocalIndex = 0; // Initialize the 'this' variable { if (!isStatic) { Local local = Util.v().getLocalForParameter(listBody, currentLocalIndex); currentLocalIndex++; units.add(Jimple.v().newIdentityStmt(local, Jimple.v().newThisRef(jmethod.getDeclaringClass().getType()))); } } // Initialize parameters { Iterator<Type> typeIt = parameterTypes.iterator(); int argCount = 0; while (typeIt.hasNext()) { Local local = Util.v().getLocalForParameter(listBody, currentLocalIndex); Type type = typeIt.next(); initialLocals.add(local); units.add(Jimple.v().newIdentityStmt(local, Jimple.v().newParameterRef(type, argCount))); if (type.equals(DoubleType.v()) || type.equals(LongType.v())) { currentLocalIndex += 2; } else { currentLocalIndex += 1; } argCount++; } } Util.v().resetEasyNames(); } jimplify(constant_pool, this_class); return true; } private void buildInsnCFGfromBBCFG() { BasicBlock block = cfg; while (block != null) { Instruction insn = block.head; while (insn != block.tail) { Instruction[] succs = new Instruction[1]; succs[0] = insn.next; insn.succs = succs; insn = insn.next; } { // The successors are the ones from the basic block. Vector<BasicBlock> bsucc = block.succ; int size = bsucc.size(); Instruction[] succs = new Instruction[size]; for (int i = 0; i < size; i++) { succs[i] = bsucc.elementAt(i).head; } insn.succs = succs; } block = block.next; } } /** * Main.v() entry point for converting list of Instructions to Jimple statements; performs flow analysis, constructs Jimple * statements, and fixes jumps. * * @param constant_pool * constant pool of ClassFile. * @param this_class * constant pool index of the CONSTANT_Class_info object for this' class. * @param clearStacks * if <i>true</i> semantic stacks will be deleted after the process is complete. * @return <i>true</i> if all ok, <i>false</i> if there was an error. * @see CFG#jimplify(cp_info[], int) * @see Stmt */ void jimplify(cp_info constant_pool[], int this_class) { Code_attribute codeAttribute = method.locate_code_attribute(); Set<Instruction> handlerInstructions = new ArraySet<Instruction>(); Map<Instruction, SootClass> handlerInstructionToException = new HashMap<Instruction, SootClass>(); Map<Instruction, TypeStack> instructionToTypeStack; Map<Instruction, TypeStack> instructionToPostTypeStack; { // build graph in buildInsnCFGfromBBCFG(); // Put in successors due to exception handlers { for (int i = 0; i < codeAttribute.exception_table_length; i++) { Instruction startIns = codeAttribute.exception_table[i].start_inst; Instruction endIns = codeAttribute.exception_table[i].end_inst; Instruction handlerIns = codeAttribute.exception_table[i].handler_inst; handlerInstructions.add(handlerIns); // Determine exception to catch { int catchType = codeAttribute.exception_table[i].catch_type; SootClass exception; if (catchType != 0) { CONSTANT_Class_info classinfo = (CONSTANT_Class_info) constant_pool[catchType]; String name = ((CONSTANT_Utf8_info) (constant_pool[classinfo.name_index])).convert(); name = name.replace('/', '.'); exception = cm.getSootClass(name); } else { exception = cm.getSootClass("java.lang.Throwable"); } handlerInstructionToException.put(handlerIns, exception); } if (startIns == endIns) { throw new RuntimeException("Empty catch range for exception handler"); } Instruction ins = startIns; for (;;) { Instruction[] succs = ins.succs; Instruction[] newsuccs = new Instruction[succs.length + 1]; System.arraycopy(succs, 0, newsuccs, 0, succs.length); newsuccs[succs.length] = handlerIns; ins.succs = newsuccs; ins = ins.next; if (ins == endIns || ins == null) { break; } } } } } Set<Instruction> reachableInstructions = new HashSet<Instruction>(); // Mark all the reachable instructions { LinkedList<Instruction> instructionsToVisit = new LinkedList<Instruction>(); reachableInstructions.add(firstInstruction); instructionsToVisit.addLast(firstInstruction); while (!instructionsToVisit.isEmpty()) { Instruction ins = instructionsToVisit.removeFirst(); Instruction[] succs = ins.succs; for (Instruction succ : succs) { if (!reachableInstructions.contains(succ)) { reachableInstructions.add(succ); instructionsToVisit.addLast(succ); } } } } /* * // Check to see if any instruction is unmarked. { BasicBlock b = cfg; * * while(b != null) { Instruction ins = b.head; * * while(ins != null) { if(!reachableInstructions.contains(ins)) throw new * RuntimeException("Method to jimplify contains unreachable code! (not handled for now)"); * * ins = ins.next; } * * b = b.next; } } */ // Perform the flow analysis, and build up instructionToTypeStack and instructionToLocalArray { instructionToTypeStack = new HashMap<Instruction, TypeStack>(); instructionToPostTypeStack = new HashMap<Instruction, TypeStack>(); Set<Instruction> visitedInstructions = new HashSet<Instruction>(); List<Instruction> changedInstructions = new ArrayList<Instruction>(); TypeStack initialTypeStack; // Build up initial type stack and initial local array (for the first instruction) { initialTypeStack = TypeStack.v(); // the empty stack with nothing on it. } // Get the loop cranked up. { instructionToTypeStack.put(firstInstruction, initialTypeStack); visitedInstructions.add(firstInstruction); changedInstructions.add(firstInstruction); } { while (!changedInstructions.isEmpty()) { Instruction ins = changedInstructions.get(0); changedInstructions.remove(0); OutFlow ret = processFlow(ins, instructionToTypeStack.get(ins), constant_pool); instructionToPostTypeStack.put(ins, ret.typeStack); Instruction[] successors = ins.succs; for (Instruction s : successors) { if (!visitedInstructions.contains(s)) { // Special case for the first time visiting. if (handlerInstructions.contains(s)) { TypeStack exceptionTypeStack = (TypeStack.v()).push(RefType.v(handlerInstructionToException.get(s).getName())); instructionToTypeStack.put(s, exceptionTypeStack); } else { instructionToTypeStack.put(s, ret.typeStack); } visitedInstructions.add(s); changedInstructions.add(s); // logger.debug("adding successor: " + s); } else { // logger.debug("considering successor: " + s); TypeStack newTypeStack, oldTypeStack = instructionToTypeStack.get(s); if (handlerInstructions.contains(s)) { // The type stack for an instruction handler should always be that of // single object on the stack. TypeStack exceptionTypeStack = (TypeStack.v()).push(RefType.v(handlerInstructionToException.get(s).getName())); newTypeStack = exceptionTypeStack; } else { try { newTypeStack = ret.typeStack.merge(oldTypeStack); } catch (RuntimeException re) { logger.debug("Considering " + s); throw re; } } if (!newTypeStack.equals(oldTypeStack)) { changedInstructions.add(s); // logger.debug("requires a revisit: " + s); } instructionToTypeStack.put(s, newTypeStack); } } } } } // logger.debug("Producing Jimple code..."); // Jimplify each statement { BasicBlock b = cfg; while (b != null) { Instruction ins = b.head; b.statements = new ArrayList<Stmt>(); List<Stmt> blockStatements = b.statements; for (;;) { List<Stmt> statementsForIns = new ArrayList<Stmt>(); if (reachableInstructions.contains(ins)) { generateJimple(ins, instructionToTypeStack.get(ins), instructionToPostTypeStack.get(ins), constant_pool, statementsForIns, b); } else { statementsForIns.add(Jimple.v().newNopStmt()); } if (!statementsForIns.isEmpty()) { for (int i = 0; i < statementsForIns.size(); i++) { units.add(statementsForIns.get(i)); blockStatements.add(statementsForIns.get(i)); } instructionToFirstStmt.put(ins, statementsForIns.get(0)); instructionToLastStmt.put(ins, statementsForIns.get(statementsForIns.size() - 1)); } if (ins == b.tail) { break; } ins = ins.next; } b = b.next; } } jimpleTargetFixup(); // fix up jump targets /* * // Print out basic blocks { BasicBlock b = cfg; * * logger.debug("Basic blocks for: " + jmethod.getName()); * * while(b != null) { Instruction ins = b.head; * * * * while(ins != null) { logger.debug(""+ins.toString()); ins = ins.next; } * * b = b.next; } } */ // Insert beginCatch/endCatch statements for exception handling { Map<Stmt, Stmt> targetToHandler = new HashMap<Stmt, Stmt>(); for (int i = 0; i < codeAttribute.exception_table_length; i++) { Instruction startIns = codeAttribute.exception_table[i].start_inst; Instruction endIns = codeAttribute.exception_table[i].end_inst; Instruction targetIns = codeAttribute.exception_table[i].handler_inst; if (!instructionToFirstStmt.containsKey(startIns) || (endIns != null && (!instructionToLastStmt.containsKey(endIns)))) { throw new RuntimeException("Exception range does not coincide with jimple instructions"); } if (!instructionToFirstStmt.containsKey(targetIns)) { throw new RuntimeException("Exception handler does not coincide with jimple instruction"); } SootClass exception; // Determine exception to catch { int catchType = codeAttribute.exception_table[i].catch_type; if (catchType != 0) { CONSTANT_Class_info classinfo = (CONSTANT_Class_info) constant_pool[catchType]; String name = ((CONSTANT_Utf8_info) (constant_pool[classinfo.name_index])).convert(); name = name.replace('/', '.'); exception = cm.getSootClass(name); } else { exception = cm.getSootClass("java.lang.Throwable"); } } Stmt newTarget; // Insert assignment of exception { Stmt firstTargetStmt = instructionToFirstStmt.get(targetIns); if (targetToHandler.containsKey(firstTargetStmt)) { newTarget = targetToHandler.get(firstTargetStmt); } else { Local local = Util.v().getLocalCreatingIfNecessary(listBody, "$stack0", UnknownType.v()); newTarget = Jimple.v().newIdentityStmt(local, Jimple.v().newCaughtExceptionRef()); // changed to account for catch blocks which are also part of normal control flow // units.insertBefore(newTarget, firstTargetStmt); ((PatchingChain<Unit>) units).insertBeforeNoRedirect(newTarget, firstTargetStmt); targetToHandler.put(firstTargetStmt, newTarget); if (units.getFirst() != newTarget) { Unit prev = (Unit) units.getPredOf(newTarget); if (prev != null && prev.fallsThrough()) { units.insertAfter(Jimple.v().newGotoStmt(firstTargetStmt), prev); } } } } // Insert trap { Stmt firstStmt = instructionToFirstStmt.get(startIns); Stmt afterEndStmt; if (endIns == null) { // A kludge which isn't really correct, but // gets us closer to correctness (until we // clean up the rest of Soot to properly // represent Traps which extend to the end // of a method): if the protected code extends // to the end of the method, use the last Stmt // as the endUnit of the Trap, even though // that will leave the last unit outside // the protected area. afterEndStmt = (Stmt) units.getLast(); } else { afterEndStmt = instructionToLastStmt.get(endIns); IdentityStmt catchStart = (IdentityStmt) targetToHandler.get(afterEndStmt); // (Cast to IdentityStmt as an assertion check.) if (catchStart != null) { // The protected region extends to the beginning of an // exception handler, so we need to reset afterEndStmt // to the identity statement which we have inserted // before the old afterEndStmt. if (catchStart != units.getPredOf(afterEndStmt)) { throw new IllegalStateException("Assertion failure: catchStart != pred of afterEndStmt"); } afterEndStmt = catchStart; } } Trap trap = Jimple.v().newTrap(exception, firstStmt, afterEndStmt, newTarget); listBody.getTraps().add(trap); } } } /* convert line number table to tags attached to statements */ if (Options.v().keep_line_number()) { HashMap<Stmt, Tag> stmtstags = new HashMap<Stmt, Tag>(); LinkedList<Stmt> startstmts = new LinkedList<Stmt>(); attribute_info[] attrs = codeAttribute.attributes; for (attribute_info element : attrs) { if (element instanceof LineNumberTable_attribute) { LineNumberTable_attribute lntattr = (LineNumberTable_attribute) element; for (line_number_table_entry element0 : lntattr.line_number_table) { Stmt start_stmt = instructionToFirstStmt.get(element0.start_inst); if (start_stmt != null) { LineNumberTag lntag = new LineNumberTag(element0.line_number); stmtstags.put(start_stmt, lntag); startstmts.add(start_stmt); } } } } /* * if the predecessor of a statement is a caughtexcetionref, give it the tag of its successor */ for (Iterator<Stmt> stmtIt = new ArrayList<Stmt>(stmtstags.keySet()).iterator(); stmtIt.hasNext();) { final Stmt stmt = stmtIt.next(); Stmt pred = stmt; Tag tag = stmtstags.get(stmt); while (true) { pred = (Stmt) units.getPredOf(pred); if (pred == null) { break; } if (!(pred instanceof IdentityStmt)) { break; } stmtstags.put(pred, tag); pred.addTag(tag); } } /* attach line number tag to each statement. */ for (int i = 0; i < startstmts.size(); i++) { Stmt stmt = startstmts.get(i); Tag tag = stmtstags.get(stmt); stmt.addTag(tag); stmt = (Stmt) units.getSuccOf(stmt); while (stmt != null && !stmtstags.containsKey(stmt)) { stmt.addTag(tag); stmt = (Stmt) units.getSuccOf(stmt); } } } } private Type byteCodeTypeOf(Type type) { if (type.equals(ShortType.v()) || type.equals(CharType.v()) || type.equals(ByteType.v()) || type.equals(BooleanType.v())) { return IntType.v(); } else { return type; } } OutFlow processFlow(Instruction ins, TypeStack typeStack, cp_info[] constant_pool) { int x; x = ((ins.code)) & 0xff; switch (x) { case ByteCode.BIPUSH: typeStack = typeStack.push(IntType.v()); break; case ByteCode.SIPUSH: typeStack = typeStack.push(IntType.v()); break; case ByteCode.LDC1: return processCPEntry(constant_pool, ((Instruction_Ldc1) ins).arg_b, typeStack, jmethod); case ByteCode.LDC2: case ByteCode.LDC2W: return processCPEntry(constant_pool, ((Instruction_intindex) ins).arg_i, typeStack, jmethod); case ByteCode.ACONST_NULL: typeStack = typeStack.push(RefType.v("java.lang.Object")); break; case ByteCode.ICONST_M1: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: typeStack = typeStack.push(IntType.v()); break; case ByteCode.LCONST_0: case ByteCode.LCONST_1: typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: typeStack = typeStack.push(FloatType.v()); break; case ByteCode.DCONST_0: case ByteCode.DCONST_1: typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.ILOAD: typeStack = typeStack.push(IntType.v()); break; case ByteCode.FLOAD: typeStack = typeStack.push(FloatType.v()); break; case ByteCode.ALOAD: typeStack = typeStack.push(RefType.v("java.lang.Object")); // this is highly imprecise break; case ByteCode.DLOAD: typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.LLOAD: typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: typeStack = typeStack.push(IntType.v()); break; case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: typeStack = typeStack.push(FloatType.v()); break; case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: typeStack = typeStack.push(RefType.v("java.lang.Object")); // this is highly imprecise break; case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.ISTORE: typeStack = popSafe(typeStack, IntType.v()); break; case ByteCode.FSTORE: typeStack = popSafe(typeStack, FloatType.v()); break; case ByteCode.ASTORE: typeStack = typeStack.pop(); break; case ByteCode.LSTORE: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); break; case ByteCode.DSTORE: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); break; case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: typeStack = popSafe(typeStack, IntType.v()); break; case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: typeStack = popSafe(typeStack, FloatType.v()); break; case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: if (!(typeStack.top() instanceof StmtAddressType) && !(typeStack.top() instanceof RefType) && !(typeStack.top() instanceof ArrayType)) { throw new RuntimeException("Astore failed, invalid stack type: " + typeStack.top()); } typeStack = typeStack.pop(); break; case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); break; case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); break; case ByteCode.IINC: break; case ByteCode.WIDE: throw new RuntimeException("Wide instruction should not be encountered"); // break; case ByteCode.NEWARRAY: { typeStack = popSafe(typeStack, IntType.v()); Type baseType = jimpleTypeOfAtype(((Instruction_Newarray) ins).atype); typeStack = typeStack.push(ArrayType.v(baseType, 1)); break; } case ByteCode.ANEWARRAY: { CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[((Instruction_Anewarray) ins).arg_i]; String name = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); name = name.replace('/', '.'); Type baseType; if (name.startsWith("[")) { String baseName = getClassName(constant_pool, ((Instruction_Anewarray) ins).arg_i); baseType = Util.v().jimpleTypeOfFieldDescriptor(baseName); } else { baseType = RefType.v(name); } typeStack = popSafe(typeStack, IntType.v()); typeStack = typeStack.push(baseType.makeArrayType()); break; } case ByteCode.MULTIANEWARRAY: { int bdims = (((Instruction_Multianewarray) ins).dims); CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[((Instruction_Multianewarray) ins).arg_i]; String arrayDescriptor = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); ArrayType arrayType = (ArrayType) Util.v().jimpleTypeOfFieldDescriptor(arrayDescriptor); for (int j = 0; j < bdims; j++) { typeStack = popSafe(typeStack, IntType.v()); } typeStack = typeStack.push(arrayType); break; } case ByteCode.ARRAYLENGTH: typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(IntType.v()); break; case ByteCode.IALOAD: case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.SALOAD: typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(IntType.v()); break; case ByteCode.FALOAD: typeStack = popSafe(typeStack, FloatType.v()); typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(FloatType.v()); break; case ByteCode.AALOAD: { typeStack = popSafe(typeStack, IntType.v()); if (typeStack.top() instanceof ArrayType) { ArrayType arrayType = (ArrayType) typeStack.top(); typeStack = popSafeRefType(typeStack); if (arrayType.numDimensions == 1) { typeStack = typeStack.push(arrayType.baseType); } else { typeStack = typeStack.push(ArrayType.v(arrayType.baseType, arrayType.numDimensions - 1)); } } else { // it's a null object typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(RefType.v("java.lang.Object")); } break; } case ByteCode.LALOAD: typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.DALOAD: typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.IASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.SASTORE: typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); break; case ByteCode.AASTORE: typeStack = popSafeRefType(typeStack); typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); break; case ByteCode.FASTORE: typeStack = popSafe(typeStack, FloatType.v()); typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); break; case ByteCode.LASTORE: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); break; case ByteCode.DASTORE: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafeRefType(typeStack); break; case ByteCode.NOP: break; case ByteCode.POP: typeStack = typeStack.pop(); break; case ByteCode.POP2: typeStack = typeStack.pop(); typeStack = typeStack.pop(); break; case ByteCode.DUP: typeStack = typeStack.push(typeStack.top()); break; case ByteCode.DUP2: { Type topType = typeStack.get(typeStack.topIndex()), secondType = typeStack.get(typeStack.topIndex() - 1); typeStack = (typeStack.push(secondType)).push(topType); break; } case ByteCode.DUP_X1: { Type topType = typeStack.get(typeStack.topIndex()), secondType = typeStack.get(typeStack.topIndex() - 1); typeStack = typeStack.pop().pop(); typeStack = typeStack.push(topType).push(secondType).push(topType); break; } case ByteCode.DUP_X2: { Type topType = typeStack.get(typeStack.topIndex()), secondType = typeStack.get(typeStack.topIndex() - 1), thirdType = typeStack.get(typeStack.topIndex() - 2); typeStack = typeStack.pop().pop().pop(); typeStack = typeStack.push(topType).push(thirdType).push(secondType).push(topType); break; } case ByteCode.DUP2_X1: { Type topType = typeStack.get(typeStack.topIndex()), secondType = typeStack.get(typeStack.topIndex() - 1), thirdType = typeStack.get(typeStack.topIndex() - 2); typeStack = typeStack.pop().pop().pop(); typeStack = typeStack.push(secondType).push(topType).push(thirdType).push(secondType).push(topType); break; } case ByteCode.DUP2_X2: { Type topType = typeStack.get(typeStack.topIndex()), secondType = typeStack.get(typeStack.topIndex() - 1), thirdType = typeStack.get(typeStack.topIndex() - 2), fourthType = typeStack.get(typeStack.topIndex() - 3); typeStack = typeStack.pop().pop().pop().pop(); typeStack = typeStack.push(secondType).push(topType).push(fourthType).push(thirdType).push(secondType).push(topType); break; } case ByteCode.SWAP: { Type topType = typeStack.top(); typeStack = typeStack.pop(); Type secondType = typeStack.top(); typeStack = typeStack.pop(); typeStack = typeStack.push(topType); typeStack = typeStack.push(secondType); break; } case ByteCode.IADD: case ByteCode.ISUB: case ByteCode.IMUL: case ByteCode.IDIV: case ByteCode.IREM: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.IUSHR: case ByteCode.IAND: case ByteCode.IOR: case ByteCode.IXOR: typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafe(typeStack, IntType.v()); typeStack = typeStack.push(IntType.v()); break; case ByteCode.LUSHR: case ByteCode.LSHR: case ByteCode.LSHL: typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.LREM: case ByteCode.LDIV: case ByteCode.LMUL: case ByteCode.LSUB: case ByteCode.LADD: case ByteCode.LAND: case ByteCode.LOR: case ByteCode.LXOR: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.FREM: case ByteCode.FDIV: case ByteCode.FMUL: case ByteCode.FSUB: case ByteCode.FADD: typeStack = popSafe(typeStack, FloatType.v()); typeStack = popSafe(typeStack, FloatType.v()); typeStack = typeStack.push(FloatType.v()); break; case ByteCode.DREM: case ByteCode.DDIV: case ByteCode.DMUL: case ByteCode.DSUB: case ByteCode.DADD: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.INEG: case ByteCode.LNEG: case ByteCode.FNEG: case ByteCode.DNEG: // Doesn't check to see if the required types are on the stack, but it should // if it wanted to be safe. break; case ByteCode.I2L: typeStack = popSafe(typeStack, IntType.v()); typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.I2F: typeStack = popSafe(typeStack, IntType.v()); typeStack = typeStack.push(FloatType.v()); break; case ByteCode.I2D: typeStack = popSafe(typeStack, IntType.v()); typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.L2I: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = typeStack.push(IntType.v()); break; case ByteCode.L2F: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = typeStack.push(FloatType.v()); break; case ByteCode.L2D: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.F2I: typeStack = popSafe(typeStack, FloatType.v()); typeStack = typeStack.push(IntType.v()); break; case ByteCode.F2L: typeStack = popSafe(typeStack, FloatType.v()); typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.F2D: typeStack = popSafe(typeStack, FloatType.v()); typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); break; case ByteCode.D2I: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = typeStack.push(IntType.v()); break; case ByteCode.D2L: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); break; case ByteCode.D2F: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = typeStack.push(FloatType.v()); break; case ByteCode.INT2BYTE: break; case ByteCode.INT2CHAR: break; case ByteCode.INT2SHORT: break; case ByteCode.IFEQ: case ByteCode.IFGT: case ByteCode.IFLT: case ByteCode.IFLE: case ByteCode.IFNE: case ByteCode.IFGE: typeStack = popSafe(typeStack, IntType.v()); break; case ByteCode.IFNULL: case ByteCode.IFNONNULL: typeStack = popSafeRefType(typeStack); break; case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ICMPNE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPGE: typeStack = popSafe(typeStack, IntType.v()); typeStack = popSafe(typeStack, IntType.v()); break; case ByteCode.LCMP: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); typeStack = typeStack.push(IntType.v()); break; case ByteCode.FCMPL: case ByteCode.FCMPG: typeStack = popSafe(typeStack, FloatType.v()); typeStack = popSafe(typeStack, FloatType.v()); typeStack = typeStack.push(IntType.v()); break; case ByteCode.DCMPL: case ByteCode.DCMPG: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); typeStack = typeStack.push(IntType.v()); break; case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: typeStack = popSafeRefType(typeStack); typeStack = popSafeRefType(typeStack); break; case ByteCode.GOTO: case ByteCode.GOTO_W: break; case ByteCode.JSR: case ByteCode.JSR_W: typeStack = typeStack.push(StmtAddressType.v()); break; case ByteCode.RET: break; case ByteCode.RET_W: break; case ByteCode.RETURN: break; case ByteCode.IRETURN: typeStack = popSafe(typeStack, IntType.v()); break; case ByteCode.FRETURN: typeStack = popSafe(typeStack, FloatType.v()); break; case ByteCode.ARETURN: typeStack = popSafeRefType(typeStack); break; case ByteCode.DRETURN: typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); break; case ByteCode.LRETURN: typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); break; case ByteCode.BREAKPOINT: break; case ByteCode.TABLESWITCH: typeStack = popSafe(typeStack, IntType.v()); break; case ByteCode.LOOKUPSWITCH: typeStack = popSafe(typeStack, IntType.v()); break; case ByteCode.PUTFIELD: { Type type = byteCodeTypeOf(jimpleTypeOfFieldInFieldRef(cm, constant_pool, ((Instruction_Putfield) ins).arg_i)); if (type.equals(DoubleType.v())) { typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); } else if (type.equals(LongType.v())) { typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); } else if (type instanceof RefType) { typeStack = popSafeRefType(typeStack); } else { typeStack = popSafe(typeStack, type); } typeStack = popSafeRefType(typeStack); break; } case ByteCode.GETFIELD: { Type type = byteCodeTypeOf(jimpleTypeOfFieldInFieldRef(cm, constant_pool, ((Instruction_Getfield) ins).arg_i)); typeStack = popSafeRefType(typeStack); if (type.equals(DoubleType.v())) { typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); } else if (type.equals(LongType.v())) { typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); } else { typeStack = typeStack.push(type); } break; } case ByteCode.PUTSTATIC: { Type type = byteCodeTypeOf(jimpleTypeOfFieldInFieldRef(cm, constant_pool, ((Instruction_Putstatic) ins).arg_i)); if (type.equals(DoubleType.v())) { typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); } else if (type.equals(LongType.v())) { typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); } else if (type instanceof RefType) { typeStack = popSafeRefType(typeStack); } else { typeStack = popSafe(typeStack, type); } break; } case ByteCode.GETSTATIC: { Type type = byteCodeTypeOf(jimpleTypeOfFieldInFieldRef(cm, constant_pool, ((Instruction_Getstatic) ins).arg_i)); if (type.equals(DoubleType.v())) { typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); } else if (type.equals(LongType.v())) { typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); } else { typeStack = typeStack.push(type); } break; } case ByteCode.INVOKEDYNAMIC: { Instruction_Invokedynamic iv = (Instruction_Invokedynamic) ins; CONSTANT_InvokeDynamic_info iv_info = (CONSTANT_InvokeDynamic_info) constant_pool[iv.invoke_dynamic_index]; int args = cp_info.countParams(constant_pool, iv_info.name_and_type_index); Type returnType = byteCodeTypeOf(jimpleReturnTypeOfNameAndType(cm, constant_pool, iv_info.name_and_type_index)); // pop off parameters. for (int j = args - 1; j >= 0; j--) { if (typeStack.top().equals(Long2ndHalfType.v())) { typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); } else if (typeStack.top().equals(Double2ndHalfType.v())) { typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); } else { typeStack = popSafe(typeStack, typeStack.top()); } } if (!returnType.equals(VoidType.v())) { typeStack = smartPush(typeStack, returnType); } break; } case ByteCode.INVOKEVIRTUAL: { Instruction_Invokevirtual iv = (Instruction_Invokevirtual) ins; int args = cp_info.countParams(constant_pool, iv.arg_i); Type returnType = byteCodeTypeOf(jimpleReturnTypeOfMethodRef(cm, constant_pool, iv.arg_i)); // pop off parameters. for (int j = args - 1; j >= 0; j--) { if (typeStack.top().equals(Long2ndHalfType.v())) { typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); } else if (typeStack.top().equals(Double2ndHalfType.v())) { typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); } else { typeStack = popSafe(typeStack, typeStack.top()); } } typeStack = popSafeRefType(typeStack); if (!returnType.equals(VoidType.v())) { typeStack = smartPush(typeStack, returnType); } break; } case ByteCode.INVOKENONVIRTUAL: { Instruction_Invokenonvirtual iv = (Instruction_Invokenonvirtual) ins; int args = cp_info.countParams(constant_pool, iv.arg_i); Type returnType = byteCodeTypeOf(jimpleReturnTypeOfMethodRef(cm, constant_pool, iv.arg_i)); // pop off parameters. for (int j = args - 1; j >= 0; j--) { if (typeStack.top().equals(Long2ndHalfType.v())) { typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); } else if (typeStack.top().equals(Double2ndHalfType.v())) { typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); } else { typeStack = popSafe(typeStack, typeStack.top()); } } typeStack = popSafeRefType(typeStack); if (!returnType.equals(VoidType.v())) { typeStack = smartPush(typeStack, returnType); } break; } case ByteCode.INVOKESTATIC: { Instruction_Invokestatic iv = (Instruction_Invokestatic) ins; int args = cp_info.countParams(constant_pool, iv.arg_i); Type returnType = byteCodeTypeOf(jimpleReturnTypeOfMethodRef(cm, constant_pool, iv.arg_i)); // pop off parameters. for (int j = args - 1; j >= 0; j--) { if (typeStack.top().equals(Long2ndHalfType.v())) { typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); } else if (typeStack.top().equals(Double2ndHalfType.v())) { typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); } else { typeStack = popSafe(typeStack, typeStack.top()); } } if (!returnType.equals(VoidType.v())) { typeStack = smartPush(typeStack, returnType); } break; } case ByteCode.INVOKEINTERFACE: { Instruction_Invokeinterface iv = (Instruction_Invokeinterface) ins; int args = cp_info.countParams(constant_pool, iv.arg_i); Type returnType = byteCodeTypeOf(jimpleReturnTypeOfInterfaceMethodRef(cm, constant_pool, iv.arg_i)); // pop off parameters. for (int j = args - 1; j >= 0; j--) { if (typeStack.top().equals(Long2ndHalfType.v())) { typeStack = popSafe(typeStack, Long2ndHalfType.v()); typeStack = popSafe(typeStack, LongType.v()); } else if (typeStack.top().equals(Double2ndHalfType.v())) { typeStack = popSafe(typeStack, Double2ndHalfType.v()); typeStack = popSafe(typeStack, DoubleType.v()); } else { typeStack = popSafe(typeStack, typeStack.top()); } } typeStack = popSafeRefType(typeStack); if (!returnType.equals(VoidType.v())) { typeStack = smartPush(typeStack, returnType); } break; } case ByteCode.ATHROW: // technically athrow leaves the stack in an undefined // state. In fact, the top value is the one we actually // throw, but it should stay on the stack since the exception // handler expects to start that way, at least in the real JVM. break; case ByteCode.NEW: { Type type = RefType.v(getClassName(constant_pool, ((Instruction_New) ins).arg_i)); typeStack = typeStack.push(type); break; } case ByteCode.CHECKCAST: { String className = getClassName(constant_pool, ((Instruction_Checkcast) ins).arg_i); Type castType; if (className.startsWith("[")) { castType = Util.v().jimpleTypeOfFieldDescriptor(getClassName(constant_pool, ((Instruction_Checkcast) ins).arg_i)); } else { castType = RefType.v(className); } typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(castType); break; } case ByteCode.INSTANCEOF: { typeStack = popSafeRefType(typeStack); typeStack = typeStack.push(IntType.v()); break; } case ByteCode.MONITORENTER: typeStack = popSafeRefType(typeStack); break; case ByteCode.MONITOREXIT: typeStack = popSafeRefType(typeStack); break; default: throw new RuntimeException("processFlow failed: Unknown bytecode instruction: " + x); } return new OutFlow(typeStack); } private Type jimpleTypeOfFieldInFieldRef(Scene cm, cp_info[] constant_pool, int index) { CONSTANT_Fieldref_info fr = (CONSTANT_Fieldref_info) (constant_pool[index]); CONSTANT_NameAndType_info nat = (CONSTANT_NameAndType_info) (constant_pool[fr.name_and_type_index]); String fieldDescriptor = ((CONSTANT_Utf8_info) (constant_pool[nat.descriptor_index])).convert(); return Util.v().jimpleTypeOfFieldDescriptor(fieldDescriptor); } private Type jimpleReturnTypeOfNameAndType(Scene cm, cp_info[] constant_pool, int index) { CONSTANT_NameAndType_info nat = (CONSTANT_NameAndType_info) (constant_pool[index]); String methodDescriptor = ((CONSTANT_Utf8_info) (constant_pool[nat.descriptor_index])).convert(); return Util.v().jimpleReturnTypeOfMethodDescriptor(methodDescriptor); } private Type jimpleReturnTypeOfMethodRef(Scene cm, cp_info[] constant_pool, int index) { CONSTANT_Methodref_info mr = (CONSTANT_Methodref_info) (constant_pool[index]); CONSTANT_NameAndType_info nat = (CONSTANT_NameAndType_info) (constant_pool[mr.name_and_type_index]); String methodDescriptor = ((CONSTANT_Utf8_info) (constant_pool[nat.descriptor_index])).convert(); return Util.v().jimpleReturnTypeOfMethodDescriptor(methodDescriptor); } private Type jimpleReturnTypeOfInterfaceMethodRef(Scene cm, cp_info[] constant_pool, int index) { CONSTANT_InterfaceMethodref_info mr = (CONSTANT_InterfaceMethodref_info) (constant_pool[index]); CONSTANT_NameAndType_info nat = (CONSTANT_NameAndType_info) (constant_pool[mr.name_and_type_index]); String methodDescriptor = ((CONSTANT_Utf8_info) (constant_pool[nat.descriptor_index])).convert(); return Util.v().jimpleReturnTypeOfMethodDescriptor(methodDescriptor); } private OutFlow processCPEntry(cp_info constant_pool[], int i, TypeStack typeStack, SootMethod jmethod) { cp_info c = constant_pool[i]; if (c instanceof CONSTANT_Integer_info) { typeStack = typeStack.push(IntType.v()); } else if (c instanceof CONSTANT_Float_info) { typeStack = typeStack.push(FloatType.v()); } else if (c instanceof CONSTANT_Long_info) { typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); } else if (c instanceof CONSTANT_Double_info) { typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); } else if (c instanceof CONSTANT_String_info) { typeStack = typeStack.push(RefType.v("java.lang.String")); } else if (c instanceof CONSTANT_Utf8_info) { typeStack = typeStack.push(RefType.v("java.lang.String")); } else if (c instanceof CONSTANT_Class_info) { CONSTANT_Class_info info = (CONSTANT_Class_info) c; String name = ((CONSTANT_Utf8_info) (constant_pool[info.name_index])).convert(); name = name.replace('/', '.'); if (name.charAt(0) == '[') { int dim = 0; while (name.charAt(dim) == '[') { dim++; } // array type Type baseType = null; char typeIndicator = name.charAt(dim); switch (typeIndicator) { case 'I': baseType = IntType.v(); break; case 'C': baseType = CharType.v(); break; case 'F': baseType = FloatType.v(); break; case 'D': baseType = DoubleType.v(); break; case 'B': baseType = ByteType.v(); break; case 'S': baseType = ShortType.v(); break; case 'Z': baseType = BooleanType.v(); break; case 'J': baseType = LongType.v(); break; case 'L': baseType = RefType.v(name.substring(dim + 1, name.length() - 1)); break; default: throw new RuntimeException("Unknown Array Base Type in Class Constant"); } typeStack = typeStack.push(ArrayType.v(baseType, dim)); } else { typeStack = typeStack.push(RefType.v(name)); } } else { throw new RuntimeException("Attempting to push a non-constant cp entry" + c.getClass()); } return new OutFlow(typeStack); } TypeStack smartPush(TypeStack typeStack, Type type) { if (type.equals(LongType.v())) { typeStack = typeStack.push(LongType.v()); typeStack = typeStack.push(Long2ndHalfType.v()); } else if (type.equals(DoubleType.v())) { typeStack = typeStack.push(DoubleType.v()); typeStack = typeStack.push(Double2ndHalfType.v()); } else { typeStack = typeStack.push(type); } return typeStack; } TypeStack popSafeRefType(TypeStack typeStack) { /* * if(!(typeStack.top() instanceof RefType) && !(typeStack.top() instanceof ArrayType)) { throw new * RuntimeException("popSafe failed; top: " + typeStack.top() + " required: RefType"); } */ return typeStack.pop(); } TypeStack popSafeArrayType(TypeStack typeStack) { /* * if(!(typeStack.top() instanceof ArrayType) && !(RefType.v("null").equals(typeStack.top()))) { throw new * RuntimeException("popSafe failed; top: " + typeStack.top() + " required: ArrayType"); } */ return typeStack.pop(); } TypeStack popSafe(TypeStack typeStack, Type requiredType) { /* * if(!typeStack.top().equals(requiredType)) throw new RuntimeException("popSafe failed; top: " + typeStack.top() + * " required: " + requiredType); */ return typeStack.pop(); } void confirmType(Type actualType, Type requiredType) { /* * if(!actualType.equals(requiredType)) throw new RuntimeException("confirmType failed; actualType: " + actualType + * " required: " + requiredType); */ } String getClassName(cp_info[] constant_pool, int index) { CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[index]; String name = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); return name.replace('/', '.'); } void confirmRefType(Type actualType) { /* * if(!(actualType instanceof RefType) && !(actualType instanceof ArrayType)) throw new * RuntimeException("confirmRefType failed; actualType: " + actualType); */ } /** * Runs through the given bbq contents performing the target fix-up pass; Requires all reachable blocks to have their done * flags set to true, and this resets them all back to false; * * @param bbq * queue of BasicBlocks to process. * @see jimpleTargetFixup */ private void processTargetFixup(BBQ bbq) { BasicBlock b, p; Stmt s; while (!bbq.isEmpty()) { try { b = bbq.pull(); } catch (NoSuchElementException e) { break; } s = b.getTailJStmt(); if (s instanceof GotoStmt) { if (b.succ.size() == 1) { // Regular goto ((GotoStmt) s).setTarget(b.succ.firstElement().getHeadJStmt()); } else { // Goto derived from a jsr bytecode /* * if((BasicBlock)(b.succ.firstElement())==b.next) ((GotoStmt)s).setTarget(((BasicBlock) * b.succ.elementAt(1)).getHeadJStmt()); else ((GotoStmt)s).setTarget(((BasicBlock) * b.succ.firstElement()).getHeadJStmt()); */ logger.debug("Error :"); for (int i = 0; i < b.statements.size(); i++) { logger.debug("" + b.statements.get(i)); } throw new RuntimeException(b + " has " + b.succ.size() + " successors."); } } else if (s instanceof IfStmt) { if (b.succ.size() != 2) { logger.debug("How can an if not have 2 successors?"); } if ((b.succ.firstElement()) == b.next) { ((IfStmt) s).setTarget(b.succ.elementAt(1).getHeadJStmt()); } else { ((IfStmt) s).setTarget(b.succ.firstElement().getHeadJStmt()); } } else if (s instanceof TableSwitchStmt) { int count = 0; TableSwitchStmt sts = (TableSwitchStmt) s; // Successors of the basic block ending with a switch statement // are listed in the successor vector in order, with the // default as the very first (0-th entry) for (BasicBlock basicBlock : b.succ) { p = (basicBlock); if (count == 0) { sts.setDefaultTarget(p.getHeadJStmt()); } else { sts.setTarget(count - 1, p.getHeadJStmt()); } count++; } } else if (s instanceof LookupSwitchStmt) { int count = 0; LookupSwitchStmt sls = (LookupSwitchStmt) s; // Successors of the basic block ending with a switch statement // are listed in the successor vector in order, with the // default as the very first (0-th entry) for (BasicBlock basicBlock : b.succ) { p = (basicBlock); if (count == 0) { sls.setDefaultTarget(p.getHeadJStmt()); } else { sls.setTarget(count - 1, p.getHeadJStmt()); } count++; } } b.done = false; for (BasicBlock basicBlock : b.succ) { p = (basicBlock); if (p.done) { bbq.push(p); } } } } /** * After the initial jimple construction, a second pass is made to fix up missing Stmt targets for <tt>goto</tt>s, * <tt>if</tt>'s etc. * * @param c * code attribute of this method. * @see CFG#jimplify */ void jimpleTargetFixup() { BasicBlock b; BBQ bbq = new BBQ(); Code_attribute c = method.locate_code_attribute(); if (c == null) { return; } // Reset all the dones to true { BasicBlock bb = cfg; while (bb != null) { bb.done = true; bb = bb.next; } } // first process the main code bbq.push(cfg); processTargetFixup(bbq); // then the exceptions if (bbq.isEmpty()) { int i; for (i = 0; i < c.exception_table_length; i++) { b = c.exception_table[i].b; // if block hasn't yet been processed... if (b != null && b.done) { bbq.push(b); processTargetFixup(bbq); if (!bbq.isEmpty()) { logger.debug("Error 2nd processing exception block."); break; } } } } } private void generateJimpleForCPEntry(cp_info constant_pool[], int i, TypeStack typeStack, TypeStack postTypeStack, SootMethod jmethod, List<Stmt> statements) { Stmt stmt; Value rvalue; cp_info c = constant_pool[i]; if (c instanceof CONSTANT_Integer_info) { CONSTANT_Integer_info ci = (CONSTANT_Integer_info) c; rvalue = IntConstant.v((int) ci.bytes); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else if (c instanceof CONSTANT_Float_info) { CONSTANT_Float_info cf = (CONSTANT_Float_info) c; rvalue = FloatConstant.v(cf.convert()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else if (c instanceof CONSTANT_Long_info) { CONSTANT_Long_info cl = (CONSTANT_Long_info) c; rvalue = LongConstant.v(cl.convert()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else if (c instanceof CONSTANT_Double_info) { CONSTANT_Double_info cd = (CONSTANT_Double_info) c; rvalue = DoubleConstant.v(cd.convert()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else if (c instanceof CONSTANT_String_info) { CONSTANT_String_info cs = (CONSTANT_String_info) c; String constant = cs.toString(constant_pool); if (constant.startsWith("\"") && constant.endsWith("\"")) { constant = constant.substring(1, constant.length() - 1); } rvalue = StringConstant.v(constant); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else if (c instanceof CONSTANT_Utf8_info) { CONSTANT_Utf8_info cu = (CONSTANT_Utf8_info) c; String constant = cu.convert(); if (constant.startsWith("\"") && constant.endsWith("\"")) { constant = constant.substring(1, constant.length() - 1); } rvalue = StringConstant.v(constant); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else if (c instanceof CONSTANT_Class_info) { String className = ((CONSTANT_Utf8_info) (constant_pool[((CONSTANT_Class_info) c).name_index])).convert(); rvalue = ClassConstant.v(className); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else { throw new RuntimeException("Attempting to push a non-constant cp entry" + c); } statements.add(stmt); } void generateJimple(Instruction ins, TypeStack typeStack, TypeStack postTypeStack, cp_info constant_pool[], List<Stmt> statements, BasicBlock basicBlock) { Value[] params; Local l1 = null, l2 = null, l3 = null, l4 = null; Expr rhs = null; ConditionExpr co = null; ArrayRef a = null; int args; Value rvalue; // int localIndex; Stmt stmt = null; int x = ((ins.code)) & 0xff; switch (x) { case ByteCode.BIPUSH: rvalue = IntConstant.v(((Instruction_Bipush) ins).arg_b); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); break; case ByteCode.SIPUSH: rvalue = IntConstant.v(((Instruction_Sipush) ins).arg_i); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); break; case ByteCode.LDC1: generateJimpleForCPEntry(constant_pool, ((Instruction_Ldc1) ins).arg_b, typeStack, postTypeStack, jmethod, statements); break; case ByteCode.LDC2: case ByteCode.LDC2W: generateJimpleForCPEntry(constant_pool, ((Instruction_intindex) ins).arg_i, typeStack, postTypeStack, jmethod, statements); break; case ByteCode.ACONST_NULL: rvalue = NullConstant.v(); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); break; case ByteCode.ICONST_M1: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: rvalue = IntConstant.v(x - ByteCode.ICONST_0); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); break; case ByteCode.LCONST_0: case ByteCode.LCONST_1: rvalue = LongConstant.v(x - ByteCode.LCONST_0); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); break; case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: rvalue = FloatConstant.v((x - ByteCode.FCONST_0)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); break; case ByteCode.DCONST_0: case ByteCode.DCONST_1: rvalue = DoubleConstant.v((x - ByteCode.DCONST_0)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); break; case ByteCode.ILOAD: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.FLOAD: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.ALOAD: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.DLOAD: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.LLOAD: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.ILOAD_0), ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.FLOAD_0), ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.ALOAD_0), ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.LLOAD_0), ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.DLOAD_0), ins); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), local); break; } case ByteCode.ISTORE: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.FSTORE: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.ASTORE: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.LSTORE: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.DSTORE: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_bytevar) ins).arg_b, ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.ISTORE_0), ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.FSTORE_0), ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.ASTORE_0), ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.LSTORE_0), ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: { Local local = Util.v().getLocalForIndex(listBody, (x - ByteCode.DSTORE_0), ins); stmt = Jimple.v().newAssignStmt(local, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.IINC: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_Iinc) ins).arg_b, ins); int amt = (((Instruction_Iinc) ins).arg_c); rhs = Jimple.v().newAddExpr(local, IntConstant.v(amt)); stmt = Jimple.v().newAssignStmt(local, rhs); break; } case ByteCode.WIDE: throw new RuntimeException("WIDE instruction should not be encountered anymore"); // break; case ByteCode.NEWARRAY: { Type baseType = jimpleTypeOfAtype(((Instruction_Newarray) ins).atype); rhs = Jimple.v().newNewArrayExpr(baseType, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; } case ByteCode.ANEWARRAY: { String baseName = getClassName(constant_pool, ((Instruction_Anewarray) ins).arg_i); Type baseType; if (baseName.startsWith("[")) { baseType = Util.v().jimpleTypeOfFieldDescriptor(getClassName(constant_pool, ((Instruction_Anewarray) ins).arg_i)); } else { baseType = RefType.v(baseName); } rhs = Jimple.v().newNewArrayExpr(baseType, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; } case ByteCode.MULTIANEWARRAY: { int bdims = (((Instruction_Multianewarray) ins).dims); List<Value> dims = new ArrayList<Value>(); for (int j = 0; j < bdims; j++) { dims.add(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - bdims + j + 1)); } String mstype = constant_pool[((Instruction_Multianewarray) ins).arg_i].toString(constant_pool); ArrayType jimpleType = (ArrayType) Util.v().jimpleTypeOfFieldDescriptor(mstype); rhs = Jimple.v().newNewMultiArrayExpr(jimpleType, dims); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; } case ByteCode.ARRAYLENGTH: rhs = Jimple.v().newLengthExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.IALOAD: case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.SALOAD: case ByteCode.FALOAD: case ByteCode.LALOAD: case ByteCode.DALOAD: case ByteCode.AALOAD: a = Jimple.v().newArrayRef(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), a); break; case ByteCode.IASTORE: case ByteCode.FASTORE: case ByteCode.AASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.SASTORE: a = Jimple.v().newArrayRef(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(a, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; case ByteCode.LASTORE: case ByteCode.DASTORE: a = Jimple.v().newArrayRef(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2)); stmt = Jimple.v().newAssignStmt(a, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; case ByteCode.NOP: stmt = Jimple.v().newNopStmt(); break; case ByteCode.POP: case ByteCode.POP2: stmt = Jimple.v().newNopStmt(); break; case ByteCode.DUP: stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; case ByteCode.DUP2: if (typeSize(typeStack.top()) == 2) { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); } else { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); statements.add(stmt); stmt = null; } break; case ByteCode.DUP_X1: l1 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); l2 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), l1); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), l2); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 2), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex())); statements.add(stmt); stmt = null; break; case ByteCode.DUP_X2: if (typeSize(typeStack.get(typeStack.topIndex() - 2)) == 2) { l3 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2); l1 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 2), l3); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 3), l1); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), l1); statements.add(stmt); stmt = null; } else { l3 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2); l2 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1); l1 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), l1); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), l2); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 2), l3); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex())); statements.add(stmt); stmt = null; } break; case ByteCode.DUP2_X1: if (typeSize(typeStack.get(typeStack.topIndex() - 1)) == 2) { l2 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1); l3 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), l2); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 2), l3); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 4), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1)); statements.add(stmt); stmt = null; } else { l3 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2); l2 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1); l1 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), l1); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), l2); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 2), l3); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex())); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 4), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1)); statements.add(stmt); stmt = null; } break; case ByteCode.DUP2_X2: if (typeSize(typeStack.get(typeStack.topIndex() - 1)) == 2) { l2 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), l2); statements.add(stmt); } else { l1 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); l2 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1), l2); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), l1); statements.add(stmt); } if (typeSize(typeStack.get(typeStack.topIndex() - 3)) == 2) { l4 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 3), l4); statements.add(stmt); } else { l4 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3); l3 = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 3), l4); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 2), l3); statements.add(stmt); } if (typeSize(typeStack.get(typeStack.topIndex() - 1)) == 2) { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 5), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1)); statements.add(stmt); } else { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 5), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1)); statements.add(stmt); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 4), Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex())); statements.add(stmt); } stmt = null; break; case ByteCode.SWAP: { Local first; typeStack = typeStack.push(typeStack.top()); first = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); typeStack = typeStack.pop(); // generation of a free temporary Local second = Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()); Local third = Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex() - 1); stmt = Jimple.v().newAssignStmt(first, second); statements.add(stmt); stmt = Jimple.v().newAssignStmt(second, third); statements.add(stmt); stmt = Jimple.v().newAssignStmt(third, first); statements.add(stmt); stmt = null; break; } case ByteCode.FADD: case ByteCode.IADD: rhs = Jimple.v().newAddExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.DADD: case ByteCode.LADD: rhs = Jimple.v().newAddExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.FSUB: case ByteCode.ISUB: rhs = Jimple.v().newSubExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.DSUB: case ByteCode.LSUB: rhs = Jimple.v().newSubExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.FMUL: case ByteCode.IMUL: rhs = Jimple.v().newMulExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.DMUL: case ByteCode.LMUL: rhs = Jimple.v().newMulExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.FDIV: case ByteCode.IDIV: rhs = Jimple.v().newDivExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.DDIV: case ByteCode.LDIV: rhs = Jimple.v().newDivExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.FREM: case ByteCode.IREM: rhs = Jimple.v().newRemExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.DREM: case ByteCode.LREM: rhs = Jimple.v().newRemExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.INEG: case ByteCode.LNEG: case ByteCode.FNEG: case ByteCode.DNEG: rhs = Jimple.v().newNegExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.ISHL: rhs = Jimple.v().newShlExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.ISHR: rhs = Jimple.v().newShrExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.IUSHR: rhs = Jimple.v().newUshrExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.LSHL: rhs = Jimple.v().newShlExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.LSHR: rhs = Jimple.v().newShrExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.LUSHR: rhs = Jimple.v().newUshrExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 2), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.IAND: rhs = Jimple.v().newAndExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.LAND: rhs = Jimple.v().newAndExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.IOR: rhs = Jimple.v().newOrExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.LOR: rhs = Jimple.v().newOrExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.IXOR: rhs = Jimple.v().newXorExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.LXOR: rhs = Jimple.v().newXorExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.D2L: case ByteCode.F2L: case ByteCode.I2L: rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), LongType.v()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.D2F: case ByteCode.L2F: case ByteCode.I2F: rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), FloatType.v()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.I2D: case ByteCode.L2D: case ByteCode.F2D: rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), DoubleType.v()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.L2I: case ByteCode.F2I: case ByteCode.D2I: rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), IntType.v()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.INT2BYTE: rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), ByteType.v()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.INT2CHAR: rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), CharType.v()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.INT2SHORT: rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), ShortType.v()); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.IFEQ: co = Jimple.v().newEqExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), IntConstant.v(0)); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IFNULL: co = Jimple.v().newEqExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), NullConstant.v()); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IFLT: co = Jimple.v().newLtExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), IntConstant.v(0)); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IFLE: co = Jimple.v().newLeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), IntConstant.v(0)); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IFNE: co = Jimple.v().newNeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), IntConstant.v(0)); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IFNONNULL: co = Jimple.v().newNeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), NullConstant.v()); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IFGT: co = Jimple.v().newGtExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), IntConstant.v(0)); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IFGE: co = Jimple.v().newGeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), IntConstant.v(0)); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IF_ICMPEQ: co = Jimple.v().newEqExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IF_ICMPLT: co = Jimple.v().newLtExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IF_ICMPLE: co = Jimple.v().newLeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IF_ICMPNE: co = Jimple.v().newNeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IF_ICMPGT: co = Jimple.v().newGtExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IF_ICMPGE: co = Jimple.v().newGeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.LCMP: rhs = Jimple.v().newCmpExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.FCMPL: rhs = Jimple.v().newCmplExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.FCMPG: rhs = Jimple.v().newCmpgExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.DCMPL: rhs = Jimple.v().newCmplExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.DCMPG: rhs = Jimple.v().newCmpgExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 3), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; case ByteCode.IF_ACMPEQ: co = Jimple.v().newEqExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.IF_ACMPNE: co = Jimple.v().newNeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - 1), Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); stmt = Jimple.v().newIfStmt(co, new FutureStmt()); break; case ByteCode.GOTO: stmt = Jimple.v().newGotoStmt(new FutureStmt()); break; case ByteCode.GOTO_W: stmt = Jimple.v().newGotoStmt(new FutureStmt()); break; /* * case ByteCode.JSR: case ByteCode.JSR_W: { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, * postTypeStack, postTypeStack.topIndex()), Jimple.v().newNextNextStmtRef()); * * statements.add(stmt); * * stmt = Jimple.v().newGotoStmt(new FutureStmt()); statements.add(stmt); * * stmt = null; break; } */ case ByteCode.RET: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_Ret) ins).arg_b, ins); stmt = Jimple.v().newRetStmt(local); break; } case ByteCode.RET_W: { Local local = Util.v().getLocalForIndex(listBody, ((Instruction_Ret_w) ins).arg_i, ins); stmt = Jimple.v().newRetStmt(local); break; } case ByteCode.RETURN: stmt = Jimple.v().newReturnVoidStmt(); break; case ByteCode.LRETURN: case ByteCode.DRETURN: case ByteCode.IRETURN: case ByteCode.FRETURN: case ByteCode.ARETURN: stmt = Jimple.v().newReturnStmt(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; case ByteCode.BREAKPOINT: stmt = Jimple.v().newBreakpointStmt(); break; case ByteCode.TABLESWITCH: { int lowIndex = ((Instruction_Tableswitch) ins).low, highIndex = ((Instruction_Tableswitch) ins).high; int npairs = highIndex - lowIndex + 1; stmt = Jimple.v().newTableSwitchStmt(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), lowIndex, highIndex, Arrays.asList(new FutureStmt[npairs]), new FutureStmt()); break; } case ByteCode.LOOKUPSWITCH: { List<IntConstant> matches = new ArrayList<IntConstant>(); int npairs = ((Instruction_Lookupswitch) ins).npairs; for (int j = 0; j < npairs; j++) { matches.add(IntConstant.v(((Instruction_Lookupswitch) ins).match_offsets[j * 2])); } stmt = Jimple.v().newLookupSwitchStmt(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), matches, Arrays.asList(new FutureStmt[npairs]), new FutureStmt()); break; } case ByteCode.PUTFIELD: { CONSTANT_Fieldref_info fieldInfo = (CONSTANT_Fieldref_info) constant_pool[((Instruction_Putfield) ins).arg_i]; CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[fieldInfo.class_index]; String className = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); className = className.replace('/', '.'); CONSTANT_NameAndType_info i = (CONSTANT_NameAndType_info) constant_pool[fieldInfo.name_and_type_index]; String fieldName = ((CONSTANT_Utf8_info) (constant_pool[i.name_index])).convert(); String fieldDescriptor = ((CONSTANT_Utf8_info) (constant_pool[i.descriptor_index])).convert(); Type fieldType = Util.v().jimpleTypeOfFieldDescriptor(fieldDescriptor); SootClass bclass = cm.getSootClass(className); SootFieldRef fieldRef = Scene.v().makeFieldRef(bclass, fieldName, fieldType, false); InstanceFieldRef fr = Jimple.v().newInstanceFieldRef( Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex() - typeSize(typeStack.top())), fieldRef); rvalue = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); stmt = Jimple.v().newAssignStmt(fr, rvalue); break; } case ByteCode.GETFIELD: { InstanceFieldRef fr = null; CONSTANT_Fieldref_info fieldInfo = (CONSTANT_Fieldref_info) constant_pool[((Instruction_Getfield) ins).arg_i]; CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[fieldInfo.class_index]; String className = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); className = className.replace('/', '.'); CONSTANT_NameAndType_info i = (CONSTANT_NameAndType_info) constant_pool[fieldInfo.name_and_type_index]; String fieldName = ((CONSTANT_Utf8_info) (constant_pool[i.name_index])).convert(); String fieldDescriptor = ((CONSTANT_Utf8_info) (constant_pool[i.descriptor_index])).convert(); if (className.charAt(0) == '[') { className = "java.lang.Object"; } SootClass bclass = cm.getSootClass(className); Type fieldType = Util.v().jimpleTypeOfFieldDescriptor(fieldDescriptor); SootFieldRef fieldRef = Scene.v().makeFieldRef(bclass, fieldName, fieldType, false); fr = Jimple.v().newInstanceFieldRef(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), fieldRef); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), fr); break; } case ByteCode.PUTSTATIC: { StaticFieldRef fr = null; CONSTANT_Fieldref_info fieldInfo = (CONSTANT_Fieldref_info) constant_pool[((Instruction_Putstatic) ins).arg_i]; CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[fieldInfo.class_index]; String className = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); className = className.replace('/', '.'); CONSTANT_NameAndType_info i = (CONSTANT_NameAndType_info) constant_pool[fieldInfo.name_and_type_index]; String fieldName = ((CONSTANT_Utf8_info) (constant_pool[i.name_index])).convert(); String fieldDescriptor = ((CONSTANT_Utf8_info) (constant_pool[i.descriptor_index])).convert(); Type fieldType = Util.v().jimpleTypeOfFieldDescriptor(fieldDescriptor); SootClass bclass = cm.getSootClass(className); SootFieldRef fieldRef = Scene.v().makeFieldRef(bclass, fieldName, fieldType, true); fr = Jimple.v().newStaticFieldRef(fieldRef); stmt = Jimple.v().newAssignStmt(fr, Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; } case ByteCode.GETSTATIC: { StaticFieldRef fr = null; CONSTANT_Fieldref_info fieldInfo = (CONSTANT_Fieldref_info) constant_pool[((Instruction_Getstatic) ins).arg_i]; CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[fieldInfo.class_index]; String className = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); className = className.replace('/', '.'); CONSTANT_NameAndType_info i = (CONSTANT_NameAndType_info) constant_pool[fieldInfo.name_and_type_index]; String fieldName = ((CONSTANT_Utf8_info) (constant_pool[i.name_index])).convert(); String fieldDescriptor = ((CONSTANT_Utf8_info) (constant_pool[i.descriptor_index])).convert(); Type fieldType = Util.v().jimpleTypeOfFieldDescriptor(fieldDescriptor); SootClass bclass = cm.getSootClass(className); SootFieldRef fieldRef = Scene.v().makeFieldRef(bclass, fieldName, fieldType, true); fr = Jimple.v().newStaticFieldRef(fieldRef); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), fr); break; } case ByteCode.INVOKEDYNAMIC: { Instruction_Invokedynamic iv = (Instruction_Invokedynamic) ins; CONSTANT_InvokeDynamic_info iv_info = (CONSTANT_InvokeDynamic_info) constant_pool[iv.invoke_dynamic_index]; args = cp_info.countParams(constant_pool, iv_info.name_and_type_index); SootMethodRef bootstrapMethodRef; List<Value> bootstrapArgs = new LinkedList<Value>(); int kind; { short[] bootstrapMethodTable = bootstrap_methods_attribute.method_handles; short methodSigIndex = bootstrapMethodTable[iv_info.bootstrap_method_index]; CONSTANT_MethodHandle_info mhInfo = (CONSTANT_MethodHandle_info) constant_pool[methodSigIndex]; CONSTANT_Methodref_info bsmInfo = (CONSTANT_Methodref_info) constant_pool[mhInfo.target_index]; bootstrapMethodRef = createMethodRef(constant_pool, bsmInfo, false); kind = mhInfo.kind; short[] bsmArgIndices = bootstrap_methods_attribute.arg_indices[iv_info.bootstrap_method_index]; if (bsmArgIndices.length > 0) { // logger.debug("Soot does not currently support static arguments to bootstrap methods. They will be stripped."); for (short bsmArgIndex : bsmArgIndices) { cp_info cpEntry = constant_pool[bsmArgIndex]; Value val = cpEntry.createJimpleConstantValue(constant_pool); bootstrapArgs.add(val); } } } SootMethodRef methodRef = null; CONSTANT_NameAndType_info nameAndTypeInfo = (CONSTANT_NameAndType_info) constant_pool[iv_info.name_and_type_index]; String methodName = ((CONSTANT_Utf8_info) (constant_pool[nameAndTypeInfo.name_index])).convert(); String methodDescriptor = ((CONSTANT_Utf8_info) (constant_pool[nameAndTypeInfo.descriptor_index])).convert(); SootClass bclass = cm.getSootClass(SootClass.INVOKEDYNAMIC_DUMMY_CLASS_NAME); List<Type> parameterTypes; Type returnType; // Generate parameters & returnType & parameterTypes { Type[] types = Util.v().jimpleTypesOfFieldOrMethodDescriptor(methodDescriptor); parameterTypes = new ArrayList<Type>(); for (int k = 0; k < types.length - 1; k++) { parameterTypes.add(types[k]); } returnType = types[types.length - 1]; } // we always model invokeDynamic method refs as static method references of methods on the type // SootClass.INVOKEDYNAMIC_DUMMY_CLASS_NAME methodRef = Scene.v().makeMethodRef(bclass, methodName, parameterTypes, returnType, true); // build Vector of parameters params = new Value[args]; for (int j = args - 1; j >= 0; j--) { params[j] = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); if (typeSize(typeStack.top()) == 2) { typeStack = typeStack.pop(); typeStack = typeStack.pop(); } else { typeStack = typeStack.pop(); } } rvalue = Jimple.v().newDynamicInvokeExpr(bootstrapMethodRef, bootstrapArgs, methodRef, kind, Arrays.asList(params)); if (!returnType.equals(VoidType.v())) { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else { stmt = Jimple.v().newInvokeStmt(rvalue); } break; } case ByteCode.INVOKEVIRTUAL: { Instruction_Invokevirtual iv = (Instruction_Invokevirtual) ins; args = cp_info.countParams(constant_pool, iv.arg_i); CONSTANT_Methodref_info methodInfo = (CONSTANT_Methodref_info) constant_pool[iv.arg_i]; SootMethodRef methodRef = createMethodRef(constant_pool, methodInfo, false); Type returnType = methodRef.returnType(); // build array of parameters params = new Value[args]; for (int j = args - 1; j >= 0; j--) { params[j] = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); if (typeSize(typeStack.top()) == 2) { typeStack = typeStack.pop(); typeStack = typeStack.pop(); } else { typeStack = typeStack.pop(); } } rvalue = Jimple.v().newVirtualInvokeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), methodRef, Arrays.asList(params)); if (!returnType.equals(VoidType.v())) { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else { stmt = Jimple.v().newInvokeStmt(rvalue); } break; } case ByteCode.INVOKENONVIRTUAL: { Instruction_Invokenonvirtual iv = (Instruction_Invokenonvirtual) ins; args = cp_info.countParams(constant_pool, iv.arg_i); CONSTANT_Methodref_info methodInfo = (CONSTANT_Methodref_info) constant_pool[iv.arg_i]; SootMethodRef methodRef = createMethodRef(constant_pool, methodInfo, false); Type returnType = methodRef.returnType(); // build array of parameters params = new Value[args]; for (int j = args - 1; j >= 0; j--) { params[j] = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); if (typeSize(typeStack.top()) == 2) { typeStack = typeStack.pop(); typeStack = typeStack.pop(); } else { typeStack = typeStack.pop(); } } rvalue = Jimple.v().newSpecialInvokeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), methodRef, Arrays.asList(params)); if (!returnType.equals(VoidType.v())) { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else { stmt = Jimple.v().newInvokeStmt(rvalue); } break; } case ByteCode.INVOKESTATIC: { Instruction_Invokestatic is = (Instruction_Invokestatic) ins; args = cp_info.countParams(constant_pool, is.arg_i); CONSTANT_Methodref_info methodInfo = (CONSTANT_Methodref_info) constant_pool[is.arg_i]; SootMethodRef methodRef = createMethodRef(constant_pool, methodInfo, true); Type returnType = methodRef.returnType(); // build Vector of parameters params = new Value[args]; for (int j = args - 1; j >= 0; j--) { /* * logger.debug("BeforeTypeStack"); typeStack.print(G.v().out); * * logger.debug("AfterTypeStack"); postTypeStack.print(G.v().out); */ params[j] = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); if (typeSize(typeStack.top()) == 2) { typeStack = typeStack.pop(); typeStack = typeStack.pop(); } else { typeStack = typeStack.pop(); } } rvalue = Jimple.v().newStaticInvokeExpr(methodRef, Arrays.asList(params)); if (!returnType.equals(VoidType.v())) { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else { stmt = Jimple.v().newInvokeStmt(rvalue); } break; } case ByteCode.INVOKEINTERFACE: { Instruction_Invokeinterface ii = (Instruction_Invokeinterface) ins; args = cp_info.countParams(constant_pool, ii.arg_i); CONSTANT_InterfaceMethodref_info methodInfo = (CONSTANT_InterfaceMethodref_info) constant_pool[ii.arg_i]; SootMethodRef methodRef = createMethodRef(constant_pool, methodInfo, false); Type returnType = methodRef.returnType(); // build Vector of parameters params = new Value[args]; for (int j = args - 1; j >= 0; j--) { params[j] = Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()); if (typeSize(typeStack.top()) == 2) { typeStack = typeStack.pop(); typeStack = typeStack.pop(); } else { typeStack = typeStack.pop(); } } rvalue = Jimple.v().newInterfaceInvokeExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), methodRef, Arrays.asList(params)); if (!returnType.equals(VoidType.v())) { stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rvalue); } else { stmt = Jimple.v().newInvokeStmt(rvalue); } break; } case ByteCode.ATHROW: stmt = Jimple.v().newThrowStmt(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; case ByteCode.NEW: { SootClass bclass = cm.getSootClass(getClassName(constant_pool, ((Instruction_New) ins).arg_i)); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), Jimple.v().newNewExpr(RefType.v(bclass.getName()))); break; } case ByteCode.CHECKCAST: { String className = getClassName(constant_pool, ((Instruction_Checkcast) ins).arg_i); Type castType; if (className.startsWith("[")) { castType = Util.v().jimpleTypeOfFieldDescriptor(getClassName(constant_pool, ((Instruction_Checkcast) ins).arg_i)); } else { castType = RefType.v(className); } rhs = Jimple.v().newCastExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), castType); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; } case ByteCode.INSTANCEOF: { Type checkType; String className = getClassName(constant_pool, ((Instruction_Instanceof) ins).arg_i); if (className.startsWith("[")) { checkType = Util.v().jimpleTypeOfFieldDescriptor(getClassName(constant_pool, ((Instruction_Instanceof) ins).arg_i)); } else { checkType = RefType.v(className); } rhs = Jimple.v().newInstanceOfExpr(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex()), checkType); stmt = Jimple.v().newAssignStmt(Util.v().getLocalForStackOp(listBody, postTypeStack, postTypeStack.topIndex()), rhs); break; } case ByteCode.MONITORENTER: stmt = Jimple.v().newEnterMonitorStmt(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; case ByteCode.MONITOREXIT: stmt = Jimple.v().newExitMonitorStmt(Util.v().getLocalForStackOp(listBody, typeStack, typeStack.topIndex())); break; default: throw new RuntimeException("Unrecognized bytecode instruction: " + x); } if (stmt != null) { if (Options.v().keep_offset()) { stmt.addTag(new BytecodeOffsetTag(ins.label)); } statements.add(stmt); } } private SootMethodRef createMethodRef(cp_info[] constant_pool, ICONSTANT_Methodref_info methodInfo, boolean isStatic) { SootMethodRef methodRef; CONSTANT_Class_info c = (CONSTANT_Class_info) constant_pool[methodInfo.getClassIndex()]; String className = ((CONSTANT_Utf8_info) (constant_pool[c.name_index])).convert(); className = className.replace('/', '.'); CONSTANT_NameAndType_info i = (CONSTANT_NameAndType_info) constant_pool[methodInfo.getNameAndTypeIndex()]; String methodName = ((CONSTANT_Utf8_info) (constant_pool[i.name_index])).convert(); String methodDescriptor = ((CONSTANT_Utf8_info) (constant_pool[i.descriptor_index])).convert(); if (className.charAt(0) == '[') { className = "java.lang.Object"; } SootClass bclass = cm.getSootClass(className); List<Type> parameterTypes; Type returnType; // Generate parameters & returnType & parameterTypes { Type[] types = Util.v().jimpleTypesOfFieldOrMethodDescriptor(methodDescriptor); parameterTypes = new ArrayList<Type>(); for (int k = 0; k < types.length - 1; k++) { parameterTypes.add(types[k]); } returnType = types[types.length - 1]; } methodRef = Scene.v().makeMethodRef(bclass, methodName, parameterTypes, returnType, isStatic); return methodRef; } Type jimpleTypeOfAtype(int atype) { switch (atype) { case 4: return BooleanType.v(); case 5: return CharType.v(); case 6: return FloatType.v(); case 7: return DoubleType.v(); case 8: return ByteType.v(); case 9: return ShortType.v(); case 10: return IntType.v(); case 11: return LongType.v(); default: throw new RuntimeException("Undefined 'atype' in NEWARRAY byte instruction"); } } int typeSize(Type type) { if (type.equals(LongType.v()) || type.equals(DoubleType.v()) || type.equals(Long2ndHalfType.v()) || type.equals(Double2ndHalfType.v())) { return 2; } else { return 1; } } } class OutFlow { TypeStack typeStack; OutFlow(TypeStack typeStack) { this.typeStack = typeStack; } }
146,408
34.330357
125
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Class_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 soot.Value; import soot.jimple.ClassConstant; /** * A constant pool entry of type CONSTANT_Class. * * @see cp_info * @author Clark Verbrugge */ public class CONSTANT_Class_info extends cp_info { /** Constant pool index of name of this class. */ public int name_index; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 3; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info) (constant_pool[name_index]); return ci.convert(); } /** * Returns a String description of what kind of entry this is. * * @return the String "class". * @see cp_info#typeName */ public String typeName() { return "class"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Class_info cu = (CONSTANT_Class_info) cp; return ((CONSTANT_Utf8_info) (constant_pool[name_index])).compareTo(cp_constant_pool[cu.name_index]); } public Value createJimpleConstantValue(cp_info[] constant_pool) { CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info) (constant_pool[name_index]); String name = ci.convert(); return ClassConstant.v(name); } }
2,864
28.536082
105
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Double_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 soot.Value; import soot.jimple.DoubleConstant; /** * A constant pool entry of type CONSTANT_Double. * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_Double_info extends cp_info { /** High-order 32 bits of the double. */ public long high; /** High-order 32 bits of the double. */ public long low; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 9; } /** Converts the internal representation (two ints) to a double. */ public double convert() { return Double.longBitsToDouble(ints2long(high, low)); } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { return Double.toString(convert()); } /** * Returns a String description of what kind of entry this is. * * @return the String "double". * @see cp_info#typeName */ public String typeName() { return "double"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { double d; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Double_info cu = (CONSTANT_Double_info) cp; d = convert() - cu.convert(); return ((d > 0.0) ? 1 : ((d < 0.0) ? -1 : 0)); } public Value createJimpleConstantValue(cp_info[] constant_pool) { return DoubleConstant.v(convert()); } }
2,898
27.145631
101
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Fieldref_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 soot.Scene; import soot.Type; import soot.Value; import soot.jimple.Jimple; /** * A constant pool entry of type CONSTANT_Fieldref. * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_Fieldref_info extends cp_info { /** * Constant pool index of a CONSTANT_Class object. * * @see CONSTANT_Class_info */ public int class_index; /** * Constant pool index of a CONSTANT_NameAndType object. * * @see CONSTANT_NameAndType_info */ public int name_and_type_index; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 5; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { CONSTANT_Class_info cc = (CONSTANT_Class_info) (constant_pool[class_index]); CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[name_and_type_index]); return cc.toString(constant_pool) + "." + cn.toString(constant_pool); } /** * Returns a String description of what kind of entry this is. * * @return the String "fieldref". * @see cp_info#typeName */ public String typeName() { return "fieldref"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { int i; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Fieldref_info cu = (CONSTANT_Fieldref_info) cp; i = constant_pool[class_index].compareTo(constant_pool, cp_constant_pool[cu.class_index], cp_constant_pool); if (i != 0) { return i; } return constant_pool[name_and_type_index].compareTo(constant_pool, cp_constant_pool[cu.name_and_type_index], cp_constant_pool); } public Value createJimpleConstantValue(cp_info[] constant_pool) { CONSTANT_Class_info cc = (CONSTANT_Class_info) (constant_pool[class_index]); CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[name_and_type_index]); String className = cc.toString(constant_pool); String nameAndType = cn.toString(constant_pool); String name = nameAndType.substring(0, nameAndType.indexOf(":")); String typeName = nameAndType.substring(nameAndType.indexOf(":") + 1); Type type = Util.v().jimpleTypeOfFieldDescriptor(typeName); return Jimple.v().newStaticFieldRef(Scene.v().makeFieldRef(Scene.v().getSootClass(className), name, type, true)); } }
3,916
31.106557
117
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Float_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 soot.Value; import soot.jimple.FloatConstant; /** * A constant pool entry of type CONSTANT_Float * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_Float_info extends cp_info { /** Internal representation of the float. */ public long bytes; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 5; } /** Converts the internal representation to an actual float. */ public float convert() { return Float.intBitsToFloat((int) bytes); } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { return Float.toString(bytes); } /** * Returns a String description of what kind of entry this is. * * @return the String "float". * @see cp_info#typeName */ public String typeName() { return "float"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { float d; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Float_info cu = (CONSTANT_Float_info) cp; d = convert() - cu.convert(); return ((d > 0.0) ? 1 : ((d < 0.0) ? -1 : 0)); } public Value createJimpleConstantValue(cp_info[] constant_pool) { return FloatConstant.v(convert()); } }
2,809
26.821782
101
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Integer_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 soot.Value; import soot.jimple.IntConstant; /** * A constant pool entry of type CONSTANT_Integer * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_Integer_info extends cp_info { /** Internal representation. */ public long bytes; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 5; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { return Integer.toString((int) bytes); } /** * Returns a String description of what kind of entry this is. * * @return the String "int". * @see cp_info#typeName */ public String typeName() { return "int"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Integer_info cu = (CONSTANT_Integer_info) cp; return ((int) bytes) - (int) cu.bytes; } public Value createJimpleConstantValue(cp_info[] constant_pool) { return IntConstant.v((int) bytes); } }
2,607
26.744681
101
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_InterfaceMethodref_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 soot.Value; /** * A constant pool entry of type CONSTANT_InterfaceMethodref * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_InterfaceMethodref_info extends cp_info implements ICONSTANT_Methodref_info { /** * Constant pool index of a CONSTANT_Class object. * * @see CONSTANT_Class_info */ public int class_index; /** * Constant pool index of a CONSTANT_NameAndType object. * * @see CONSTANT_NameAndType_info */ public int name_and_type_index; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 5; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { CONSTANT_Class_info cc = (CONSTANT_Class_info) (constant_pool[class_index]); CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[name_and_type_index]); return cc.toString(constant_pool) + "." + cn.toString(constant_pool); } /** * Returns a String description of what kind of entry this is. * * @return the String "interfacemethodref". * @see cp_info#typeName */ public String typeName() { return "interfacemethodref"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { int i; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_InterfaceMethodref_info cu = (CONSTANT_InterfaceMethodref_info) cp; i = constant_pool[class_index].compareTo(constant_pool, cp_constant_pool[cu.class_index], cp_constant_pool); if (i != 0) { return i; } return constant_pool[name_and_type_index].compareTo(constant_pool, cp_constant_pool[cu.name_and_type_index], cp_constant_pool); } public Value createJimpleConstantValue(cp_info[] constant_pool) { throw new UnsupportedOperationException("cannot convert to Jimple: " + typeName()); } public int getClassIndex() { return class_index; } public int getNameAndTypeIndex() { return name_and_type_index; } }
3,555
28.882353
112
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_InvokeDynamic_info.java
package soot.coffi; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 2012 Eric Bodden * %% * 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.Value; /** * A constant pool entry of type CONSTANT_InvokeDynamic * * @see cp_info * @author Eric Bodden */ class CONSTANT_InvokeDynamic_info extends cp_info { public int bootstrap_method_index; public int name_and_type_index; public int size() { return 5; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { // currently neglects field "kind" cp_info bsm = constant_pool[bootstrap_method_index]; cp_info nat = constant_pool[name_and_type_index]; return nat.toString(constant_pool) + " - " + bsm.toString(constant_pool); } /** * Returns a String description of what kind of entry this is. * * @return the String "methodhandle". * @see cp_info#typeName */ public String typeName() { return "invokedynamic"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { int i; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_InvokeDynamic_info cu = (CONSTANT_InvokeDynamic_info) cp; i = constant_pool[bootstrap_method_index].compareTo(constant_pool, cp_constant_pool[cu.bootstrap_method_index], cp_constant_pool); if (i != 0) { return i; } i = constant_pool[name_and_type_index].compareTo(constant_pool, cp_constant_pool[cu.name_and_type_index], cp_constant_pool); return i; } public Value createJimpleConstantValue(cp_info[] constant_pool) { throw new UnsupportedOperationException("cannot convert to Jimple: " + typeName()); } }
3,020
29.21
115
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Long_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 soot.Value; import soot.jimple.LongConstant; /** * A constant pool entry of type CONSTANT_Long * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_Long_info extends cp_info { /** the upper 32 bits of the long. */ public long high; /** the lower 32 bits of the long. */ public long low; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 9; } /** Converts the internal two-int representation to an actual long. */ public long convert() { return ints2long(high, low); } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { return "(" + high + "," + low + ") = " + Long.toString(convert()); } /** * Returns a String description of what kind of entry this is. * * @return the String "long". * @see cp_info#typeName */ public String typeName() { return "long"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { long d; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Long_info cu = (CONSTANT_Long_info) cp; d = convert() - cu.convert(); return ((d > 0) ? 1 : ((d < 0) ? -1 : 0)); } public Value createJimpleConstantValue(cp_info[] constant_pool) { return LongConstant.v(convert()); } }
2,877
26.941748
101
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_MethodHandle_info.java
package soot.coffi; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 2012 Eric Bodden * %% * 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.Value; /** * A constant pool entry of type CONSTANT_MethodHandle * * @see cp_info * @author Eric Bodden */ class CONSTANT_MethodHandle_info extends cp_info { public int kind; public int target_index; public int size() { return 4; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { // currently neglects field "kind" cp_info target = constant_pool[target_index]; return target.toString(constant_pool); } /** * Returns a String description of what kind of entry this is. * * @return the String "methodhandle". * @see cp_info#typeName */ public String typeName() { return "methodhandle"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { int i; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_MethodHandle_info cu = (CONSTANT_MethodHandle_info) cp; i = constant_pool[target_index].compareTo(constant_pool, cp_constant_pool[cu.target_index], cp_constant_pool); if (i != 0) { return i; } return kind - cu.kind; } public Value createJimpleConstantValue(cp_info[] constant_pool) { // FIXME may need to determine static-ness based on "kind" field return constant_pool[target_index].createJimpleConstantValue(constant_pool); } }
2,808
27.958763
114
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Methodref_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.ArrayList; import java.util.List; import soot.Scene; import soot.Type; import soot.Value; import soot.jimple.Jimple; /** * A constant pool entry of type CONSTANT_Methodref * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_Methodref_info extends cp_info implements ICONSTANT_Methodref_info { /** * Constant pool index of a CONSTANT_Class object. * * @see CONSTANT_Class_info */ public int class_index; /** * Constant pool index of a CONSTANT_NameAndType object. * * @see CONSTANT_NameAndType_info */ public int name_and_type_index; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 5; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { CONSTANT_Class_info cc = (CONSTANT_Class_info) (constant_pool[class_index]); CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[name_and_type_index]); return cc.toString(constant_pool) + "." + cn.toString(constant_pool); } /** * Returns a String description of what kind of entry this is. * * @return the String "methodref". * @see cp_info#typeName */ public String typeName() { return "methodref"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { int i; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Methodref_info cu = (CONSTANT_Methodref_info) cp; i = constant_pool[class_index].compareTo(constant_pool, cp_constant_pool[cu.class_index], cp_constant_pool); if (i != 0) { return i; } return constant_pool[name_and_type_index].compareTo(constant_pool, cp_constant_pool[cu.name_and_type_index], cp_constant_pool); } public Value createJimpleConstantValue(cp_info[] constant_pool) { CONSTANT_Class_info cc = (CONSTANT_Class_info) (constant_pool[class_index]); CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[name_and_type_index]); String className = cc.toString(constant_pool); String nameAndType = cn.toString(constant_pool); String name = nameAndType.substring(0, nameAndType.indexOf(":")); String typeName = nameAndType.substring(nameAndType.indexOf(":") + 1); List parameterTypes; Type returnType; // Generate parameters & returnType & parameterTypes { Type[] types = Util.v().jimpleTypesOfFieldOrMethodDescriptor(typeName); parameterTypes = new ArrayList(); for (int k = 0; k < types.length - 1; k++) { parameterTypes.add(types[k]); } returnType = types[types.length - 1]; } return Jimple.v().newStaticInvokeExpr( Scene.v().makeMethodRef(Scene.v().getSootClass(className), name, parameterTypes, returnType, true)); } public int getClassIndex() { return class_index; } public int getNameAndTypeIndex() { return name_and_type_index; } }
4,490
29.55102
112
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_NameAndType_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 soot.Value; /** * A constant pool entry of type CONSTANT_NameAndType * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_NameAndType_info extends cp_info { /** * Constant pool index of the CONSTANT_Utf8 object for the name. * * @see CONSTANT_Utf8_info */ public int name_index; /** * Constant pool index of the CONSTANT_Utf8 object for the descriptor. * * @see CONSTANT_Utf8_info */ public int descriptor_index; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 5; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info) (constant_pool[name_index]); // CONSTANT_Utf8_info di = (CONSTANT_Utf8_info)(constant_pool[descriptor_index]); return ci.convert(); // + "/" + di.convert(); } /** * Returns a String description of what kind of entry this is. * * @return the String "nameandtype". * @see cp_info#typeName */ public String typeName() { return "nameandtype"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { int i; if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_NameAndType_info cu = (CONSTANT_NameAndType_info) cp; i = ((CONSTANT_Utf8_info) (constant_pool[name_index])).compareTo(cp_constant_pool[cu.name_index]); if (i != 0) { return i; } return ((CONSTANT_Utf8_info) (constant_pool[descriptor_index])).compareTo(cp_constant_pool[cu.descriptor_index]); } public Value createJimpleConstantValue(cp_info[] constant_pool) { throw new UnsupportedOperationException("cannot convert to Jimple: " + typeName()); } }
3,293
28.675676
117
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_String_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 soot.Value; import soot.jimple.StringConstant; /** * A constant pool entry of type CONSTANT_String. * * @see cp_info * @author Clark Verbrugge */ class CONSTANT_String_info extends cp_info { /** * Constant pool index of the CONSTANT_Utf8 object for the actual string. * * @see CONSTANT_Utf8_info */ public int string_index; /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return 3; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info) (constant_pool[string_index]); return "\"" + ci.convert() + "\""; } /** * Returns a String description of what kind of entry this is. * * @return the String "string". * @see cp_info#typeName */ public String typeName() { return "string"; } /** * 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. * @see cp_info#compareTo */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_String_info cu = (CONSTANT_String_info) cp; return ((CONSTANT_Utf8_info) (constant_pool[string_index])).compareTo(cp_constant_pool[cu.string_index]); } public Value createJimpleConstantValue(cp_info[] constant_pool) { CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info) (constant_pool[string_index]); return StringConstant.v(ci.convert()); } }
2,936
28.37
109
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Utf8_collector.java
package soot.coffi; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 2001 Michael Pan (pan@math.tau.ac.il) * %% * 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 soot.G; import soot.Singletons; /** * Provides sharing for Utf8_info string objects reused in different contexts. */ public class CONSTANT_Utf8_collector { public CONSTANT_Utf8_collector(Singletons.Global g) { } public static CONSTANT_Utf8_collector v() { return G.v().soot_coffi_CONSTANT_Utf8_collector(); } HashMap<String, CONSTANT_Utf8_info> hash = null; synchronized CONSTANT_Utf8_info add(CONSTANT_Utf8_info _Utf8_info) { if (hash == null) { hash = new HashMap<String, CONSTANT_Utf8_info>(); } String Utf8_str_key = _Utf8_info.convert(); if (hash.containsKey(Utf8_str_key)) { return hash.get(Utf8_str_key); } hash.put(Utf8_str_key, _Utf8_info); _Utf8_info.fixConversion(Utf8_str_key); return _Utf8_info; } }
1,655
27.551724
78
java
soot
soot-master/src/main/java/soot/coffi/CONSTANT_Utf8_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.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import soot.G; import soot.Value; import soot.jimple.StringConstant; /** * A constant pool entry of type CONSTANT_Utf8; note this is <b>not</b> multithread safe. It is, however, immutable. * * @see cp_info * @author Clark Verbrugge */ public class CONSTANT_Utf8_info extends cp_info { private static final Logger logger = LoggerFactory.getLogger(CONSTANT_Utf8_info.class); // Some local private objects to help with efficient comparisons. private int sHashCode; // for caching the conversion. private String s; /** Byte array of actual utf8 string. */ private final byte bytes[]; /** Constructor from a DataInputSream */ public CONSTANT_Utf8_info(DataInputStream d) throws IOException { int len; len = d.readUnsignedShort(); bytes = new byte[len + 2]; bytes[0] = (byte) (len >> 8); bytes[1] = (byte) (len & 0xff); if (len > 0) { int j; for (j = 0; j < len; j++) { bytes[j + 2] = (byte) d.readUnsignedByte(); } } } /** For writing out the byte stream for this utf8 properly (incl size). */ public void writeBytes(DataOutputStream dd) throws IOException { int len; len = bytes.length; dd.writeShort(len - 2); dd.write(bytes, 2, len - 2); } /** Length in bytes of byte array. */ public int length() { return (((((bytes[0])) & 0xff) << 8) + (((bytes[1])) & 0xff)); } /** * Returns the size of this cp_info object. * * @return number of bytes occupied by this object. * @see cp_info#size */ public int size() { return length() + 3; } /** * Converts internal representation into an actual String. * * @return String version of this utf8 object. */ public String convert() { if (s == null) { try { ByteArrayInputStream bs = new ByteArrayInputStream(bytes); DataInputStream d = new DataInputStream(bs); String buf = d.readUTF(); sHashCode = buf.hashCode(); return buf; } catch (IOException e) { return "!!IOException!!"; } } return s; } /** * Fixes the actual String used to represent the internal representation. We must have rep == convert(); we verify * hashCodes() to spot-check this. No user-visible effects. */ public void fixConversion(String rep) { if (sHashCode != rep.hashCode()) { throw new RuntimeException("bad use of fixConversion!"); } if (s == null) { s = rep; } } /** * Answers whether this utf8 string is the same as a given one. * * @param cu * utf8 object with which to compare. * @return <i>true</i> if they are equal, <i>false</i> if they are not. */ public boolean equals(CONSTANT_Utf8_info cu) { int i, j; j = bytes.length; if (j != cu.bytes.length) { return false; } for (i = 0; i < j; i++) { if (bytes[i] != cu.bytes[i]) { return false; } } return true; } /** * 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. * @see cp_info#compareTo * @see CONSTANT_Utf8_info#compareTo(cp_info) */ public int compareTo(cp_info constant_pool[], cp_info cp, cp_info cp_constant_pool[]) { return compareTo(cp); } /** * Compares this entry with another cp_info object; note that for Utf8 object it really doesn't matter whether they're in * the same or a different constant pool, since they really do carry all their data. * * @param cp * constant pool entry to compare against. * @return a value <0, 0, or >0 indicating whether this is smaller, the same or larger than cp. * @see cp_info#compareTo * @see CONSTANT_Utf8_info#compareTo(cp_info[],cp_info,cp_info[]) */ public int compareTo(cp_info cp) { if (tag != cp.tag) { return tag - cp.tag; } CONSTANT_Utf8_info cu = (CONSTANT_Utf8_info) cp; G.v().coffi_CONSTANT_Utf8_info_e1.reset(bytes); G.v().coffi_CONSTANT_Utf8_info_e2.reset(cu.bytes); for (; G.v().coffi_CONSTANT_Utf8_info_e1.hasMoreElements() && G.v().coffi_CONSTANT_Utf8_info_e2.hasMoreElements();) { G.v().coffi_CONSTANT_Utf8_info_e1.nextElement(); G.v().coffi_CONSTANT_Utf8_info_e2.nextElement(); if (G.v().coffi_CONSTANT_Utf8_info_e1.c < G.v().coffi_CONSTANT_Utf8_info_e2.c) { return -1; } if (G.v().coffi_CONSTANT_Utf8_info_e2.c < G.v().coffi_CONSTANT_Utf8_info_e1.c) { return 1; } } if (G.v().coffi_CONSTANT_Utf8_info_e1.hasMoreElements()) { return -1; } if (G.v().coffi_CONSTANT_Utf8_info_e2.hasMoreElements()) { return 1; } return 0; } /** * Utility method; converts the given String into a utf8 encoded array of bytes. * * @param s * String to encode. * @return array of bytes, utf8 encoded version of s. */ public static byte[] toUtf8(String s) { try { ByteArrayOutputStream bs = new ByteArrayOutputStream(s.length()); DataOutputStream d = new DataOutputStream(bs); d.writeUTF(s); return bs.toByteArray(); } catch (IOException e) { logger.debug("Some sort of IO exception in toUtf8 with " + s); } return null; } /** * Returns a String representation of this entry. * * @param constant_pool * constant pool of ClassFile. * @return String representation of this entry. * @see cp_info#toString */ public String toString(cp_info constant_pool[]) { return convert(); } /** * Returns a String description of what kind of entry this is. * * @return the String "utf8". * @see cp_info#typeName */ public String typeName() { return "utf8"; } public Value createJimpleConstantValue(cp_info[] constant_pool) { return StringConstant.v(convert()); } }
7,192
28.479508
123
java
soot
soot-master/src/main/java/soot/coffi/ClassFile.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.ByteArrayInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import soot.Timers; import soot.options.Options; /** * A ClassFile object represents the contents of a <tt>.class</tt> file. * <p> * A ClassFile contains code for manipulation of its constituents. * * @author Clark Verbrugge */ public class ClassFile { private static final Logger logger = LoggerFactory.getLogger(ClassFile.class); /** Magic number. */ static final long MAGIC = 0xCAFEBABEL; /** Access bit flag. */ static final short ACC_PUBLIC = 0x0001; /** Access bit flag. */ static final short ACC_PRIVATE = 0x0002; /** Access bit flag. */ static final short ACC_PROTECTED = 0x0004; /** Access bit flag. */ static final short ACC_STATIC = 0x0008; /** Access bit flag. */ static final short ACC_FINAL = 0x0010; /** Access bit flag. */ static final short ACC_SUPER = 0x0020; /** Access bit flag. */ static final short ACC_VOLATILE = 0x0040; /** Access bit flag. */ static final short ACC_TRANSIENT = 0x0080; /** Access bit flag. */ static final short ACC_INTERFACE = 0x0200; /** Access bit flag. */ static final short ACC_ABSTRACT = 0x0400; /** Access bit flag. */ static final short ACC_STRICT = 0x0800; /** Access bit flag. */ static final short ACC_ANNOTATION = 0x2000; /** Access bit flag. */ static final short ACC_ENUM = 0x4000; /** Remaining bits in the access bit flag. */ static final short ACC_UNKNOWN = 0x7000; /** Descriptor code string. */ static final String DESC_BYTE = "B"; /** Descriptor code string. */ static final String DESC_CHAR = "C"; /** Descriptor code string. */ static final String DESC_DOUBLE = "D"; /** Descriptor code string. */ static final String DESC_FLOAT = "F"; /** Descriptor code string. */ static final String DESC_INT = "I"; /** Descriptor code string. */ static final String DESC_LONG = "J"; /** Descriptor code string. */ static final String DESC_OBJECT = "L"; /** Descriptor code string. */ static final String DESC_SHORT = "S"; /** Descriptor code string. */ static final String DESC_BOOLEAN = "Z"; /** Descriptor code string. */ static final String DESC_VOID = "V"; /** Descriptor code string. */ static final String DESC_ARRAY = "["; /** Debugging flag. */ boolean debug; /** File name of the <tt>.class</tt> this represents. */ String fn; /* * For chaining ClassFiles into a list. ClassFile next; */ /** * Magic number read in. * * @see ClassFile#MAGIC */ long magic; /** Minor version. */ int minor_version; /** Major version. */ int major_version; /** Number of items in the constant pool. */ public int constant_pool_count; /** * Array of constant pool items. * * @see cp_info */ public cp_info constant_pool[]; /** * Access flags for this Class. */ public int access_flags; /** * Constant pool index of the Class constant describing <i>this</i>. * * @see CONSTANT_Class_info */ public int this_class; /** * Constant pool index of the Class constant describing <i>super</i>. * * @see CONSTANT_Class_info */ public int super_class; /** Count of interfaces implemented. */ public int interfaces_count; /** * Array of constant pool indices of Class constants describing each interace implemented by this class, as given in the * source for this class. * * @see CONSTANT_Class_info */ public int interfaces[]; /** Count of fields this Class contains. */ public int fields_count; /** * Array of field_info objects describing each field. * * @see field_info */ public field_info fields[]; /** Count of methods this Class contains. */ public int methods_count; /** * Array of method_info objects describing each field. * * @see method_info */ public method_info methods[]; /** Count of attributes this class contains. */ public int attributes_count; /** * Array of attribute_info objects for this class. * * @see attribute_info */ public attribute_info attributes[]; /** bootstrap-methods attribute (if any) */ public BootstrapMethods_attribute bootstrap_methods_attribute; /** * Creates a new ClassFile object given the name of the file. * * @param nfn * file name which this ClassFile will represent. */ public ClassFile(String nfn) { fn = nfn; } /** Returns the name of this Class. */ public String toString() { return (constant_pool[this_class].toString(constant_pool)); } public boolean loadClassFile(InputStream is) { InputStream f = null; InputStream classFileStream; DataInputStream d; boolean b; classFileStream = is; byte[] data; if (Options.v().time()) { Timers.v().readTimer.start(); } try { DataInputStream classDataStream = new DataInputStream(classFileStream); data = new byte[classDataStream.available()]; classDataStream.readFully(data); f = new ByteArrayInputStream(data); } catch (IOException e) { logger.debug(e.getMessage(), e); } if (Options.v().time()) { Timers.v().readTimer.end(); } d = new DataInputStream(f); b = readClass(d); try { classFileStream.close(); d.close(); if (f != null) { f.close(); } } catch (IOException e) { logger.debug("IOException with " + fn + ": " + e.getMessage()); return false; } if (!b) { return false; } // parse(); // parse all methods & builds CFGs // logger.debug("-- Read " + cf + " --"); return true; } /** * Main entry point for writing a class file. The file name is given in the constructor; this opens the file and writes the * internal representation. * * @return <i>true</i> on success. */ boolean saveClassFile() { FileOutputStream f; DataOutputStream d; boolean b; try { f = new FileOutputStream(fn); } catch (FileNotFoundException e) { if (fn.indexOf(".class") >= 0) { logger.debug("Can't find " + fn); return false; } fn = fn + ".class"; try { f = new FileOutputStream(fn); } catch (FileNotFoundException ee) { logger.debug("Can't find " + fn); return false; } } d = new DataOutputStream(f); b = writeClass(d); try { d.close(); f.close(); } catch (IOException e) { logger.debug("IOException with " + fn + ": " + e.getMessage()); return false; } return b; } /** * Returns a String constructed by parsing the bits in the given access code (as defined by the ACC_* constants). * * @param af * access code. * @param separator * String used to separate words used for access bits. * @see ClassFile#access_flags * @see method_info#access_flags * @see field_info#access_flags */ static String access_string(int af, String separator) { boolean hasone = false; String s = ""; if ((af & ACC_PUBLIC) != 0) { s = "public"; hasone = true; } if ((af & ACC_PRIVATE) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "private"; } if ((af & ACC_PROTECTED) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "protected"; } if ((af & ACC_STATIC) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "static"; } if ((af & ACC_FINAL) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "final"; } if ((af & ACC_SUPER) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "super"; } if ((af & ACC_VOLATILE) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "volatile"; } if ((af & ACC_TRANSIENT) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "transient"; } if ((af & ACC_INTERFACE) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "interface"; } if ((af & ACC_ABSTRACT) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "abstract"; } if ((af & ACC_STRICT) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "strict"; } if ((af & ACC_ANNOTATION) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "annotation"; } if ((af & ACC_ENUM) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "enum"; } if ((af & ACC_UNKNOWN) != 0) { if (hasone) { s = s + separator; } else { hasone = true; } s = s + "unknown"; } return s; } /** * Builds the internal representation of this Class by reading in the given class file. * * @param d * Stream forming the <tt>.class</tt> file. * @return <i>true</i> if read was successful, <i>false</i> on some error. */ public boolean readClass(DataInputStream d) { try { // first read in magic number magic = d.readInt() & 0xFFFFFFFFL; if (magic != MAGIC) { logger.debug("Wrong magic number in " + fn + ": " + magic); return false; } minor_version = d.readUnsignedShort(); major_version = d.readUnsignedShort(); constant_pool_count = d.readUnsignedShort(); if (!readConstantPool(d)) { return false; } access_flags = d.readUnsignedShort(); this_class = d.readUnsignedShort(); super_class = d.readUnsignedShort(); interfaces_count = d.readUnsignedShort(); if (interfaces_count > 0) { interfaces = new int[interfaces_count]; int j; for (j = 0; j < interfaces_count; j++) { interfaces[j] = d.readUnsignedShort(); } } if (Options.v().time()) { Timers.v().fieldTimer.start(); } fields_count = d.readUnsignedShort(); readFields(d); if (Options.v().time()) { Timers.v().fieldTimer.end(); } if (Options.v().time()) { Timers.v().methodTimer.start(); } methods_count = d.readUnsignedShort(); readMethods(d); if (Options.v().time()) { Timers.v().methodTimer.end(); } if (Options.v().time()) { Timers.v().attributeTimer.start(); } attributes_count = d.readUnsignedShort(); if (attributes_count > 0) { attributes = new attribute_info[attributes_count]; readAttributes(d, attributes_count, attributes); } if (Options.v().time()) { Timers.v().attributeTimer.end(); } } catch (IOException e) { throw new RuntimeException("IOException with " + fn + ": " + e.getMessage(), e); } return true; } /** * Reads in the constant pool from the given stream. * * @param d * Stream forming the <tt>.class</tt> file. * @return <i>true</i> if read was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean readConstantPool(DataInputStream d) throws IOException { byte tag; cp_info cp; int i; boolean skipone; // set if next cp entry is to be skipped constant_pool = new cp_info[constant_pool_count]; // Instruction.constant_pool = constant_pool; skipone = false; for (i = 1; i < constant_pool_count; i++) { if (skipone) { skipone = false; continue; } tag = (byte) d.readUnsignedByte(); switch (tag) { case cp_info.CONSTANT_Class: cp = new CONSTANT_Class_info(); ((CONSTANT_Class_info) cp).name_index = d.readUnsignedShort(); if (debug) { logger.debug("Constant pool[" + i + "]: Class"); } break; case cp_info.CONSTANT_Fieldref: cp = new CONSTANT_Fieldref_info(); ((CONSTANT_Fieldref_info) cp).class_index = d.readUnsignedShort(); ((CONSTANT_Fieldref_info) cp).name_and_type_index = d.readUnsignedShort(); if (debug) { logger.debug("Constant pool[" + i + "]: Fieldref"); } break; case cp_info.CONSTANT_Methodref: cp = new CONSTANT_Methodref_info(); ((CONSTANT_Methodref_info) cp).class_index = d.readUnsignedShort(); ((CONSTANT_Methodref_info) cp).name_and_type_index = d.readUnsignedShort(); if (debug) { logger.debug("Constant pool[" + i + "]: Methodref"); } break; case cp_info.CONSTANT_InterfaceMethodref: cp = new CONSTANT_InterfaceMethodref_info(); ((CONSTANT_InterfaceMethodref_info) cp).class_index = d.readUnsignedShort(); ((CONSTANT_InterfaceMethodref_info) cp).name_and_type_index = d.readUnsignedShort(); if (debug) { logger.debug("Constant pool[" + i + "]: MethodHandle"); } break; case cp_info.CONSTANT_String: cp = new CONSTANT_String_info(); ((CONSTANT_String_info) cp).string_index = d.readUnsignedShort(); if (debug) { logger.debug("Constant pool[" + i + "]: String"); } break; case cp_info.CONSTANT_Integer: cp = new CONSTANT_Integer_info(); ((CONSTANT_Integer_info) cp).bytes = d.readInt(); if (debug) { logger.debug("Constant pool[" + i + "]: Integer = " + ((CONSTANT_Integer_info) cp).bytes); } break; case cp_info.CONSTANT_Float: cp = new CONSTANT_Float_info(); ((CONSTANT_Float_info) cp).bytes = d.readInt(); if (debug) { logger.debug("Constant pool[" + i + "]: Float = " + ((CONSTANT_Float_info) cp).convert()); } break; case cp_info.CONSTANT_Long: cp = new CONSTANT_Long_info(); ((CONSTANT_Long_info) cp).high = d.readInt() & 0xFFFFFFFFL; ((CONSTANT_Long_info) cp).low = d.readInt() & 0xFFFFFFFFL; if (debug) { String temp = cp.toString(constant_pool); logger.debug("Constant pool[" + i + "]: Long = " + temp); /* * logger.debug("Constant pool[" + i + "]: that's " + cp.printBits(((CONSTANT_Long_info)cp).high) + " <<32 + " + * cp.printBits(((CONSTANT_Long_info)cp).low) + " = " + cp.printBits(((CONSTANT_Long_info)cp).convert())); */ } skipone = true; // next entry needs to be skipped break; case cp_info.CONSTANT_Double: cp = new CONSTANT_Double_info(); ((CONSTANT_Double_info) cp).high = d.readInt() & 0xFFFFFFFFL; ((CONSTANT_Double_info) cp).low = d.readInt() & 0xFFFFFFFFL; if (debug) { logger.debug("Constant pool[" + i + "]: Double = " + ((CONSTANT_Double_info) cp).convert()); } skipone = true; // next entry needs to be skipped break; case cp_info.CONSTANT_NameAndType: cp = new CONSTANT_NameAndType_info(); ((CONSTANT_NameAndType_info) cp).name_index = d.readUnsignedShort(); ((CONSTANT_NameAndType_info) cp).descriptor_index = d.readUnsignedShort(); if (debug) { logger.debug("Constant pool[" + i + "]: Name and Type"); } break; case cp_info.CONSTANT_Utf8: CONSTANT_Utf8_info cputf8 = new CONSTANT_Utf8_info(d); // If an equivalent CONSTANT_Utf8 already exists, we return // the pre-existing one and allow cputf8 to be GC'd. cp = (cp_info) CONSTANT_Utf8_collector.v().add(cputf8); if (debug) { logger.debug("Constant pool[" + i + "]: Utf8 = \"" + cputf8.convert() + "\""); } break; case cp_info.CONSTANT_MethodHandle: cp = new CONSTANT_MethodHandle_info(); ((CONSTANT_MethodHandle_info) cp).kind = d.readByte(); ((CONSTANT_MethodHandle_info) cp).target_index = d.readUnsignedShort(); break; case cp_info.CONSTANT_InvokeDynamic: cp = new CONSTANT_InvokeDynamic_info(); ((CONSTANT_InvokeDynamic_info) cp).bootstrap_method_index = d.readUnsignedShort(); ((CONSTANT_InvokeDynamic_info) cp).name_and_type_index = d.readUnsignedShort(); break; default: logger.debug("Unknown tag in constant pool: " + tag + " at entry " + i); return false; } cp.tag = tag; constant_pool[i] = cp; } return true; } private void readAllBytes(byte[] dest, DataInputStream d) throws IOException { int total_len = dest.length; int read_len = 0; while (read_len < total_len) { int to_read = total_len - read_len; int curr_read = d.read(dest, read_len, to_read); read_len += curr_read; } } /** * Reads in the given number of attributes from the given stream. * * @param d * Stream forming the <tt>.class</tt> file. * @param attributes_count * number of attributes to read in. * @param ai * pre-allocated array of attributes to be filled in. * @return <i>true</i> if read was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean readAttributes(DataInputStream d, int attributes_count, attribute_info[] ai) throws IOException { attribute_info a = null; int i; int j; long len; String s; for (i = 0; i < attributes_count; i++) { j = d.readUnsignedShort(); // read attribute name before allocating len = d.readInt() & 0xFFFFFFFFL; s = ((CONSTANT_Utf8_info) (constant_pool[j])).convert(); if (s.compareTo(attribute_info.SourceFile) == 0) { SourceFile_attribute sa = new SourceFile_attribute(); sa.sourcefile_index = d.readUnsignedShort(); a = (attribute_info) sa; } else if (s.compareTo(attribute_info.ConstantValue) == 0) { ConstantValue_attribute ca = new ConstantValue_attribute(); ca.constantvalue_index = d.readUnsignedShort(); a = (attribute_info) ca; } else if (s.compareTo(attribute_info.Code) == 0) { Code_attribute ca = new Code_attribute(); ca.max_stack = d.readUnsignedShort(); ca.max_locals = d.readUnsignedShort(); ca.code_length = d.readInt() & 0xFFFFFFFFL; ca.code = new byte[(int) ca.code_length]; readAllBytes(ca.code, d); ca.exception_table_length = d.readUnsignedShort(); ca.exception_table = new exception_table_entry[ca.exception_table_length]; int k; exception_table_entry e; for (k = 0; k < ca.exception_table_length; k++) { e = new exception_table_entry(); e.start_pc = d.readUnsignedShort(); e.end_pc = d.readUnsignedShort(); e.handler_pc = d.readUnsignedShort(); e.catch_type = d.readUnsignedShort(); ca.exception_table[k] = e; } ca.attributes_count = d.readUnsignedShort(); ca.attributes = new attribute_info[ca.attributes_count]; readAttributes(d, ca.attributes_count, ca.attributes); a = (attribute_info) ca; } else if (s.compareTo(attribute_info.Exceptions) == 0) { Exception_attribute ea = new Exception_attribute(); ea.number_of_exceptions = d.readUnsignedShort(); if (ea.number_of_exceptions > 0) { int k; ea.exception_index_table = new int[ea.number_of_exceptions]; for (k = 0; k < ea.number_of_exceptions; k++) { ea.exception_index_table[k] = d.readUnsignedShort(); } } a = (attribute_info) ea; } else if (s.compareTo(attribute_info.LineNumberTable) == 0) { LineNumberTable_attribute la = new LineNumberTable_attribute(); la.line_number_table_length = d.readUnsignedShort(); int k; line_number_table_entry e; la.line_number_table = new line_number_table_entry[la.line_number_table_length]; for (k = 0; k < la.line_number_table_length; k++) { e = new line_number_table_entry(); e.start_pc = d.readUnsignedShort(); e.line_number = d.readUnsignedShort(); la.line_number_table[k] = e; } a = (attribute_info) la; } else if (s.compareTo(attribute_info.LocalVariableTable) == 0) { LocalVariableTable_attribute la = new LocalVariableTable_attribute(); la.local_variable_table_length = d.readUnsignedShort(); int k; local_variable_table_entry e; la.local_variable_table = new local_variable_table_entry[la.local_variable_table_length]; for (k = 0; k < la.local_variable_table_length; k++) { e = new local_variable_table_entry(); e.start_pc = d.readUnsignedShort(); e.length = d.readUnsignedShort(); e.name_index = d.readUnsignedShort(); e.descriptor_index = d.readUnsignedShort(); e.index = d.readUnsignedShort(); la.local_variable_table[k] = e; } a = (attribute_info) la; } else if (s.compareTo(attribute_info.LocalVariableTypeTable) == 0) { LocalVariableTypeTable_attribute la = new LocalVariableTypeTable_attribute(); la.local_variable_type_table_length = d.readUnsignedShort(); int k; local_variable_type_table_entry e; la.local_variable_type_table = new local_variable_type_table_entry[la.local_variable_type_table_length]; for (k = 0; k < la.local_variable_type_table_length; k++) { e = new local_variable_type_table_entry(); e.start_pc = d.readUnsignedShort(); e.length = d.readUnsignedShort(); e.name_index = d.readUnsignedShort(); e.signature_index = d.readUnsignedShort(); e.index = d.readUnsignedShort(); la.local_variable_type_table[k] = e; } a = (attribute_info) la; } else if (s.compareTo(attribute_info.Synthetic) == 0) { Synthetic_attribute ia = new Synthetic_attribute(); a = (attribute_info) ia; } else if (s.compareTo(attribute_info.Signature) == 0) { Signature_attribute ia = new Signature_attribute(); ia.signature_index = d.readUnsignedShort(); a = (attribute_info) ia; } else if (s.compareTo(attribute_info.Deprecated) == 0) { Deprecated_attribute da = new Deprecated_attribute(); a = (attribute_info) da; } else if (s.compareTo(attribute_info.EnclosingMethod) == 0) { EnclosingMethod_attribute ea = new EnclosingMethod_attribute(); ea.class_index = d.readUnsignedShort(); ea.method_index = d.readUnsignedShort(); a = (attribute_info) ea; } else if (s.compareTo(attribute_info.InnerClasses) == 0) { InnerClasses_attribute ia = new InnerClasses_attribute(); ia.inner_classes_length = d.readUnsignedShort(); ia.inner_classes = new inner_class_entry[ia.inner_classes_length]; for (int k = 0; k < ia.inner_classes_length; k++) { inner_class_entry e = new inner_class_entry(); e.inner_class_index = d.readUnsignedShort(); e.outer_class_index = d.readUnsignedShort(); e.name_index = d.readUnsignedShort(); e.access_flags = d.readUnsignedShort(); ia.inner_classes[k] = e; } a = (attribute_info) ia; } else if (s.compareTo(attribute_info.RuntimeVisibleAnnotations) == 0) { RuntimeVisibleAnnotations_attribute ra = new RuntimeVisibleAnnotations_attribute(); ra.number_of_annotations = d.readUnsignedShort(); ra.annotations = new annotation[ra.number_of_annotations]; for (int k = 0; k < ra.number_of_annotations; k++) { annotation annot = new annotation(); annot.type_index = d.readUnsignedShort(); annot.num_element_value_pairs = d.readUnsignedShort(); annot.element_value_pairs = readElementValues(annot.num_element_value_pairs, d, true, 0); ra.annotations[k] = annot; } a = (attribute_info) ra; } else if (s.compareTo(attribute_info.RuntimeInvisibleAnnotations) == 0) { RuntimeInvisibleAnnotations_attribute ra = new RuntimeInvisibleAnnotations_attribute(); ra.number_of_annotations = d.readUnsignedShort(); ra.annotations = new annotation[ra.number_of_annotations]; for (int k = 0; k < ra.number_of_annotations; k++) { annotation annot = new annotation(); annot.type_index = d.readUnsignedShort(); annot.num_element_value_pairs = d.readUnsignedShort(); annot.element_value_pairs = readElementValues(annot.num_element_value_pairs, d, true, 0); ra.annotations[k] = annot; } a = (attribute_info) ra; } else if (s.compareTo(attribute_info.RuntimeVisibleParameterAnnotations) == 0) { RuntimeVisibleParameterAnnotations_attribute ra = new RuntimeVisibleParameterAnnotations_attribute(); ra.num_parameters = d.readUnsignedByte(); ra.parameter_annotations = new parameter_annotation[ra.num_parameters]; for (int x = 0; x < ra.num_parameters; x++) { parameter_annotation pAnnot = new parameter_annotation(); pAnnot.num_annotations = d.readUnsignedShort(); pAnnot.annotations = new annotation[pAnnot.num_annotations]; for (int k = 0; k < pAnnot.num_annotations; k++) { annotation annot = new annotation(); annot.type_index = d.readUnsignedShort(); annot.num_element_value_pairs = d.readUnsignedShort(); annot.element_value_pairs = readElementValues(annot.num_element_value_pairs, d, true, 0); pAnnot.annotations[k] = annot; } ra.parameter_annotations[x] = pAnnot; } a = (attribute_info) ra; } else if (s.compareTo(attribute_info.RuntimeInvisibleParameterAnnotations) == 0) { RuntimeInvisibleParameterAnnotations_attribute ra = new RuntimeInvisibleParameterAnnotations_attribute(); ra.num_parameters = d.readUnsignedByte(); ra.parameter_annotations = new parameter_annotation[ra.num_parameters]; for (int x = 0; x < ra.num_parameters; x++) { parameter_annotation pAnnot = new parameter_annotation(); pAnnot.num_annotations = d.readUnsignedShort(); pAnnot.annotations = new annotation[pAnnot.num_annotations]; for (int k = 0; k < pAnnot.num_annotations; k++) { annotation annot = new annotation(); annot.type_index = d.readUnsignedShort(); annot.num_element_value_pairs = d.readUnsignedShort(); annot.element_value_pairs = readElementValues(annot.num_element_value_pairs, d, true, 0); pAnnot.annotations[k] = annot; } ra.parameter_annotations[x] = pAnnot; } a = (attribute_info) ra; } else if (s.compareTo(attribute_info.AnnotationDefault) == 0) { AnnotationDefault_attribute da = new AnnotationDefault_attribute(); element_value[] result = readElementValues(1, d, false, 0); da.default_value = result[0]; a = (attribute_info) da; } else if (s.equals(attribute_info.BootstrapMethods)) { BootstrapMethods_attribute bsma = new BootstrapMethods_attribute(); int count = d.readUnsignedShort(); bsma.method_handles = new short[count]; bsma.arg_indices = new short[count][]; for (int num = 0; num < count; num++) { short index = (short) d.readUnsignedShort(); bsma.method_handles[num] = index; int argCount = d.readUnsignedShort(); bsma.arg_indices[num] = new short[argCount]; for (int numArg = 0; numArg < argCount; numArg++) { short indexArg = (short) d.readUnsignedShort(); bsma.arg_indices[num][numArg] = indexArg; } } assert bootstrap_methods_attribute == null : "More than one bootstrap methods attribute!"; a = bootstrap_methods_attribute = bsma; } else { // unknown attribute // logger.debug("Generic/Unknown Attribute: " + s); Generic_attribute ga = new Generic_attribute(); if (len > 0) { ga.info = new byte[(int) len]; readAllBytes(ga.info, d); } a = (attribute_info) ga; } a.attribute_name = j; a.attribute_length = len; ai[i] = a; } return true; } private element_value[] readElementValues(int count, DataInputStream d, boolean needName, int name_index) throws IOException { element_value[] list = new element_value[count]; for (int x = 0; x < count; x++) { if (needName) { name_index = d.readUnsignedShort(); } int tag = d.readUnsignedByte(); char kind = (char) tag; if (kind == 'B' || kind == 'C' || kind == 'D' || kind == 'F' || kind == 'I' || kind == 'J' || kind == 'S' || kind == 'Z' || kind == 's') { constant_element_value elem = new constant_element_value(); elem.name_index = name_index; elem.tag = kind; elem.constant_value_index = d.readUnsignedShort(); list[x] = elem; } else if (kind == 'e') { enum_constant_element_value elem = new enum_constant_element_value(); elem.name_index = name_index; elem.tag = kind; elem.type_name_index = d.readUnsignedShort(); elem.constant_name_index = d.readUnsignedShort(); list[x] = elem; } else if (kind == 'c') { class_element_value elem = new class_element_value(); elem.name_index = name_index; elem.tag = kind; elem.class_info_index = d.readUnsignedShort(); list[x] = elem; } else if (kind == '[') { array_element_value elem = new array_element_value(); elem.name_index = name_index; elem.tag = kind; elem.num_values = d.readUnsignedShort(); elem.values = readElementValues(elem.num_values, d, false, name_index); list[x] = elem; } else if (kind == '@') { annotation_element_value elem = new annotation_element_value(); elem.name_index = name_index; elem.tag = kind; annotation annot = new annotation(); annot.type_index = d.readUnsignedShort(); annot.num_element_value_pairs = d.readUnsignedShort(); annot.element_value_pairs = readElementValues(annot.num_element_value_pairs, d, true, 0); elem.annotation_value = annot; list[x] = elem; } else { throw new RuntimeException("Unknown element value pair kind: " + kind); } } return list; } /** * Reads in the fields from the given stream. * * @param d * Stream forming the <tt>.class</tt> file. * @return <i>true</i> if read was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean readFields(DataInputStream d) throws IOException { field_info fi; int i; fields = new field_info[fields_count]; for (i = 0; i < fields_count; i++) { fi = new field_info(); fi.access_flags = d.readUnsignedShort(); fi.name_index = d.readUnsignedShort(); fi.descriptor_index = d.readUnsignedShort(); fi.attributes_count = d.readUnsignedShort(); if (fi.attributes_count > 0) { fi.attributes = new attribute_info[fi.attributes_count]; readAttributes(d, fi.attributes_count, fi.attributes); } /* * CONSTANT_Utf8_info ci; ci = (CONSTANT_Utf8_info)(constant_pool[fi.name_index]); logger.debug("Field: " + * ci.convert()); */ fields[i] = fi; } return true; } /** * Reads in the methods from the given stream. * * @param d * Stream forming the <tt>.class</tt> file. * @return <i>true</i> if read was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean readMethods(DataInputStream d) throws IOException { method_info mi; int i; methods = new method_info[methods_count]; for (i = 0; i < methods_count; i++) { mi = new method_info(); mi.access_flags = d.readUnsignedShort(); mi.name_index = d.readUnsignedShort(); mi.descriptor_index = d.readUnsignedShort(); mi.attributes_count = d.readUnsignedShort(); // logger.debug("Has " + mi.attributes_count + " attribute(s)"); if (mi.attributes_count > 0) { mi.attributes = new attribute_info[mi.attributes_count]; readAttributes(d, mi.attributes_count, mi.attributes); for (int j = 0; j < mi.attributes_count; j++) { if (mi.attributes[j] instanceof Code_attribute) { mi.code_attr = (Code_attribute) mi.attributes[j]; break; } } } /* * if ("main".compareTo(ci.convert())==0) { decompile(mi); } */ methods[i] = mi; } return true; } /* * DEPRECATED public void showByteCode(Code_attribute ca) { int i=0,j; * * logger.debug("Code bytes follow..."); while(i<ca.code_length) { j = (int)(ca.code[i]); j &= 0xff; * logger.debug(""+Integer.toString(j) + " "); i++; } logger.debug(""); } */ /** * Writes the current constant pool to the given stream. * * @param dd * output stream. * @return <i>true</i> if write was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean writeConstantPool(DataOutputStream dd) throws IOException { cp_info cp; int i; boolean skipone = false; for (i = 1; i < constant_pool_count; i++) { if (skipone) { skipone = false; continue; } cp = constant_pool[i]; dd.writeByte(cp.tag); switch (cp.tag) { case cp_info.CONSTANT_Class: dd.writeShort(((CONSTANT_Class_info) cp).name_index); break; case cp_info.CONSTANT_Fieldref: dd.writeShort(((CONSTANT_Fieldref_info) cp).class_index); dd.writeShort(((CONSTANT_Fieldref_info) cp).name_and_type_index); break; case cp_info.CONSTANT_Methodref: dd.writeShort(((CONSTANT_Methodref_info) cp).class_index); dd.writeShort(((CONSTANT_Methodref_info) cp).name_and_type_index); break; case cp_info.CONSTANT_InterfaceMethodref: dd.writeShort(((CONSTANT_InterfaceMethodref_info) cp).class_index); dd.writeShort(((CONSTANT_InterfaceMethodref_info) cp).name_and_type_index); break; case cp_info.CONSTANT_String: dd.writeShort(((CONSTANT_String_info) cp).string_index); break; case cp_info.CONSTANT_Integer: dd.writeInt((int) ((CONSTANT_Integer_info) cp).bytes); break; case cp_info.CONSTANT_Float: dd.writeInt((int) ((CONSTANT_Float_info) cp).bytes); break; case cp_info.CONSTANT_Long: dd.writeInt((int) ((CONSTANT_Long_info) cp).high); dd.writeInt((int) ((CONSTANT_Long_info) cp).low); skipone = true; break; case cp_info.CONSTANT_Double: dd.writeInt((int) ((CONSTANT_Double_info) cp).high); dd.writeInt((int) ((CONSTANT_Double_info) cp).low); skipone = true; break; case cp_info.CONSTANT_NameAndType: dd.writeShort(((CONSTANT_NameAndType_info) cp).name_index); dd.writeShort(((CONSTANT_NameAndType_info) cp).descriptor_index); break; case cp_info.CONSTANT_Utf8: ((CONSTANT_Utf8_info) cp).writeBytes(dd); break; default: logger.debug("Unknown tag in constant pool: " + cp.tag); return false; } } return true; } /** * Writes the given array of attributes to the given stream. * * @param dd * output stream. * @param attributes_count * number of attributes to write. * @param ai * array of attributes to write. * @return <i>true</i> if write was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean writeAttributes(DataOutputStream dd, int attributes_count, attribute_info[] ai) throws IOException { attribute_info a = null; int i; for (i = 0; i < attributes_count; i++) { a = ai[i]; dd.writeShort(a.attribute_name); dd.writeInt((int) a.attribute_length); if (a instanceof SourceFile_attribute) { SourceFile_attribute sa = (SourceFile_attribute) a; dd.writeShort(sa.sourcefile_index); } else if (a instanceof ConstantValue_attribute) { ConstantValue_attribute ca = (ConstantValue_attribute) a; dd.writeShort(ca.constantvalue_index); } else if (a instanceof Code_attribute) { Code_attribute ca = (Code_attribute) a; dd.writeShort(ca.max_stack); dd.writeShort(ca.max_locals); dd.writeInt((int) ca.code_length); dd.write(ca.code, 0, (int) ca.code_length); dd.writeShort(ca.exception_table_length); int k; exception_table_entry e; for (k = 0; k < ca.exception_table_length; k++) { e = ca.exception_table[k]; dd.writeShort(e.start_pc); dd.writeShort(e.end_pc); dd.writeShort(e.handler_pc); dd.writeShort(e.catch_type); } dd.writeShort(ca.attributes_count); if (ca.attributes_count > 0) { writeAttributes(dd, ca.attributes_count, ca.attributes); } } else if (a instanceof Exception_attribute) { Exception_attribute ea = (Exception_attribute) a; dd.writeShort(ea.number_of_exceptions); if (ea.number_of_exceptions > 0) { int k; for (k = 0; k < ea.number_of_exceptions; k++) { dd.writeShort(ea.exception_index_table[k]); } } } else if (a instanceof LineNumberTable_attribute) { LineNumberTable_attribute la = (LineNumberTable_attribute) a; dd.writeShort(la.line_number_table_length); int k; line_number_table_entry e; for (k = 0; k < la.line_number_table_length; k++) { e = la.line_number_table[k]; dd.writeShort(e.start_pc); dd.writeShort(e.line_number); } } else if (a instanceof LocalVariableTable_attribute) { LocalVariableTable_attribute la = (LocalVariableTable_attribute) a; dd.writeShort(la.local_variable_table_length); int k; local_variable_table_entry e; for (k = 0; k < la.local_variable_table_length; k++) { e = la.local_variable_table[k]; dd.writeShort(e.start_pc); dd.writeShort(e.length); dd.writeShort(e.name_index); dd.writeShort(e.descriptor_index); dd.writeShort(e.index); } } else { // unknown attribute logger.debug("Generic/Unknown Attribute in output"); Generic_attribute ga = (Generic_attribute) a; if (ga.attribute_length > 0) { dd.write(ga.info, 0, (int) ga.attribute_length); } } } return true; } /** * Writes the fields to the given stream. * * @param dd * output stream. * @return <i>true</i> if write was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean writeFields(DataOutputStream dd) throws IOException { field_info fi; int i; for (i = 0; i < fields_count; i++) { fi = fields[i]; dd.writeShort(fi.access_flags); dd.writeShort(fi.name_index); dd.writeShort(fi.descriptor_index); dd.writeShort(fi.attributes_count); if (fi.attributes_count > 0) { writeAttributes(dd, fi.attributes_count, fi.attributes); } } return true; } /** * Writes the methods to the given stream. * * @param dd * output stream. * @return <i>true</i> if write was successful, <i>false</i> on some error. * @exception java.io.IOException * on error. */ protected boolean writeMethods(DataOutputStream dd) throws IOException { method_info mi; int i; for (i = 0; i < methods_count; i++) { mi = methods[i]; dd.writeShort(mi.access_flags); dd.writeShort(mi.name_index); dd.writeShort(mi.descriptor_index); dd.writeShort(mi.attributes_count); if (mi.attributes_count > 0) { writeAttributes(dd, mi.attributes_count, mi.attributes); } } return true; } /** * Writes this entire ClassFile object to the given stream. * * @param dd * output stream. * @return <i>true</i> if write was successful, <i>false</i> on some error. */ boolean writeClass(DataOutputStream dd) { // outputs the .class file from the loaded one try { // first write magic number dd.writeInt((int) magic); dd.writeShort(minor_version); dd.writeShort(major_version); dd.writeShort(constant_pool_count); if (!writeConstantPool(dd)) { return false; } dd.writeShort(access_flags); dd.writeShort(this_class); dd.writeShort(super_class); dd.writeShort(interfaces_count); if (interfaces_count > 0) { int j; for (j = 0; j < interfaces_count; j++) { dd.writeShort(interfaces[j]); } } dd.writeShort(fields_count); writeFields(dd); dd.writeShort(methods_count); writeMethods(dd); dd.writeShort(attributes_count); if (attributes_count > 0) { writeAttributes(dd, attributes_count, attributes); } } catch (IOException e) { logger.debug("IOException with " + fn + ": " + e.getMessage()); return false; } return true; } /** * Parses the given method, converting its bytecode array into a list of Instruction objects. * * @param m * method to parse. * @return head of a list of Instructions. * @see Instruction * @see ByteCode * @see ByteCode#disassemble_bytecode */ public Instruction parseMethod(method_info m) { // first task, look through attributes for a code attribute int j; Code_attribute ca; ByteCode bc; Instruction inst, head, tail; exception_table_entry e; head = null; tail = null; bc = new ByteCode(); ca = m.locate_code_attribute(); if (ca == null) { return null; } j = 0; while (j < ca.code_length) { inst = bc.disassemble_bytecode(ca.code, j); inst.originalIndex = j; // logger.debug(""+inst + ": " + (((int)(inst.code))&0xff)); // logger.debug(""+j + " : " + inst); if (inst instanceof Instruction_Unknown) { logger.debug("Unknown instruction in \"" + m.toName(constant_pool) + "\" at offset " + j); logger.debug(" bytecode = " + (((int) (inst.code)) & 0xff)); } // logger.debug("before: " + j); j = inst.nextOffset(j); // logger.debug("after: " + j); if (head == null) { head = inst; } else { tail.next = inst; inst.prev = tail; } tail = inst; } // bytecode converted into instructions, now build pointers bc.build(head); // also change exception table to use pointers instead of absolute addresses for (j = 0; j < ca.exception_table_length; j++) { e = ca.exception_table[j]; e.start_inst = bc.locateInst(e.start_pc); if (e.end_pc == ca.code_length) { e.end_inst = null; } else { e.end_inst = bc.locateInst(e.end_pc); } e.handler_inst = bc.locateInst(e.handler_pc); if (e.handler_inst != null) { e.handler_inst.labelled = true; } } m.instructions = head; for (attribute_info element : ca.attributes) { if (element instanceof LineNumberTable_attribute) { LineNumberTable_attribute lntattr = (LineNumberTable_attribute) element; for (line_number_table_entry element0 : lntattr.line_number_table) { element0.start_inst = bc.locateInst(element0.start_pc); } } } return head; } /** * For every method, this calls parseMethod, storing the list of Instructions in the method_info object, and also * constructs the corresponding CFG. * * @see ClassFile#parseMethod * @see CFG */ public void parse() { method_info mi; int i; for (i = 0; i < methods_count; i++) { mi = methods[i]; mi.instructions = parseMethod(mi); // new CFG(mi); // don't build it right away for now } } /** * Recomputes the offset of each Instruction starting from 0; used when converting references back to offsets. * * @param i * list of Instructions to process. * @return length of corresponding bytecode. * @see Instruction#nextOffset */ int relabel(Instruction i) { int index = 0; while (i != null) { i.label = index; index = i.nextOffset(index); i = i.next; } return index; } /** * Inversive to parseMethod, this converts the list of Instructions stored in a method_info object back to an array of * bytecode. * * @param m * method to unparse. * @return array of bytecode, or <i>null</i> on error. * @see CFG#reconstructInstructions * @see ClassFile#parseMethod * @see ClassFile#relabel * @see Instruction#compile */ byte[] unparseMethod(method_info m) { int codesize; byte bc[]; Instruction i; // Rebuild instruction sequence m.cfg.reconstructInstructions(); // relabel instructions and get size of code array codesize = relabel(m.instructions); // construct a new array for the byte-code bc = new byte[codesize]; // then recompile the instructions into byte-code i = m.instructions; codesize = 0; while (i != null) { codesize = i.compile(bc, codesize); i = i.next; } if (codesize != bc.length) { logger.warn("code size doesn't match array length!"); } return bc; } /** * Inversive to parse, this method calls unparseMethod for each method, storing the resulting bytecode in the method's code * attribute, and recomputing offsets for exception handlers. * * @see ClassFile#unparseMethod */ void unparse() { int i, j; Code_attribute ca; byte bc[]; method_info mi; exception_table_entry e; for (i = 0; i < methods_count; i++) { mi = methods[i]; // locate code attribute ca = mi.locate_code_attribute(); if (ca == null) { continue; } bc = unparseMethod(mi); if (bc == null) { logger.debug("Recompile of " + mi.toName(constant_pool) + " failed!"); } else { ca.code_length = bc.length; ca.code = bc; // also recompile exception table for (j = 0; j < ca.exception_table_length; j++) { e = ca.exception_table[j]; e.start_pc = (e.start_inst.label); if (e.end_inst != null) { e.end_pc = (e.end_inst.label); } else { e.end_pc = (int) (ca.code_length); } e.handler_pc = (e.handler_inst.label); } } } } /** * Static utility method to parse the given method descriptor string. * * @param s * descriptor string. * @return return type of method. * @see ClassFile#parseDesc * @see ClassFile#parseMethodDesc_params */ static String parseMethodDesc_return(String s) { int j; j = s.lastIndexOf(')'); if (j >= 0) { return parseDesc(s.substring(j + 1), ","); } return parseDesc(s, ","); } /** * Static utility method to parse the given method descriptor string. * * @param s * descriptor string. * @return comma-separated ordered list of parameter types * @see ClassFile#parseDesc * @see ClassFile#parseMethodDesc_return */ static String parseMethodDesc_params(String s) { int i, j; i = s.indexOf('('); if (i >= 0) { j = s.indexOf(')', i + 1); if (j >= 0) { return parseDesc(s.substring(i + 1, j), ","); } } return "<parse error>"; } /** * Static utility method to parse the given method descriptor string. * * @param desc * descriptor string. * @param sep * String to use as a separator between types. * @return String of types parsed. * @see ClassFile#parseDesc * @see ClassFile#parseMethodDesc_return */ static String parseDesc(String desc, String sep) { String params = "", param; char c; int i, len, arraylevel = 0; boolean didone = false; len = desc.length(); for (i = 0; i < len; i++) { c = desc.charAt(i); if (c == DESC_BYTE.charAt(0)) { param = "byte"; } else if (c == DESC_CHAR.charAt(0)) { param = "char"; } else if (c == DESC_DOUBLE.charAt(0)) { param = "double"; } else if (c == DESC_FLOAT.charAt(0)) { param = "float"; } else if (c == DESC_INT.charAt(0)) { param = "int"; } else if (c == DESC_LONG.charAt(0)) { param = "long"; } else if (c == DESC_SHORT.charAt(0)) { param = "short"; } else if (c == DESC_BOOLEAN.charAt(0)) { param = "boolean"; } else if (c == DESC_VOID.charAt(0)) { param = "void"; } else if (c == DESC_ARRAY.charAt(0)) { arraylevel++; continue; } else if (c == DESC_OBJECT.charAt(0)) { int j; j = desc.indexOf(';', i + 1); if (j < 0) { logger.warn("Parse error -- can't find a ; in " + desc.substring(i + 1)); param = "<error>"; } else { if (j - i > 10 && desc.substring(i + 1, i + 11).compareTo("java/lang/") == 0) { i = i + 10; } param = desc.substring(i + 1, j); // replace '/'s with '.'s param = param.replace('/', '.'); i = j; } } else { param = "???"; } if (didone) { params = params + sep; } params = params + param; while (arraylevel > 0) { params = params + "[]"; arraylevel--; } didone = true; } return params; } /** * Locates a method by name. * * @param s * name of method. * @return method_info object representing method, or <i>null</i> if not found. * @see method_info#toName */ method_info findMethod(String s) { method_info m; int i; for (i = 0; i < methods_count; i++) { m = methods[i]; if (s.equals(m.toName(constant_pool))) { return m; } } return null; } /** * Displays a the prototypes for all the methods defined in this ClassFile. * * @see ClassFile#methods * @see ClassFile#methods_count * @see method_info#prototype */ void listMethods() { int i; for (i = 0; i < methods_count; i++) { logger.debug("" + methods[i].prototype(constant_pool)); } } /** * Displays the entire constant pool. * * @see ClassFile#constant_pool * @see ClassFile#constant_pool_count * @see cp_info#toString */ void listConstantPool() { cp_info c; int i; // note that we start at 1 in the constant pool for (i = 1; i < constant_pool_count; i++) { c = constant_pool[i]; logger.debug("[" + i + "] " + c.typeName() + "=" + c.toString(constant_pool)); if ((constant_pool[i]).tag == cp_info.CONSTANT_Long || (constant_pool[i]).tag == cp_info.CONSTANT_Double) { // must skip an entry after a long or double constant i++; } } } /** * Displays the list of fields defined in this ClassFile, including any static initializers (constants). * * @see ClassFile#fields * @see ClassFile#fields_count * @see field_info#prototype * @see ConstantValue_attribute */ void listFields() { field_info fi; ConstantValue_attribute cva; CONSTANT_Utf8_info cm; int i, j; for (i = 0; i < fields_count; i++) { fi = fields[i]; logger.debug("" + fi.prototype(constant_pool)); // see if has a constant value attribute for (j = 0; j < fi.attributes_count; j++) { cm = (CONSTANT_Utf8_info) (constant_pool[fi.attributes[j].attribute_name]); if (cm.convert().compareTo(attribute_info.ConstantValue) == 0) { cva = (ConstantValue_attribute) (fi.attributes[j]); // dm = (CONSTANT_Utf8_info)(constant_pool[cva.constantvalue_index]); logger.debug(" = " + constant_pool[cva.constantvalue_index].toString(constant_pool)); break; } } logger.debug(";"); } } /** * Moves a method to a different index in the methods array. * * @param m * name of method to move. * @param pos * desired index. * @see ClassFile#methods */ void moveMethod(String m, int pos) { int i, j; method_info mthd; logger.debug("Moving " + m + " to position " + pos + " of " + methods_count); for (i = 0; i < methods_count; i++) { if (m.compareTo(methods[i].toName(constant_pool)) == 0) { mthd = methods[i]; if (i > pos) { for (j = i; j > pos && j > 0; j--) { methods[j] = methods[j - 1]; } methods[pos] = mthd; } else if (i < pos) { for (j = i; j < pos && j < methods_count - 1; j++) { methods[j] = methods[j + 1]; } methods[pos] = mthd; } return; } } } /** * Answers whether this class is an immediate descendant (as subclass or as an implementation of an interface) of the given * class. * * @param cf * ClassFile of supposed parent. * @return <i>true</i> if it is a parent, <i>false</i> otherwise. * @see ClassFile#descendsFrom(String) */ boolean descendsFrom(ClassFile cf) { return descendsFrom(cf.toString()); } /** * Answers whether this class is an immediate descendant (as subclass or as an implementation of an interface) of the given * class. * * @param cname * name of supposed parent. * @return <i>true</i> if it is a parent, <i>false</i> otherwise. * @see ClassFile#descendsFrom(ClassFile) */ boolean descendsFrom(String cname) { cp_info cf; int i; cf = constant_pool[super_class]; if (cf.toString(constant_pool).compareTo(cname) == 0) { return true; } for (i = 0; i < interfaces_count; i++) { cf = constant_pool[interfaces[i]]; if (cf.toString(constant_pool).compareTo(cname) == 0) { return true; } } return false; } /** * Answers whether this class can have subclasses outside its package. * * @return <i>true</i> if it cannot, <i>false</i> if it might. */ boolean isSterile() { if ((access_flags & ACC_PUBLIC) != 0 && (access_flags & ACC_FINAL) == 0) { return false; } return true; } /** * Given the name of a class --- possibly with <tt>.class</tt> after it, this answers whether the class might refer to this * ClassFile object. * * @return <i>true</i> if it does, <i>false</i> if it doesn't. */ boolean sameClass(String cfn) { String s = cfn; int i = s.lastIndexOf(".class"); if (i > 0) { // has .class after it s = s.substring(0, i); // cut off the .class } if (s.compareTo(toString()) == 0) { return true; } return false; } /** * Returns the name of a specific field in the field array. * * @param i * index of field in field array. * @return name of field. */ String fieldName(int i) { return fields[i].toName(constant_pool); } /* * DEPRECATED // Locates the given classfile, and extracts it from the list. // It cannot be the first one in the list, and * this returns null // or the classfile. static ClassFile removeClassFile(ClassFile cfhead,String cfn) { ClassFile * cf,cfprev; cf = cfhead; cfprev = null; while (cf!=null) { if (cf.sameClass(cfn)) { if (cfprev==null) return null; // * this shouldn't happen cfprev.next = cf.next; cf.next = null; return cf; } cfprev = cf; cf = cf.next; } return null; } * * // returns true if this class contains any references to the given // cuClass.cuName, which is of type cuDesc. Searches * for methods if // ismethod is true, fields otherwise. boolean refersTo(boolean ismethod,CONSTANT_Utf8_info cuClass, * CONSTANT_Utf8_info cuName,CONSTANT_Utf8_info cuDesc) { int i; CONSTANT_Utf8_info cu; // note that we start at 1 in the * constant pool if (ismethod) { for (i=1;i<constant_pool_count;i++) { if * ((constant_pool[i]).tag==cp_info.CONSTANT_Methodref) { CONSTANT_Methodref_info cf = * (CONSTANT_Methodref_info)(constant_pool[i]); CONSTANT_Class_info cc = (CONSTANT_Class_info) * (constant_pool[cf.class_index]); if (cuClass.equals((CONSTANT_Utf8_info) (constant_pool[cc.name_index]))) { * CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[cf.name_and_type_index]); if * (cuName.equals((CONSTANT_Utf8_info) (constant_pool[cn.name_index])) && cuDesc.equals((CONSTANT_Utf8_info) * (constant_pool[cn.descriptor_index]))) return true; } } else if ((constant_pool[i]).tag== * cp_info.CONSTANT_InterfaceMethodref) { CONSTANT_InterfaceMethodref_info cf = * (CONSTANT_InterfaceMethodref_info)(constant_pool[i]); CONSTANT_Class_info cc = (CONSTANT_Class_info) * (constant_pool[cf.class_index]); if (cuClass.equals((CONSTANT_Utf8_info) (constant_pool[cc.name_index]))) { * CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[cf.name_and_type_index]); if * (cuName.equals((CONSTANT_Utf8_info) (constant_pool[cn.name_index])) && cuDesc.equals((CONSTANT_Utf8_info) * (constant_pool[cn.descriptor_index]))) return true; } } else if ((constant_pool[i]).tag==cp_info.CONSTANT_Long || * (constant_pool[i]).tag==cp_info.CONSTANT_Double) { // must skip an entry after a long or double constant i++; } } } else * { for (i=1;i<constant_pool_count;i++) { if ((constant_pool[i]).tag==cp_info.CONSTANT_Fieldref) { CONSTANT_Fieldref_info * cf = (CONSTANT_Fieldref_info)(constant_pool[i]); CONSTANT_Class_info cc = (CONSTANT_Class_info) * (constant_pool[cf.class_index]); if (cuClass.equals((CONSTANT_Utf8_info) (constant_pool[cc.name_index]))) { * CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[cf.name_and_type_index]); if * (cuName.equals((CONSTANT_Utf8_info) (constant_pool[cn.name_index])) && cuDesc.equals((CONSTANT_Utf8_info) * (constant_pool[cn.descriptor_index]))) return true; } } else if ((constant_pool[i]).tag==cp_info.CONSTANT_Long || * (constant_pool[i]).tag==cp_info.CONSTANT_Double) { // must skip an entry after a long or double constant i++; } } } * return false; } * * // produces a sorted array of constant pool indices, one for each Utf8 entry used // by any field short[] * forbiddenFields() { short fFields[] = new short[fields_count]; for (int i=0;i<fields_count;i++) { fFields[i] = * fields[i].name_index; } // now to sort the array return sortShorts(fFields); } * * // sorts an array of shorts using selection sort. It's assumed no valid // entry is 0. static short[] sortShorts(short * a[]) { int i,largest; short s; for(largest = a.length-1;largest>=1;largest--) { for (i=0;i<largest;i++) { if * (a[i]>a[largest]) { s = a[i]; a[i] = a[largest]; a[largest] = s; } } } return a; } * * // Given a new constant pool, and a list of redirections // (new index = redirect[old index]), this changes all constant * // pool entries, and installs the new constant pool of size size void changeConstantPool(short redirect[],cp_info * newCP[],short size) { Debig d = new Debig(this); d.redirectCPRefs(redirect); constant_pool = newCP; constant_pool_count * = size; } * * // the constant pool is typically a few hundred entries in size, and so // is just a bit too big to make use of * insertion/selection sort. // However, the variable size of the entries makes using a heapsort // or quicksort rather * cumbersome, so since it is quite close to the // limits of efficient insertion/selection sort, we'll use that anyway. * void sortConstantPool() { cp_info newcp[] = new cp_info[constant_pool_count]; short redirect[] = new * short[constant_pool_count]; newcp[0] = constant_pool[0]; // the 0-entry stays put redirect[0] = (short)0; int * smallest,j; for (int i=1;i<constant_pool_count;i++) redirect[i] = (short)0; for (int i=1;i<constant_pool_count;i++) { * for (smallest = 1;smallest<constant_pool_count;smallest++) if (redirect[smallest]==(short)0) break; * //logger.debug(" smallest = " + smallest); j = (constant_pool[smallest].tag==cp_info.CONSTANT_Double || * constant_pool[smallest].tag==cp_info.CONSTANT_Long) ? smallest+2 : smallest+1; for (;j<constant_pool_count;j++) { if * ((redirect[j]==(short)0) && constant_pool[j]. compareTo(constant_pool,constant_pool[smallest],constant_pool)<0) { * smallest = j; } if (constant_pool[j].tag==cp_info.CONSTANT_Double || constant_pool[j].tag==cp_info.CONSTANT_Long) j++; } * redirect[smallest] = (short)i; newcp[i] = constant_pool[smallest]; //logger.debug(" Smallest cp entry is [" + smallest + * "] = " + constant_pool[smallest] // + " -> " + i); * * if (constant_pool[smallest].tag==cp_info.CONSTANT_Double || constant_pool[smallest].tag==cp_info.CONSTANT_Long) { * redirect[++smallest] = (short)(++i); newcp[i] = constant_pool[smallest]; } } // constant pool is now sorted into newcp * changeConstantPool(redirect,newcp,constant_pool_count); logger.debug("Finished sorting constant pool"); } * * // just a wrapper for the debigulation, so we can elegantly allocate // a new debigulator, debigualte and then produce * some output void debigulate(boolean attribs,boolean privates) { Debig debigulator = new Debig(this); * debigulator.debigulate(attribs,privates); debigulator.setCF(null); * * inf.verboseReport(G.v().out); } */ }
64,067
33.260963
125
java
soot
soot-master/src/main/java/soot/coffi/Code_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% */ /** * There should be exactly one code attribute in every method; there may also be a code attribute associated with a field (as * an initializer). * * @see attribute_info * @see method_info#attributes * @see field_info#attributes * @see ClassFile@attributes * @author Clark Verbrugge */ class Code_attribute extends attribute_info { /** Maximum size of the operand stack. */ public int max_stack; /** Maximum number of locals required. */ public int max_locals; /** Length of code array. */ public long code_length; /** Actual array of bytecode. */ public byte code[]; /** Length of exception table array. */ public int exception_table_length; /** * Exception table array. * * @see exception_table_entry */ public exception_table_entry exception_table[]; /** Length of attributes array. */ int attributes_count; /** * Array of attributes. * * @see attribute_info */ attribute_info attributes[]; /** * Locates the LocalVariableTable attribute, if one is present. * * @return the local variable table attribute, or <i>null</i> if not found. * @see LocalVariableTable_attribute * @see method_info#makeLocals */ public LocalVariableTable_attribute findLocalVariableTable() { int i; for (i = 0; i < attributes_count; i++) { if (attributes[i] instanceof LocalVariableTable_attribute) { return (LocalVariableTable_attribute) (attributes[i]); } } return null; } /** * Locates the LocalVariableTypeTable attribute, if one is present. * * @return the local variable type table attribute, or <i>null</i> if not found. * @see LocalVariableTypeTable_attribute * @see method_info#makeLocals */ public LocalVariableTypeTable_attribute findLocalVariableTypeTable() { int i; for (i = 0; i < attributes_count; i++) { if (attributes[i] instanceof LocalVariableTypeTable_attribute) { return (LocalVariableTypeTable_attribute) (attributes[i]); } } return null; } }
2,854
28.739583
125
java
soot
soot-master/src/main/java/soot/coffi/CoffiMethodSource.java
package soot.coffi; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 1999 Patrick Lam * %% * 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.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import soot.Body; import soot.MethodSource; import soot.PackManager; import soot.PhaseOptions; import soot.Scene; import soot.SootMethod; import soot.Timers; import soot.jimple.Jimple; import soot.jimple.JimpleBody; import soot.options.Options; public class CoffiMethodSource implements MethodSource { private static final Logger logger = LoggerFactory.getLogger(CoffiMethodSource.class); public ClassFile coffiClass; public method_info coffiMethod; CoffiMethodSource(soot.coffi.ClassFile coffiClass, soot.coffi.method_info coffiMethod) { this.coffiClass = coffiClass; this.coffiMethod = coffiMethod; } public Body getBody(SootMethod m, String phaseName) { JimpleBody jb = Jimple.v().newBody(m); Map options = PhaseOptions.v().getPhaseOptions(phaseName); boolean useOriginalNames = PhaseOptions.getBoolean(options, "use-original-names"); if (useOriginalNames) { soot.coffi.Util.v().setFaithfulNaming(true); } /* * I need to set these to null to free Coffi structures. fileBody.coffiClass = null; bafBody.coffiMethod = null; * */ if (Options.v().verbose()) { logger.debug("[" + m.getName() + "] Constructing JimpleBody from coffi..."); } if (m.isAbstract() || m.isNative() || m.isPhantom()) { return jb; } if (Options.v().time()) { Timers.v().conversionTimer.start(); } if (coffiMethod.instructions == null) { if (Options.v().verbose()) { logger.debug("[" + m.getName() + "] Parsing Coffi instructions..."); } coffiClass.parseMethod(coffiMethod); } if (coffiMethod.cfg == null) { if (Options.v().verbose()) { logger.debug("[" + m.getName() + "] Building Coffi CFG..."); } new soot.coffi.CFG(coffiMethod); // if just computing metrics, we don't need to actually return body if (soot.jbco.Main.metrics) { return null; } } if (Options.v().verbose()) { logger.debug("[" + m.getName() + "] Producing naive Jimple..."); } boolean oldPhantomValue = Scene.v().getPhantomRefs(); Scene.v().setPhantomRefs(true); coffiMethod.cfg.jimplify(coffiClass.constant_pool, coffiClass.this_class, coffiClass.bootstrap_methods_attribute, jb); Scene.v().setPhantomRefs(oldPhantomValue); if (Options.v().time()) { Timers.v().conversionTimer.end(); } coffiMethod.instructions = null; coffiMethod.cfg = null; coffiMethod.attributes = null; coffiMethod.code_attr = null; coffiMethod.jmethod = null; coffiMethod.instructionList = null; coffiMethod = null; coffiClass = null; PackManager.v().getPack("jb").apply(jb); return jb; } }
3,620
27.738095
122
java
soot
soot-master/src/main/java/soot/coffi/ConstantValue_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% */ /** * An attribute for a constant value; used for field initializers. * * @see attribute_info * @see field_info#attributes * @author Clark Verbrugge */ class ConstantValue_attribute extends attribute_info { /** The constant pool index of the actual constant. */ public int constantvalue_index; }
1,128
30.361111
71
java
soot
soot-master/src/main/java/soot/coffi/Deprecated_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 deprecated attribute. * * @see attribute_info * @author Jennifer Lhotak */ class Deprecated_attribute extends attribute_info { }
986
28.909091
71
java
soot
soot-master/src/main/java/soot/coffi/Double2ndHalfType.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 Double2ndHalfType extends Type { public Double2ndHalfType(Singletons.Global g) { } public static Double2ndHalfType v() { return G.v().soot_coffi_Double2ndHalfType(); } public boolean equals(Type otherType) { return otherType instanceof Double2ndHalfType; } @Override public String toString() { return "double2ndhalf"; } }
1,248
25.574468
71
java
soot
soot-master/src/main/java/soot/coffi/EnclosingMethod_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 enclosing method attribute. * * @see attribute_info * @author Jennifer Lhotak */ class EnclosingMethod_attribute extends attribute_info { public int class_index; public int method_index; }
1,051
28.222222
71
java
soot
soot-master/src/main/java/soot/coffi/Exception_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% */ /** * There should be exactly one Exceptions attribute in every method, indicating the types of exceptions the method might * throw. * * @see attribute_info * @see method_info#attributes * @author Clark Verbrugge */ public class Exception_attribute extends attribute_info { /** Length of exception table array. */ public int number_of_exceptions; /** * Constant pool indices of CONSTANT_Class types representing exceptions the associated method might throw. * * @see CONSTANT_Class_info */ public int exception_index_table[]; }
1,376
31.023256
120
java
soot
soot-master/src/main/java/soot/coffi/FutureStmt.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.UnitPrinter; import soot.util.Switch; class FutureStmt extends soot.jimple.internal.AbstractStmt { public Object object; public FutureStmt(Object object) { this.object = object; } public FutureStmt() { } public String toString() { return "<futurestmt>"; } public void toString(UnitPrinter up) { up.literal("<futurestmt>"); } public void apply(Switch sw) { ((soot.jimple.StmtSwitch) sw).defaultCase(this); } public boolean fallsThrough() { throw new RuntimeException(); } public boolean branches() { throw new RuntimeException(); } public Object clone() { throw new RuntimeException(); } }
1,493
23.096774
71
java
soot
soot-master/src/main/java/soot/coffi/Generic_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% */ /** * For representing an unknown, or generic attribute. * * @see attribute_info * @author Clark Verbrugge */ class Generic_attribute extends attribute_info { /** Actual attribute information in byte form. */ public byte info[]; }
1,062
29.371429
71
java
soot
soot-master/src/main/java/soot/coffi/ICONSTANT_Methodref_info.java
package soot.coffi; /*- * #%L * Soot - a J*va Optimization Framework * %% * Copyright (C) 2012 Eric Bodden * %% * 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 {@link CONSTANT_Methodref_info} or {@link CONSTANT_InterfaceMethodref_info}. */ public interface ICONSTANT_Methodref_info { public int getClassIndex(); public int getNameAndTypeIndex(); }
1,022
28.228571
81
java
soot
soot-master/src/main/java/soot/coffi/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% */ // for storing statistical or informative data about a class file import java.io.PrintStream; class Info { public ClassFile cf; public long flength; // file length public int cp; // number of constant pool entries public int fields; // number of fields public int methods; // number of methods public int pfields; // private fields public int pmethods; // private methods public int attribsave; // savings through attribute elimination public int attribcpsave;// savings through cp compression after attribute elim. public int psave; // savings through renaming privates public Info(ClassFile newcf) { cf = newcf; } public void verboseReport(PrintStream ps) { int total; ps.println("<INFO> -- Debigulation Report on " + cf.fn + " --"); ps.println("<INFO> Length: " + flength); ps.println("<INFO> CP: " + cp + " reduced to " + cf.constant_pool_count); ps.println("<INFO> Fields: " + fields + " (" + pfields + " private)" + " reduced to " + cf.fields_count); ps.println("<INFO> Methods: " + methods + " (" + pmethods + " private)" + " reduced to " + cf.methods_count); total = attribsave + attribcpsave + psave; if (total > 0) { ps.println("<INFO> -- Savings through debigulation --"); if (attribsave > 0) { ps.println("<INFO> Attributes: " + attribsave); } if (attribcpsave > 0) { ps.println("<INFO> CP Compression: " + attribcpsave); } if (psave > 0) { ps.println("<INFO> Private renaming: " + psave); } ps.println("<INFO> Total savings: " + total); double d = ((total) * 100000.0) / (flength); int x = (int) d; d = (x) / 1000.0; ps.println("<INFO> ratio: " + d + "%"); } } }
2,603
33.72
114
java
soot
soot-master/src/main/java/soot/coffi/InnerClasses_attribute.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% */ /** * Attribute that connects inner classes with their containing classes. * * @see attribute_info * @author Archie L. Cobbs */ class InnerClasses_attribute extends attribute_info { /** Length of the inner classes table. */ public int inner_classes_length; /** Actual table of local variables. */ public inner_class_entry inner_classes[]; public String toString() { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < inner_classes_length; i++) { buffer.append(inner_classes[i]); buffer.append('\n'); } return buffer.toString(); } }
1,411
29.695652
71
java
soot
soot-master/src/main/java/soot/coffi/Instruction.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 */ abstract class Instruction implements Cloneable { /** String used to separate arguments in printing. */ public static final String argsep = " "; /** String used to construct names for local variables. */ public static final String LOCALPREFIX = "local_"; // public static int w; // set by the wide instr. and used by other instrs /** Actual byte code of this instruction. */ public byte code; /** * Offset of this instruction from the start of code. * * @see ClassFile#relabel */ public int label; /** * Name of this instruction. * * @see Instruction#toString */ public String name; /** Reference for chaining. */ public Instruction next; /** More convenient for chaining. */ public Instruction prev; /** Whether this instruction is the target of a branch. */ public boolean labelled; /** Whether this instruction branches. */ public boolean branches; /** Whether this instruction is a method invocation. */ public boolean calls; /** Whether this instruction is a return. */ public boolean returns; /** Successor array. It is different from the field 'next'. */ public Instruction[] succs; int originalIndex; /** * Constructs a new Instruction for this bytecode. * * @param c * bytecode of the instruction. */ public Instruction(byte c) { code = c; next = null; branches = false; calls = false; returns = false; } protected Object clone() throws CloneNotSupportedException { return super.clone(); } public String toString() { return label + ": " + name + "[" + originalIndex + "]"; } /** * Assuming the actual bytecode for this instruction has been extracted already, and index is the offset of the next byte, * this method parses whatever arguments the instruction requires and return the offset of the next available byte. * * @param bc * complete array of bytecode. * @param index * offset of remaining bytecode after this instruction's bytecode was parsed. * @return offset of the next available bytecode. * @see ByteCode#disassemble_bytecode * @see Instruction#compile */ public abstract int parse(byte bc[], int index); /** * Writes out the sequence of bytecodes represented by this instruction, including any arguments. * * @param bc * complete array of bytecode. * @param index * offset of remaining bytecode at which to start writing. * @return offset of the next available bytecode. * @see ClassFile#unparseMethod * @see Instruction#parse */ public abstract int compile(byte bc[], int index); /** * Changes offset values in this instruction to Instruction references; default behaviour is to do nothing. * * @param bc * complete array of bytecode. * @see ByteCode#build */ public void offsetToPointer(ByteCode bc) { } /** * Returns the next available offset assuming this instruction begins on the indicated offset; default assumes no * arguments. * * @param curr * offset this instruction would be on. * @return next available offset. * @see ClassFile#relabel */ public int nextOffset(int curr) { return curr + 1; } /** * Returns an array of the instructions to which this instruction might branch (only valid if branches==<i>true</i>; * default action is to return <i>null</i>). * * @param next * the instruction following this one, in case of default flow through. * @return array of instructions which may be targets of this instruction. * @see Instruction#branches */ public Instruction[] branchpoints(Instruction next) { /* * Instruction[] bps= new Instruction[1]; bps[0] = next; return bps; */ return null; } /** * Marks the appropriate spot if that constant_pool entry is used by this instr. For every constant pool entry used * (referenced) by this instruction, the corresponding boolean in the given array is set to <i>true</i>. * * @param refs * array of booleans the same size as the constant pool array. * @see ClassFile#constant_pool */ public void markCPRefs(boolean[] refs) { } /** * Updates all constant pool references within this instruction to use new indices, based on the given redirection array. * * @param redirect * array of new indices of constant pool entries. * @see ClassFile#constant_pool */ public void redirectCPRefs(short redirect[]) { } /** * For storing in a Hashtable. * * @return unique hash code for this instruction, assuming labels are unique. */ public int hashCode() { return (new Integer(label)).hashCode(); } /** * For storing in a Hashtable. * * @param i * the Instruction to which this is compared. * @return <i>true</i> if <i>i</i> is the same, <i>false</i> otherwise. */ public boolean equals(Instruction i) { return (this == i); /* * if (label == i.label) return true; return false; */ } /** * Utility routines, used mostly by the parse routines of various Instruction subclasses; this method converts two bytes * into a short. * * @param bc * complete array of bytecode. * @param index * offset of data in bc. * @return the short constructed from the two bytes. * @see Instruction#parse * @see Instruction#shortToBytes */ public static short getShort(byte bc[], int index) { short s, bh, bl; bh = (bc[index]); bl = (bc[index + 1]); s = (short) (((bh << 8) & 0xff00) | (bl & 0xff)); // s = (short)((int)(bc[index])<<8 + bc[index+1]); return s; } /** * Utility routines, used mostly by the parse routines of various Instruction subclasses; this method converts four bytes * into an int. * * @param bc * complete array of bytecode. * @param index * offset of data in bc. * @return the int constructed from the four bytes. * @see Instruction#parse * @see Instruction#intToBytes */ public static int getInt(byte bc[], int index) { int i, bhh, bhl, blh, bll; bhh = (((bc[index])) << 24) & 0xff000000; bhl = (((bc[index + 1])) << 16) & 0xff0000; blh = (((bc[index + 2])) << 8) & 0xff00; bll = ((bc[index + 3])) & 0xff; i = bhh | bhl | blh | bll; return i; } /** * Utility routines, used mostly by the compile routines of various Instruction subclasses; this method converts a short * into two bytes. * * @param bc * complete array of bytecode in which to store the short. * @param index * next available offset in bc. * @return the next available offset in bc * @see Instruction#compile * @see Instruction#getShort */ public static int shortToBytes(short s, byte bc[], int index) { bc[index++] = (byte) ((s >> 8) & 0xff); bc[index++] = (byte) (s & 0xff); return index; } /** * Utility routines, used mostly by the compile routines of various Instruction subclasses; this method converts an int * into four bytes. * * @param bc * complete array of bytecode in which to store the int. * @param index * next available offset in bc. * @return the next available offset in bc * @see Instruction#compile * @see Instruction#getInt */ public static int intToBytes(int s, byte bc[], int index) { bc[index++] = (byte) ((s >> 24) & 0xff); bc[index++] = (byte) ((s >> 16) & 0xff); bc[index++] = (byte) ((s >> 8) & 0xff); bc[index++] = (byte) (s & 0xff); return index; } /** * For displaying instructions. * * @param constant_pool * constant pool of associated ClassFile * @return String representation of this instruction. */ public String toString(cp_info constant_pool[]) { int i = (code) & 0xff; if (name == null) { name = "null???=" + Integer.toString(i); } return name; } }
10,133
29.990826
124
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aaload.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_Aaload extends Instruction_noargs { public Instruction_Aaload() { super((byte) ByteCode.AALOAD); name = "aaload"; } }
2,246
35.241935
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aastore.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_Aastore extends Instruction_noargs { public Instruction_Aastore() { super((byte) ByteCode.AASTORE); name = "aastore"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aconst_null.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_Aconst_null extends Instruction_noargs { public Instruction_Aconst_null() { super((byte) ByteCode.ACONST_NULL); name = "aconst_null"; } }
2,266
35.564516
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aload.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_Aload extends Instruction_bytevar { public Instruction_Aload() { super((byte) ByteCode.ALOAD); name = "aload"; } }
2,243
35.193548
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aload_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_Aload_0 extends Instruction_noargs { public Instruction_Aload_0() { super((byte) ByteCode.ALOAD_0); name = "aload_0"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aload_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_Aload_1 extends Instruction_noargs { public Instruction_Aload_1() { super((byte) ByteCode.ALOAD_1); name = "aload_1"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aload_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_Aload_2 extends Instruction_noargs { public Instruction_Aload_2() { super((byte) ByteCode.ALOAD_2); name = "aload_2"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Aload_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_Aload_3 extends Instruction_noargs { public Instruction_Aload_3() { super((byte) ByteCode.ALOAD_3); name = "aload_3"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Anewarray.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_Anewarray extends Instruction_intindex { public Instruction_Anewarray() { super((byte) ByteCode.ANEWARRAY); name = "anewarray"; } }
2,260
35.467742
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Areturn.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_Areturn extends Instruction_noargs { public Instruction_Areturn() { super((byte) ByteCode.ARETURN); name = "areturn"; branches = true; returns = true; } }
2,291
34.8125
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Arraylength.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_Arraylength extends Instruction_noargs { public Instruction_Arraylength() { super((byte) ByteCode.ARRAYLENGTH); name = "arraylength"; } }
2,266
35.564516
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Astore.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_Astore extends Instruction_bytevar implements Interface_Astore { public Instruction_Astore() { super((byte) ByteCode.ASTORE); name = "astore"; } public int getLocalNumber() { return arg_b; } }
2,330
34.318182
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Astore_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_Astore_0 extends Instruction_noargs implements Interface_Astore { public Instruction_Astore_0() { super((byte) ByteCode.ASTORE_0); name = "astore_0"; } public int getLocalNumber() { return 0; } }
2,333
34.363636
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Astore_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_Astore_1 extends Instruction_noargs implements Interface_Astore { public Instruction_Astore_1() { super((byte) ByteCode.ASTORE_1); name = "astore_1"; } public int getLocalNumber() { return 1; } }
2,333
34.363636
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Astore_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_Astore_2 extends Instruction_noargs implements Interface_Astore { public Instruction_Astore_2() { super((byte) ByteCode.ASTORE_2); name = "astore_2"; } public int getLocalNumber() { return 2; } }
2,333
34.363636
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Astore_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_Astore_3 extends Instruction_noargs implements Interface_Astore { public Instruction_Astore_3() { super((byte) ByteCode.ASTORE_3); name = "astore_3"; } public int getLocalNumber() { return 3; } }
2,333
34.363636
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Athrow.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_Athrow extends Instruction_noargs { public Instruction_Athrow() { super((byte) ByteCode.ATHROW); name = "athrow"; branches = true; } public Instruction[] branchpoints(Instruction next) { Instruction i[] = new Instruction[1]; i[0] = null; return i; } }
2,401
33.811594
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Baload.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_Baload extends Instruction_noargs { public Instruction_Baload() { super((byte) ByteCode.BALOAD); name = "baload"; } }
2,246
35.241935
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Bastore.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_Bastore extends Instruction_noargs { public Instruction_Bastore() { super((byte) ByteCode.BASTORE); name = "bastore"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Bipush.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_Bipush extends Instruction_byte { public Instruction_Bipush() { super((byte) ByteCode.BIPUSH); name = "bipush"; } public Instruction_Bipush(byte b) { this(); arg_b = b; } }
2,314
33.552239
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Breakpoint.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_Breakpoint extends Instruction_noargs { public Instruction_Breakpoint() { super((byte) ByteCode.BREAKPOINT); name = "breakpoint"; } }
2,262
35.5
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Caload.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_Caload extends Instruction_noargs { public Instruction_Caload() { super((byte) ByteCode.CALOAD); name = "caload"; } }
2,246
35.241935
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Castore.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_Castore extends Instruction_noargs { public Instruction_Castore() { super((byte) ByteCode.CASTORE); name = "castore"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Checkcast.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_Checkcast extends Instruction_intindex { public Instruction_Checkcast() { super((byte) ByteCode.CHECKCAST); name = "checkcast"; } }
2,260
35.467742
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_D2f.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_D2f extends Instruction_noargs { public Instruction_D2f() { super((byte) ByteCode.D2F); name = "d2f"; } }
2,234
35.048387
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_D2i.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_D2i extends Instruction_noargs { public Instruction_D2i() { super((byte) ByteCode.D2I); name = "d2i"; } }
2,234
35.048387
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_D2l.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_D2l extends Instruction_noargs { public Instruction_D2l() { super((byte) ByteCode.D2L); name = "d2l"; } }
2,234
35.048387
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dadd.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_Dadd extends Instruction_noargs { public Instruction_Dadd() { super((byte) ByteCode.DADD); name = "dadd"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Daload.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_Daload extends Instruction_noargs { public Instruction_Daload() { super((byte) ByteCode.DALOAD); name = "daload"; } }
2,246
35.241935
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dastore.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_Dastore extends Instruction_noargs { public Instruction_Dastore() { super((byte) ByteCode.DASTORE); name = "dastore"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dcmpg.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_Dcmpg extends Instruction_noargs { public Instruction_Dcmpg() { super((byte) ByteCode.DCMPG); name = "dcmpg"; } }
2,242
35.177419
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dcmpl.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_Dcmpl extends Instruction_noargs { public Instruction_Dcmpl() { super((byte) ByteCode.DCMPL); name = "dcmpl"; } }
2,242
35.177419
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dconst_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_Dconst_0 extends Instruction_noargs { public Instruction_Dconst_0() { super((byte) ByteCode.DCONST_0); name = "dconst_0"; } }
2,254
35.370968
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dconst_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_Dconst_1 extends Instruction_noargs { public Instruction_Dconst_1() { super((byte) ByteCode.DCONST_1); name = "dconst_1"; } }
2,254
35.370968
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Ddiv.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_Ddiv extends Instruction_noargs { public Instruction_Ddiv() { super((byte) ByteCode.DDIV); name = "ddiv"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dload.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_Dload extends Instruction_bytevar { public Instruction_Dload() { super((byte) ByteCode.DLOAD); name = "dload"; } }
2,243
35.193548
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dload_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_Dload_0 extends Instruction_noargs { public Instruction_Dload_0() { super((byte) ByteCode.DLOAD_0); name = "dload_0"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dload_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_Dload_1 extends Instruction_noargs { public Instruction_Dload_1() { super((byte) ByteCode.DLOAD_1); name = "dload_1"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dload_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_Dload_2 extends Instruction_noargs { public Instruction_Dload_2() { super((byte) ByteCode.DLOAD_2); name = "dload_2"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dload_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_Dload_3 extends Instruction_noargs { public Instruction_Dload_3() { super((byte) ByteCode.DLOAD_3); name = "dload_3"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dmul.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_Dmul extends Instruction_noargs { public Instruction_Dmul() { super((byte) ByteCode.DMUL); name = "dmul"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dneg.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_Dneg extends Instruction_noargs { public Instruction_Dneg() { super((byte) ByteCode.DNEG); name = "dneg"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Drem.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_Drem extends Instruction_noargs { public Instruction_Drem() { super((byte) ByteCode.DREM); name = "drem"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dreturn.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_Dreturn extends Instruction_noargs { public Instruction_Dreturn() { super((byte) ByteCode.DRETURN); name = "dreturn"; branches = true; returns = true; } }
2,291
34.8125
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dstore.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_Dstore extends Instruction_bytevar { public Instruction_Dstore() { super((byte) ByteCode.DSTORE); name = "dstore"; } }
2,247
35.258065
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dstore_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_Dstore_0 extends Instruction_noargs { public Instruction_Dstore_0() { super((byte) ByteCode.DSTORE_0); name = "dstore_0"; } }
2,254
35.370968
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dstore_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_Dstore_1 extends Instruction_noargs { public Instruction_Dstore_1() { super((byte) ByteCode.DSTORE_1); name = "dstore_1"; } }
2,254
35.370968
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dstore_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_Dstore_2 extends Instruction_noargs { public Instruction_Dstore_2() { super((byte) ByteCode.DSTORE_2); name = "dstore_2"; } }
2,254
35.370968
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dstore_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_Dstore_3 extends Instruction_noargs { public Instruction_Dstore_3() { super((byte) ByteCode.DSTORE_3); name = "dstore_3"; } }
2,254
35.370968
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dsub.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_Dsub extends Instruction_noargs { public Instruction_Dsub() { super((byte) ByteCode.DSUB); name = "dsub"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dup.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_Dup extends Instruction_noargs { public Instruction_Dup() { super((byte) ByteCode.DUP); name = "dup"; } }
2,234
35.048387
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dup2.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_Dup2 extends Instruction_noargs { public Instruction_Dup2() { super((byte) ByteCode.DUP2); name = "dup2"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dup2_x1.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_Dup2_x1 extends Instruction_noargs { public Instruction_Dup2_x1() { super((byte) ByteCode.DUP2_X1); name = "dup2_x1"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dup2_x2.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_Dup2_x2 extends Instruction_noargs { public Instruction_Dup2_x2() { super((byte) ByteCode.DUP2_X2); name = "dup2_x2"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dup_x1.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_Dup_x1 extends Instruction_noargs { public Instruction_Dup_x1() { super((byte) ByteCode.DUP_X1); name = "dup_x1"; } }
2,246
35.241935
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Dup_x2.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_Dup_x2 extends Instruction_noargs { public Instruction_Dup_x2() { super((byte) ByteCode.DUP_X2); name = "dup_x2"; } }
2,246
35.241935
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_F2d.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_F2d extends Instruction_noargs { public Instruction_F2d() { super((byte) ByteCode.F2D); name = "f2d"; } }
2,234
35.048387
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_F2i.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_F2i extends Instruction_noargs { public Instruction_F2i() { super((byte) ByteCode.F2I); name = "f2i"; } }
2,234
35.048387
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_F2l.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_F2l extends Instruction_noargs { public Instruction_F2l() { super((byte) ByteCode.F2L); name = "f2l"; } }
2,234
35.048387
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Fadd.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_Fadd extends Instruction_noargs { public Instruction_Fadd() { super((byte) ByteCode.FADD); name = "fadd"; } }
2,238
35.112903
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Faload.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_Faload extends Instruction_noargs { public Instruction_Faload() { super((byte) ByteCode.FALOAD); name = "faload"; } }
2,246
35.241935
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Fastore.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_Fastore extends Instruction_noargs { public Instruction_Fastore() { super((byte) ByteCode.FASTORE); name = "fastore"; } }
2,250
35.306452
120
java
soot
soot-master/src/main/java/soot/coffi/Instruction_Fcmpg.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_Fcmpg extends Instruction_noargs { public Instruction_Fcmpg() { super((byte) ByteCode.FCMPG); name = "fcmpg"; } }
2,242
35.177419
120
java