/*
* ProGuard -- shrinking, optimization, obfuscation, and preverification
* of Java bytecode.
*
* Copyright (c) 2002-2011 Eric Lafortune (eric@graphics.cornell.edu)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 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 Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package proguard.optimize.peephole;
import proguard.classfile.constant.*;
import proguard.classfile.instruction.*;
import proguard.classfile.util.InstructionSequenceMatcher;
/**
* This class contains a set of instruction sequences and their suggested
* replacements.
*
* @see InstructionSequencesReplacer
* @author Eric Lafortune
*/
public class InstructionSequenceConstants
{
public static final int X = InstructionSequenceMatcher.X;
public static final int Y = InstructionSequenceMatcher.Y;
public static final int Z = InstructionSequenceMatcher.Z;
public static final int A = InstructionSequenceMatcher.A;
public static final int B = InstructionSequenceMatcher.B;
public static final int C = InstructionSequenceMatcher.C;
public static final int D = InstructionSequenceMatcher.D;
private static final int I_32768 = 0;
private static final int I_65536 = 1;
private static final int I_16777216 = 2;
// private static final int I_0x000000ff
private static final int I_0x0000ff00 = 3;
private static final int I_0x00ff0000 = 4;
private static final int I_0xff000000 = 5;
private static final int I_0x0000ffff = 6;
private static final int I_0xffff0000 = 7;
private static final int L_M1 = 8;
private static final int L_2 = 9;
private static final int L_4 = 10;
private static final int L_8 = 11;
private static final int L_16 = 12;
private static final int L_32 = 13;
private static final int L_64 = 14;
private static final int L_128 = 15;
private static final int L_256 = 16;
private static final int L_512 = 17;
private static final int L_1024 = 18;
private static final int L_2048 = 19;
private static final int L_4096 = 20;
private static final int L_8192 = 21;
private static final int L_16384 = 22;
private static final int L_32768 = 23;
private static final int L_65536 = 24;
private static final int L_16777216 = 25;
private static final int L_4294967296 = 26;
private static final int L_0x00000000ffffffff = 27;
private static final int L_0xffffffff00000000 = 28;
private static final int F_M1 = 29;
private static final int D_M1 = 30;
private static final int FIELD_I = 31;
private static final int FIELD_L = 32;
private static final int FIELD_F = 33;
private static final int FIELD_D = 34;
private static final int NAME_AND_TYPE_I = 35;
private static final int NAME_AND_TYPE_L = 36;
private static final int NAME_AND_TYPE_F = 37;
private static final int NAME_AND_TYPE_D = 38;
private static final int TYPE_I = 39;
private static final int TYPE_L = 40;
private static final int TYPE_F = 41;
private static final int TYPE_D = 42;
public static final Constant[] CONSTANTS = new Constant[]
{
new IntegerConstant(32768),
new IntegerConstant(65536),
new IntegerConstant(16777216),
new IntegerConstant(0x0000ff00),
new IntegerConstant(0x00ff0000),
new IntegerConstant(0xff000000),
new IntegerConstant(0x0000ffff),
new IntegerConstant(0xffff0000),
new LongConstant(-1L),
new LongConstant(2L),
new LongConstant(4L),
new LongConstant(8L),
new LongConstant(16L),
new LongConstant(32L),
new LongConstant(64L),
new LongConstant(128L),
new LongConstant(256L),
new LongConstant(512L),
new LongConstant(1024L),
new LongConstant(2048L),
new LongConstant(4096L),
new LongConstant(8192L),
new LongConstant(16384L),
new LongConstant(32768L),
new LongConstant(65536L),
new LongConstant(16777216L),
new LongConstant(4294967296L),
new LongConstant(0x00000000ffffffffL),
new LongConstant(0xffffffff00000000L),
new FloatConstant(-1f),
new DoubleConstant(-1d),
new FieldrefConstant(X, NAME_AND_TYPE_I, null, null),
new FieldrefConstant(X, NAME_AND_TYPE_L, null, null),
new FieldrefConstant(X, NAME_AND_TYPE_F, null, null),
new FieldrefConstant(X, NAME_AND_TYPE_D, null, null),
new NameAndTypeConstant(Y, TYPE_I),
new NameAndTypeConstant(Y, TYPE_L),
new NameAndTypeConstant(Y, TYPE_F),
new NameAndTypeConstant(Y, TYPE_D),
new Utf8Constant("I"),
new Utf8Constant("J"),
new Utf8Constant("F"),
new Utf8Constant("D"),
};
public static final Instruction[][][] VARIABLE = new Instruction[][][]
{
{ // nop = nothing
{
new SimpleInstruction(InstructionConstants.OP_NOP),
},{
// Nothing.
},
},
{ // iload/pop = nothing
{
new VariableInstruction(InstructionConstants.OP_ILOAD, X),
new SimpleInstruction(InstructionConstants.OP_POP),
},{
// Nothing.
},
},
{ // lload/pop2 = nothing
{
new VariableInstruction(InstructionConstants.OP_LLOAD, X),
new SimpleInstruction(InstructionConstants.OP_POP2),
},{
// Nothing.
},
},
{ // fload/pop = nothing
{
new VariableInstruction(InstructionConstants.OP_FLOAD, X),
new SimpleInstruction(InstructionConstants.OP_POP),
},{
// Nothing.
},
},
{ // dload/pop2 = nothing
{
new VariableInstruction(InstructionConstants.OP_DLOAD, X),
new SimpleInstruction(InstructionConstants.OP_POP2),
},{
// Nothing.
},
},
{ // aload/pop = nothing
{
new VariableInstruction(InstructionConstants.OP_ALOAD, X),
new SimpleInstruction(InstructionConstants.OP_POP),
},{
// Nothing.
},
},
{ // i = i = nothing
{
new VariableInstruction(InstructionConstants.OP_ILOAD, X),
new VariableInstruction(InstructionConstants.OP_ISTORE, X),
},{
// Nothing.
},
},
{ // l = l = nothing
{
new VariableInstruction(InstructionConstants.OP_LLOAD, X),
new VariableInstruction(InstructionConstants.OP_LSTORE, X),
},{
// Nothing.