< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java

Print this page




   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.bcel.internal.generic;
  22 
  23 /**
  24  * LDC2_W - Push long or double from constant pool
  25  *
  26  * <PRE>Stack: ... -&gt; ..., item.word1, item.word2</PRE>
  27  *
  28  * @version $Id: LDC2_W.java 1749603 2016-06-21 20:50:19Z ggregory $

  29  */
  30 public class LDC2_W extends CPInstruction implements PushInstruction {
  31 
  32     /**
  33      * Empty constructor needed for the Class.newInstance() statement in
  34      * Instruction.readInstruction(). Not to be used otherwise.
  35      */
  36     LDC2_W() {
  37     }
  38 
  39 
  40     public LDC2_W(final int index) {
  41         super(com.sun.org.apache.bcel.internal.Const.LDC2_W, index);
  42     }
  43 
  44 
  45     @Override
  46     public Type getType( final ConstantPoolGen cpg ) {
  47         switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) {
  48             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
  49                 return Type.LONG;
  50             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
  51                 return Type.DOUBLE;
  52             default: // Never reached
  53                 throw new RuntimeException("Unknown constant type " + super.getOpcode());
  54         }
  55     }
  56 
  57 
  58     public Number getValue( final ConstantPoolGen cpg ) {
  59         final com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex());
  60         switch (c.getTag()) {
  61             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
  62                 return Long.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes());
  63             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
  64                 return new Double(((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes());
  65             default: // Never reached
  66                 throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex());
  67         }
  68     }
  69 
  70 
  71     /**
  72      * Call corresponding visitor method(s). The order is:
  73      * Call visitor methods of implemented interfaces first, then
  74      * call methods according to the class hierarchy in descending order,
  75      * i.e., the most specific visitXXX() call comes last.
  76      *
  77      * @param v Visitor object
  78      */
  79     @Override
  80     public void accept( final Visitor v ) {
  81         v.visitStackProducer(this);
  82         v.visitPushInstruction(this);
  83         v.visitTypedInstruction(this);
  84         v.visitCPInstruction(this);


   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.bcel.internal.generic;
  22 
  23 /**
  24  * LDC2_W - Push long or double from constant pool
  25  *
  26  * <PRE>Stack: ... -&gt; ..., item.word1, item.word2</PRE>
  27  *
  28  * @version $Id: LDC2_W.java 1749603 2016-06-21 20:50:19Z ggregory $
  29  * @LastModified: Nov 2017
  30  */
  31 public class LDC2_W extends CPInstruction implements PushInstruction {
  32 
  33     /**
  34      * Empty constructor needed for the Class.newInstance() statement in
  35      * Instruction.readInstruction(). Not to be used otherwise.
  36      */
  37     LDC2_W() {
  38     }
  39 
  40 
  41     public LDC2_W(final int index) {
  42         super(com.sun.org.apache.bcel.internal.Const.LDC2_W, index);
  43     }
  44 
  45 
  46     @Override
  47     public Type getType( final ConstantPoolGen cpg ) {
  48         switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) {
  49             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
  50                 return Type.LONG;
  51             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
  52                 return Type.DOUBLE;
  53             default: // Never reached
  54                 throw new RuntimeException("Unknown constant type " + super.getOpcode());
  55         }
  56     }
  57 
  58 
  59     public Number getValue( final ConstantPoolGen cpg ) {
  60         final com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex());
  61         switch (c.getTag()) {
  62             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
  63                 return ((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes();
  64             case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
  65                 return ((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes();
  66             default: // Never reached
  67                 throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex());
  68         }
  69     }
  70 
  71 
  72     /**
  73      * Call corresponding visitor method(s). The order is:
  74      * Call visitor methods of implemented interfaces first, then
  75      * call methods according to the class hierarchy in descending order,
  76      * i.e., the most specific visitXXX() call comes last.
  77      *
  78      * @param v Visitor object
  79      */
  80     @Override
  81     public void accept( final Visitor v ) {
  82         v.visitStackProducer(this);
  83         v.visitPushInstruction(this);
  84         v.visitTypedInstruction(this);
  85         v.visitCPInstruction(this);
< prev index next >