InstructionConstants.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  *  Unless required by applicable law or agreed to in writing, software
  12.  *  distributed under the License is distributed on an "AS IS" BASIS,
  13.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  *  See the License for the specific language governing permissions and
  15.  *  limitations under the License.
  16.  */
  17. package org.apache.bcel.generic;

  18. /**
  19.  * Contains shareable instruction objects.
  20.  * <p>
  21.  * In order to save memory you can use some instructions multiply, since they have an immutable state and are directly
  22.  * derived from Instruction. I.e. they have no instance fields that could be changed. Since some of these instructions
  23.  * like ICONST_0 occur very frequently this can save a lot of time and space. This feature is an adaptation of the
  24.  * FlyWeight design pattern, we just use an array instead of a factory.
  25.  * </p>
  26.  * <p>
  27.  * The Instructions can also accessed directly under their names, so it's possible to write
  28.  * il.append(Instruction.ICONST_0);
  29.  * </p>
  30.  *
  31.  * @deprecated (since 6.0) Do not use. Use {@link InstructionConst} instead.
  32.  */
  33. @Deprecated
  34. public interface InstructionConstants {

  35.     /**
  36.      * Deprecated, consider private and ignore.
  37.      */
  38.     class Clinit {
  39.         // empty
  40.     }

  41.     /*
  42.      * NOTE these are not currently immutable, because Instruction has mutable protected fields opcode and length.
  43.      */
  44.     Instruction NOP = InstructionConst.NOP;
  45.     Instruction ACONST_NULL = InstructionConst.ACONST_NULL;
  46.     Instruction ICONST_M1 = InstructionConst.ICONST_M1;
  47.     Instruction ICONST_0 = InstructionConst.ICONST_0;
  48.     Instruction ICONST_1 = InstructionConst.ICONST_1;
  49.     Instruction ICONST_2 = InstructionConst.ICONST_2;
  50.     Instruction ICONST_3 = InstructionConst.ICONST_3;
  51.     Instruction ICONST_4 = InstructionConst.ICONST_4;
  52.     Instruction ICONST_5 = InstructionConst.ICONST_5;
  53.     Instruction LCONST_0 = InstructionConst.LCONST_0;
  54.     Instruction LCONST_1 = InstructionConst.LCONST_1;
  55.     Instruction FCONST_0 = InstructionConst.FCONST_0;
  56.     Instruction FCONST_1 = InstructionConst.FCONST_1;
  57.     Instruction FCONST_2 = InstructionConst.FCONST_2;
  58.     Instruction DCONST_0 = InstructionConst.DCONST_0;
  59.     Instruction DCONST_1 = InstructionConst.DCONST_1;
  60.     ArrayInstruction IALOAD = InstructionConst.IALOAD;
  61.     ArrayInstruction LALOAD = InstructionConst.LALOAD;
  62.     ArrayInstruction FALOAD = InstructionConst.FALOAD;
  63.     ArrayInstruction DALOAD = InstructionConst.DALOAD;
  64.     ArrayInstruction AALOAD = InstructionConst.AALOAD;
  65.     ArrayInstruction BALOAD = InstructionConst.BALOAD;
  66.     ArrayInstruction CALOAD = InstructionConst.CALOAD;
  67.     ArrayInstruction SALOAD = InstructionConst.SALOAD;
  68.     ArrayInstruction IASTORE = InstructionConst.IASTORE;
  69.     ArrayInstruction LASTORE = InstructionConst.LASTORE;
  70.     ArrayInstruction FASTORE = InstructionConst.FASTORE;
  71.     ArrayInstruction DASTORE = InstructionConst.DASTORE;
  72.     ArrayInstruction AASTORE = InstructionConst.AASTORE;
  73.     ArrayInstruction BASTORE = InstructionConst.BASTORE;
  74.     ArrayInstruction CASTORE = InstructionConst.CASTORE;
  75.     ArrayInstruction SASTORE = InstructionConst.SASTORE;
  76.     StackInstruction POP = InstructionConst.POP;
  77.     StackInstruction POP2 = InstructionConst.POP2;
  78.     StackInstruction DUP = InstructionConst.DUP;
  79.     StackInstruction DUP_X1 = InstructionConst.DUP_X1;
  80.     StackInstruction DUP_X2 = InstructionConst.DUP_X2;
  81.     StackInstruction DUP2 = InstructionConst.DUP2;
  82.     StackInstruction DUP2_X1 = InstructionConst.DUP2_X1;
  83.     StackInstruction DUP2_X2 = InstructionConst.DUP2_X2;
  84.     StackInstruction SWAP = InstructionConst.SWAP;
  85.     ArithmeticInstruction IADD = InstructionConst.IADD;
  86.     ArithmeticInstruction LADD = InstructionConst.LADD;
  87.     ArithmeticInstruction FADD = InstructionConst.FADD;
  88.     ArithmeticInstruction DADD = InstructionConst.DADD;
  89.     ArithmeticInstruction ISUB = InstructionConst.ISUB;
  90.     ArithmeticInstruction LSUB = InstructionConst.LSUB;
  91.     ArithmeticInstruction FSUB = InstructionConst.FSUB;
  92.     ArithmeticInstruction DSUB = InstructionConst.DSUB;
  93.     ArithmeticInstruction IMUL = InstructionConst.IMUL;
  94.     ArithmeticInstruction LMUL = InstructionConst.LMUL;
  95.     ArithmeticInstruction FMUL = InstructionConst.FMUL;
  96.     ArithmeticInstruction DMUL = InstructionConst.DMUL;
  97.     ArithmeticInstruction IDIV = InstructionConst.IDIV;
  98.     ArithmeticInstruction LDIV = InstructionConst.LDIV;
  99.     ArithmeticInstruction FDIV = InstructionConst.FDIV;
  100.     ArithmeticInstruction DDIV = InstructionConst.DDIV;
  101.     ArithmeticInstruction IREM = InstructionConst.IREM;
  102.     ArithmeticInstruction LREM = InstructionConst.LREM;
  103.     ArithmeticInstruction FREM = InstructionConst.FREM;
  104.     ArithmeticInstruction DREM = InstructionConst.DREM;
  105.     ArithmeticInstruction INEG = InstructionConst.INEG;
  106.     ArithmeticInstruction LNEG = InstructionConst.LNEG;
  107.     ArithmeticInstruction FNEG = InstructionConst.FNEG;
  108.     ArithmeticInstruction DNEG = InstructionConst.DNEG;
  109.     ArithmeticInstruction ISHL = InstructionConst.ISHL;
  110.     ArithmeticInstruction LSHL = InstructionConst.LSHL;
  111.     ArithmeticInstruction ISHR = InstructionConst.ISHR;
  112.     ArithmeticInstruction LSHR = InstructionConst.LSHR;
  113.     ArithmeticInstruction IUSHR = InstructionConst.IUSHR;
  114.     ArithmeticInstruction LUSHR = InstructionConst.LUSHR;
  115.     ArithmeticInstruction IAND = InstructionConst.IAND;
  116.     ArithmeticInstruction LAND = InstructionConst.LAND;
  117.     ArithmeticInstruction IOR = InstructionConst.IOR;
  118.     ArithmeticInstruction LOR = InstructionConst.LOR;
  119.     ArithmeticInstruction IXOR = InstructionConst.IXOR;
  120.     ArithmeticInstruction LXOR = InstructionConst.LXOR;
  121.     ConversionInstruction I2L = InstructionConst.I2L;
  122.     ConversionInstruction I2F = InstructionConst.I2F;
  123.     ConversionInstruction I2D = InstructionConst.I2D;
  124.     ConversionInstruction L2I = InstructionConst.L2I;
  125.     ConversionInstruction L2F = InstructionConst.L2F;
  126.     ConversionInstruction L2D = InstructionConst.L2D;
  127.     ConversionInstruction F2I = InstructionConst.F2I;
  128.     ConversionInstruction F2L = InstructionConst.F2L;
  129.     ConversionInstruction F2D = InstructionConst.F2D;
  130.     ConversionInstruction D2I = InstructionConst.D2I;
  131.     ConversionInstruction D2L = InstructionConst.D2L;
  132.     ConversionInstruction D2F = InstructionConst.D2F;
  133.     ConversionInstruction I2B = InstructionConst.I2B;
  134.     ConversionInstruction I2C = InstructionConst.I2C;
  135.     ConversionInstruction I2S = InstructionConst.I2S;
  136.     Instruction LCMP = InstructionConst.LCMP;
  137.     Instruction FCMPL = InstructionConst.FCMPL;
  138.     Instruction FCMPG = InstructionConst.FCMPG;
  139.     Instruction DCMPL = InstructionConst.DCMPL;
  140.     Instruction DCMPG = InstructionConst.DCMPG;
  141.     ReturnInstruction IRETURN = InstructionConst.IRETURN;
  142.     ReturnInstruction LRETURN = InstructionConst.LRETURN;
  143.     ReturnInstruction FRETURN = InstructionConst.FRETURN;
  144.     ReturnInstruction DRETURN = InstructionConst.DRETURN;
  145.     ReturnInstruction ARETURN = InstructionConst.ARETURN;
  146.     ReturnInstruction RETURN = InstructionConst.RETURN;
  147.     Instruction ARRAYLENGTH = InstructionConst.ARRAYLENGTH;
  148.     Instruction ATHROW = InstructionConst.ATHROW;
  149.     Instruction MONITORENTER = InstructionConst.MONITORENTER;
  150.     Instruction MONITOREXIT = InstructionConst.MONITOREXIT;

  151.     /**
  152.      * You can use these constants in multiple places safely, if you can guarantee that you will never alter their internal
  153.      * values, e.g. call setIndex().
  154.      */
  155.     LocalVariableInstruction THIS = InstructionConst.THIS;
  156.     LocalVariableInstruction ALOAD_0 = InstructionConst.ALOAD_0;
  157.     LocalVariableInstruction ALOAD_1 = InstructionConst.ALOAD_1;
  158.     LocalVariableInstruction ALOAD_2 = InstructionConst.ALOAD_2;
  159.     LocalVariableInstruction ILOAD_0 = InstructionConst.ILOAD_0;
  160.     LocalVariableInstruction ILOAD_1 = InstructionConst.ILOAD_1;
  161.     LocalVariableInstruction ILOAD_2 = InstructionConst.ILOAD_2;
  162.     LocalVariableInstruction ASTORE_0 = InstructionConst.ASTORE_0;
  163.     LocalVariableInstruction ASTORE_1 = InstructionConst.ASTORE_1;
  164.     LocalVariableInstruction ASTORE_2 = InstructionConst.ASTORE_2;
  165.     LocalVariableInstruction ISTORE_0 = InstructionConst.ISTORE_0;
  166.     LocalVariableInstruction ISTORE_1 = InstructionConst.ISTORE_1;
  167.     LocalVariableInstruction ISTORE_2 = InstructionConst.ISTORE_2;

  168.     /**
  169.      * Gets object via its opcode, for immutable instructions like branch instructions entries are set to null.
  170.      */
  171.     Instruction[] INSTRUCTIONS = InstructionConst.INSTRUCTIONS;

  172.     /**
  173.      * Interfaces may have no static initializers, so we simulate this with an inner class.
  174.      */
  175.     Clinit bla = new Clinit();
  176. }