    View Javadoc
    1   package org.apache.bcel.generic;
    2
    3   /* ====================================================================
    4    * The Apache Software License, Version 1.1
    5    *
    6    * Copyright (c) 2001 The Apache Software Foundation.  All rights
    7    * reserved.
    8    *
    9    * Redistribution and use in source and binary forms, with or without
    10   * modification, are permitted provided that the following conditions
    11   * are met:
    12   *
    13   * 1. Redistributions of source code must retain the above copyright
    14   *    notice, this list of conditions and the following disclaimer.
    15   *
    16   * 2. Redistributions in binary form must reproduce the above copyright
    17   *    notice, this list of conditions and the following disclaimer in
    18   *    the documentation and/or other materials provided with the
    19   *    distribution.
    20   *
    21   * 3. The end-user documentation included with the redistribution,
    22   *    if any, must include the following acknowledgment:
    23   *       "This product includes software developed by the
    24   *        Apache Software Foundation (http://www.apache.org/)."
    25   *    Alternately, this acknowledgment may appear in the software itself,
    26   *    if and wherever such third-party acknowledgments normally appear.
    27   *
    28   * 4. The names "Apache" and "Apache Software Foundation" and
    29   *    "Apache BCEL" must not be used to endorse or promote products
    30   *    derived from this software without prior written permission. For
    31   *    written permission, please contact apache@apache.org.
    32   *
    33   * 5. Products derived from this software may not be called "Apache",
    34   *    "Apache BCEL", nor may "Apache" appear in their name, without
    35   *    prior written permission of the Apache Software Foundation.
    36   *
    37   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    38   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    39   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    40   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    41   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    42   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    43   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    44   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    45   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    46   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    47   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    48   * SUCH DAMAGE.
    49   * ====================================================================
    50   *
    51   * This software consists of voluntary contributions made by many
    52   * individuals on behalf of the Apache Software Foundation.  For more
    53   * information on the Apache Software Foundation, please see
    54   * <http://www.apache.org/>;.
    55   */
    56
    57  import org.apache.bcel.Constants;
    58
    59  /***
    60   * This interface contains shareable instruction objects.
    61   *
    62   * In order to save memory you can use some instructions multiply,
    63   * since they have an immutable state and are directly derived from
    64   * Instruction.  I.e. they have no instance fields that could be
    65   * changed. Since some of these instructions like ICONST_0 occur
    66   * very frequently this can save a lot of time and space. This
    67   * feature is an adaptation of the FlyWeight design pattern, we
    68   * just use an array instead of a factory.
    69   *
    70   * The Instructions can also accessed directly under their names, so
    71   * it's possible to write il.append(Instruction.ICONST_0);
    72   *
    73   * @version $Id: InstructionConstants.java,v 1.1.1.1 2001/10/29 20:00:18 jvanzyl Exp $
    74   * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    75   */
    76  public interface InstructionConstants {
    77    /*** Predefined instruction objects
    78     */
    79    public static final Instruction           NOP          = new NOP();
    80    public static final Instruction           ACONST_NULL  = new ACONST_NULL();
    81    public static final Instruction           ICONST_M1    = new ICONST(-1);
    82    public static final Instruction           ICONST_0     = new ICONST(0);
    83    public static final Instruction           ICONST_1     = new ICONST(1);
    84    public static final Instruction           ICONST_2     = new ICONST(2);
    85    public static final Instruction           ICONST_3     = new ICONST(3);
    86    public static final Instruction           ICONST_4     = new ICONST(4);
    87    public static final Instruction           ICONST_5     = new ICONST(5);
    88    public static final Instruction           LCONST_0     = new LCONST(0);
    89    public static final Instruction           LCONST_1     = new LCONST(1);
    90    public static final Instruction           FCONST_0     = new FCONST(0);
    91    public static final Instruction           FCONST_1     = new FCONST(1);
    92    public static final Instruction           FCONST_2     = new FCONST(2);
    93    public static final Instruction           DCONST_0     = new DCONST(0);
    94    public static final Instruction           DCONST_1     = new DCONST(1);
    95    public static final ArrayInstruction      IALOAD       = new IALOAD();
    96    public static final ArrayInstruction      LALOAD       = new LALOAD();
    97    public static final ArrayInstruction      FALOAD       = new FALOAD();
    98    public static final ArrayInstruction      DALOAD       = new DALOAD();
    99    public static final ArrayInstruction      AALOAD       = new AALOAD();
    100   public static final ArrayInstruction      BALOAD       = new BALOAD();
    101   public static final ArrayInstruction      CALOAD       = new CALOAD();
    102   public static final ArrayInstruction      SALOAD       = new SALOAD();
    103   public static final ArrayInstruction      IASTORE      = new IASTORE();
    104   public static final ArrayInstruction      LASTORE      = new LASTORE();
    105   public static final ArrayInstruction      FASTORE      = new FASTORE();
    106   public static final ArrayInstruction      DASTORE      = new DASTORE();
    107   public static final ArrayInstruction      AASTORE      = new AASTORE();
    108   public static final ArrayInstruction      BASTORE      = new BASTORE();
    109   public static final ArrayInstruction      CASTORE      = new CASTORE();
    110   public static final ArrayInstruction      SASTORE      = new SASTORE();
    111   public static final StackInstruction      POP          = new POP();
    112   public static final StackInstruction      POP2         = new POP2();
    113   public static final StackInstruction      DUP          = new DUP();
    114   public static final StackInstruction      DUP_X1       = new DUP_X1();
    115   public static final StackInstruction      DUP_X2       = new DUP_X2();
    116   public static final StackInstruction      DUP2         = new DUP2();
    117   public static final StackInstruction      DUP2_X1      = new DUP2_X1();
    118   public static final StackInstruction      DUP2_X2      = new DUP2_X2();
    119   public static final StackInstruction      SWAP         = new SWAP();
    120   public static final ArithmeticInstruction IADD         = new IADD();
    121   public static final ArithmeticInstruction LADD         = new LADD();
    122   public static final ArithmeticInstruction FADD         = new FADD();
    123   public static final ArithmeticInstruction DADD         = new DADD();
    124   public static final ArithmeticInstruction ISUB         = new ISUB();
    125   public static final ArithmeticInstruction LSUB         = new LSUB();
    126   public static final ArithmeticInstruction FSUB         = new FSUB();
    127   public static final ArithmeticInstruction DSUB         = new DSUB();
    128   public static final ArithmeticInstruction IMUL         = new IMUL();
    129   public static final ArithmeticInstruction LMUL         = new LMUL();
    130   public static final ArithmeticInstruction FMUL         = new FMUL();
    131   public static final ArithmeticInstruction DMUL         = new DMUL();
    132   public static final ArithmeticInstruction IDIV         = new IDIV();
    133   public static final ArithmeticInstruction LDIV         = new LDIV();
    134   public static final ArithmeticInstruction FDIV         = new FDIV();
    135   public static final ArithmeticInstruction DDIV         = new DDIV();
    136   public static final ArithmeticInstruction IREM         = new IREM();
    137   public static final ArithmeticInstruction LREM         = new LREM();
    138   public static final ArithmeticInstruction FREM         = new FREM();
    139   public static final ArithmeticInstruction DREM         = new DREM();
    140   public static final ArithmeticInstruction INEG         = new INEG();
    141   public static final ArithmeticInstruction LNEG         = new LNEG();
    142   public static final ArithmeticInstruction FNEG         = new FNEG();
    143   public static final ArithmeticInstruction DNEG         = new DNEG();
    144   public static final ArithmeticInstruction ISHL         = new ISHL();
    145   public static final ArithmeticInstruction LSHL         = new LSHL();
    146   public static final ArithmeticInstruction ISHR         = new ISHR();
    147   public static final ArithmeticInstruction LSHR         = new LSHR();
    148   public static final ArithmeticInstruction IUSHR        = new IUSHR();
    149   public static final ArithmeticInstruction LUSHR        = new LUSHR();
    150   public static final ArithmeticInstruction IAND         = new IAND();
    151   public static final ArithmeticInstruction LAND         = new LAND();
    152   public static final ArithmeticInstruction IOR          = new IOR();
    153   public static final ArithmeticInstruction LOR          = new LOR();
    154   public static final ArithmeticInstruction IXOR         = new IXOR();
    155   public static final ArithmeticInstruction LXOR         = new LXOR();
    156   public static final ConversionInstruction I2L          = new I2L();
    157   public static final ConversionInstruction I2F          = new I2F();
    158   public static final ConversionInstruction I2D          = new I2D();
    159   public static final ConversionInstruction L2I          = new L2I();
    160   public static final ConversionInstruction L2F          = new L2F();
    161   public static final ConversionInstruction L2D          = new L2D();
    162   public static final ConversionInstruction F2I          = new F2I();
    163   public static final ConversionInstruction F2L          = new F2L();
    164   public static final ConversionInstruction F2D          = new F2D();
    165   public static final ConversionInstruction D2I          = new D2I();
    166   public static final ConversionInstruction D2L          = new D2L();
    167   public static final ConversionInstruction D2F          = new D2F();
    168   public static final ConversionInstruction I2B          = new I2B();
    169   public static final ConversionInstruction I2C          = new I2C();
    170   public static final ConversionInstruction I2S          = new I2S();
    171   public static final Instruction           LCMP         = new LCMP();
    172   public static final Instruction           FCMPL        = new FCMPL();
    173   public static final Instruction           FCMPG        = new FCMPG();
    174   public static final Instruction           DCMPL        = new DCMPL();
    175   public static final Instruction           DCMPG        = new DCMPG();
    176   public static final ReturnInstruction     IRETURN      = new IRETURN();
    177   public static final ReturnInstruction     LRETURN      = new LRETURN();
    178   public static final ReturnInstruction     FRETURN      = new FRETURN();
    179   public static final ReturnInstruction     DRETURN      = new DRETURN();
    180   public static final ReturnInstruction     ARETURN      = new ARETURN();
    181   public static final ReturnInstruction     RETURN       = new RETURN();
    182   public static final Instruction           ARRAYLENGTH  = new ARRAYLENGTH();
    183   public static final Instruction           ATHROW       = new ATHROW();
    184   public static final Instruction           MONITORENTER = new MONITORENTER();
    185   public static final Instruction           MONITOREXIT  = new MONITOREXIT();
    186
    187   /*** You can use these constants in multiple places safely, if you can guarantee
    188    * that you will never alter their internal values, e.g. call setIndex().
    189    */
    190   public static final LocalVariableInstruction THIS    = new ALOAD(0);
    191   public static final LocalVariableInstruction ALOAD_0 = THIS;
    192   public static final LocalVariableInstruction ALOAD_1 = new ALOAD(1);
    193   public static final LocalVariableInstruction ALOAD_2 = new ALOAD(2);
    194   public static final LocalVariableInstruction ILOAD_0 = new ILOAD(0);
    195   public static final LocalVariableInstruction ILOAD_1 = new ILOAD(1);
    196   public static final LocalVariableInstruction ILOAD_2 = new ILOAD(2);
    197   public static final LocalVariableInstruction ASTORE_0 = new ASTORE(0);
    198   public static final LocalVariableInstruction ASTORE_1 = new ASTORE(1);
    199   public static final LocalVariableInstruction ASTORE_2 = new ASTORE(2);
    200   public static final LocalVariableInstruction ISTORE_0 = new ISTORE(0);
    201   public static final LocalVariableInstruction ISTORE_1 = new ISTORE(1);
    202   public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2);
    203
    204
    205   /*** Get object via its opcode, for immutable instructions like
    206    * branch instructions entries are set to null.
    207    */
    208   public static final Instruction[] INSTRUCTIONS = new Instruction[256];
    209
    210   /*** Interfaces may have no static initializers, so we simulate this
    211    * with an inner class.
    212    */
    213   static final Clinit bla = new Clinit();
    214
    215   static class Clinit {
    216     Clinit() {
    217       INSTRUCTIONS[Constants.NOP] = NOP;
    218       INSTRUCTIONS[Constants.ACONST_NULL] = ACONST_NULL;
    219       INSTRUCTIONS[Constants.ICONST_M1] = ICONST_M1;
    220       INSTRUCTIONS[Constants.ICONST_0] = ICONST_0;
    221       INSTRUCTIONS[Constants.ICONST_1] = ICONST_1;
    222       INSTRUCTIONS[Constants.ICONST_2] = ICONST_2;
    223       INSTRUCTIONS[Constants.ICONST_3] = ICONST_3;
    224       INSTRUCTIONS[Constants.ICONST_4] = ICONST_4;
    225       INSTRUCTIONS[Constants.ICONST_5] = ICONST_5;
    226       INSTRUCTIONS[Constants.LCONST_0] = LCONST_0;
    227       INSTRUCTIONS[Constants.LCONST_1] = LCONST_1;
    228       INSTRUCTIONS[Constants.FCONST_0] = FCONST_0;
    229       INSTRUCTIONS[Constants.FCONST_1] = FCONST_1;
    230       INSTRUCTIONS[Constants.FCONST_2] = FCONST_2;
    231       INSTRUCTIONS[Constants.DCONST_0] = DCONST_0;
    232       INSTRUCTIONS[Constants.DCONST_1] = DCONST_1;
    233       INSTRUCTIONS[Constants.IALOAD] = IALOAD;
    234       INSTRUCTIONS[Constants.LALOAD] = LALOAD;
    235       INSTRUCTIONS[Constants.FALOAD] = FALOAD;
    236       INSTRUCTIONS[Constants.DALOAD] = DALOAD;
    237       INSTRUCTIONS[Constants.AALOAD] = AALOAD;
    238       INSTRUCTIONS[Constants.BALOAD] = BALOAD;
    239       INSTRUCTIONS[Constants.CALOAD] = CALOAD;
    240       INSTRUCTIONS[Constants.SALOAD] = SALOAD;
    241       INSTRUCTIONS[Constants.IASTORE] = IASTORE;
    242       INSTRUCTIONS[Constants.LASTORE] = LASTORE;
    243       INSTRUCTIONS[Constants.FASTORE] = FASTORE;
    244       INSTRUCTIONS[Constants.DASTORE] = DASTORE;
    245       INSTRUCTIONS[Constants.AASTORE] = AASTORE;
    246       INSTRUCTIONS[Constants.BASTORE] = BASTORE;
    247       INSTRUCTIONS[Constants.CASTORE] = CASTORE;
    248       INSTRUCTIONS[Constants.SASTORE] = SASTORE;
    249       INSTRUCTIONS[Constants.POP] = POP;
    250       INSTRUCTIONS[Constants.POP2] = POP2;
    251       INSTRUCTIONS[Constants.DUP] = DUP;
    252       INSTRUCTIONS[Constants.DUP_X1] = DUP_X1;
    253       INSTRUCTIONS[Constants.DUP_X2] = DUP_X2;
    254       INSTRUCTIONS[Constants.DUP2] = DUP2;
    255       INSTRUCTIONS[Constants.DUP2_X1] = DUP2_X1;
    256       INSTRUCTIONS[Constants.DUP2_X2] = DUP2_X2;
    257       INSTRUCTIONS[Constants.SWAP] = SWAP;
    258       INSTRUCTIONS[Constants.IADD] = IADD;
    259       INSTRUCTIONS[Constants.LADD] = LADD;
    260       INSTRUCTIONS[Constants.FADD] = FADD;
    261       INSTRUCTIONS[Constants.DADD] = DADD;
    262       INSTRUCTIONS[Constants.ISUB] = ISUB;
    263       INSTRUCTIONS[Constants.LSUB] = LSUB;
    264       INSTRUCTIONS[Constants.FSUB] = FSUB;
    265       INSTRUCTIONS[Constants.DSUB] = DSUB;
    266       INSTRUCTIONS[Constants.IMUL] = IMUL;
    267       INSTRUCTIONS[Constants.LMUL] = LMUL;
    268       INSTRUCTIONS[Constants.FMUL] = FMUL;
    269       INSTRUCTIONS[Constants.DMUL] = DMUL;
    270       INSTRUCTIONS[Constants.IDIV] = IDIV;
    271       INSTRUCTIONS[Constants.LDIV] = LDIV;
    272       INSTRUCTIONS[Constants.FDIV] = FDIV;
    273       INSTRUCTIONS[Constants.DDIV] = DDIV;
    274       INSTRUCTIONS[Constants.IREM] = IREM;
    275       INSTRUCTIONS[Constants.LREM] = LREM;
    276       INSTRUCTIONS[Constants.FREM] = FREM;
    277       INSTRUCTIONS[Constants.DREM] = DREM;
    278       INSTRUCTIONS[Constants.INEG] = INEG;
    279       INSTRUCTIONS[Constants.LNEG] = LNEG;
    280       INSTRUCTIONS[Constants.FNEG] = FNEG;
    281       INSTRUCTIONS[Constants.DNEG] = DNEG;
    282       INSTRUCTIONS[Constants.ISHL] = ISHL;
    283       INSTRUCTIONS[Constants.LSHL] = LSHL;
    284       INSTRUCTIONS[Constants.ISHR] = ISHR;
    285       INSTRUCTIONS[Constants.LSHR] = LSHR;
    286       INSTRUCTIONS[Constants.IUSHR] = IUSHR;
    287       INSTRUCTIONS[Constants.LUSHR] = LUSHR;
    288       INSTRUCTIONS[Constants.IAND] = IAND;
    289       INSTRUCTIONS[Constants.LAND] = LAND;
    290       INSTRUCTIONS[Constants.IOR] = IOR;
    291       INSTRUCTIONS[Constants.LOR] = LOR;
    292       INSTRUCTIONS[Constants.IXOR] = IXOR;
    293       INSTRUCTIONS[Constants.LXOR] = LXOR;
    294       INSTRUCTIONS[Constants.I2L] = I2L;
    295       INSTRUCTIONS[Constants.I2F] = I2F;
    296       INSTRUCTIONS[Constants.I2D] = I2D;
    297       INSTRUCTIONS[Constants.L2I] = L2I;
    298       INSTRUCTIONS[Constants.L2F] = L2F;
    299       INSTRUCTIONS[Constants.L2D] = L2D;
    300       INSTRUCTIONS[Constants.F2I] = F2I;
    301       INSTRUCTIONS[Constants.F2L] = F2L;
    302       INSTRUCTIONS[Constants.F2D] = F2D;
    303       INSTRUCTIONS[Constants.D2I] = D2I;
    304       INSTRUCTIONS[Constants.D2L] = D2L;
    305       INSTRUCTIONS[Constants.D2F] = D2F;
    306       INSTRUCTIONS[Constants.I2B] = I2B;
    307       INSTRUCTIONS[Constants.I2C] = I2C;
    308       INSTRUCTIONS[Constants.I2S] = I2S;
    309       INSTRUCTIONS[Constants.LCMP] = LCMP;
    310       INSTRUCTIONS[Constants.FCMPL] = FCMPL;
    311       INSTRUCTIONS[Constants.FCMPG] = FCMPG;
    312       INSTRUCTIONS[Constants.DCMPL] = DCMPL;
    313       INSTRUCTIONS[Constants.DCMPG] = DCMPG;
    314       INSTRUCTIONS[Constants.IRETURN] = IRETURN;
    315       INSTRUCTIONS[Constants.LRETURN] = LRETURN;
    316       INSTRUCTIONS[Constants.FRETURN] = FRETURN;
    317       INSTRUCTIONS[Constants.DRETURN] = DRETURN;
    318       INSTRUCTIONS[Constants.ARETURN] = ARETURN;
    319       INSTRUCTIONS[Constants.RETURN] = RETURN;
    320       INSTRUCTIONS[Constants.ARRAYLENGTH] = ARRAYLENGTH;
    321       INSTRUCTIONS[Constants.ATHROW] = ATHROW;
    322       INSTRUCTIONS[Constants.MONITORENTER] = MONITORENTER;
    323       INSTRUCTIONS[Constants.MONITOREXIT] = MONITOREXIT;
    324     }
    325   }
    326 }

This page was automatically generated by Maven