jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SIPUSH.java
changeset 46174 5611d2529b49
parent 45853 bfa06be36a17
equal deleted inserted replaced
46173:5546b5710844 46174:5611d2529b49
    18  * limitations under the License.
    18  * limitations under the License.
    19  */
    19  */
    20 
    20 
    21 package com.sun.org.apache.bcel.internal.generic;
    21 package com.sun.org.apache.bcel.internal.generic;
    22 
    22 
    23 import java.io.*;
    23 import java.io.DataOutputStream;
       
    24 import java.io.IOException;
       
    25 
    24 import com.sun.org.apache.bcel.internal.util.ByteSequence;
    26 import com.sun.org.apache.bcel.internal.util.ByteSequence;
    25 
    27 
    26 /**
    28 /**
    27  * SIPUSH - Push short
    29  * SIPUSH - Push short
    28  *
    30  *
    29  * <PRE>Stack: ... -&gt; ..., value</PRE>
    31  * <PRE>Stack: ... -&gt; ..., value</PRE>
    30  *
    32  *
    31  * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    33  * @version $Id: SIPUSH.java 1747278 2016-06-07 17:28:43Z britter $
    32  */
    34  */
    33 public class SIPUSH extends Instruction implements ConstantPushInstruction {
    35 public class SIPUSH extends Instruction implements ConstantPushInstruction {
    34   private short b;
       
    35 
    36 
    36   /**
    37     private short b;
    37    * Empty constructor needed for the Class.newInstance() statement in
       
    38    * Instruction.readInstruction(). Not to be used otherwise.
       
    39    */
       
    40   SIPUSH() {}
       
    41 
    38 
    42   public SIPUSH(short b) {
       
    43     super(com.sun.org.apache.bcel.internal.Constants.SIPUSH, (short)3);
       
    44     this.b = b;
       
    45   }
       
    46 
    39 
    47   /**
    40     /**
    48    * Dump instruction as short code to stream out.
    41      * Empty constructor needed for the Class.newInstance() statement in
    49    */
    42      * Instruction.readInstruction(). Not to be used otherwise.
    50   public void dump(DataOutputStream out) throws IOException {
    43      */
    51     super.dump(out);
    44     SIPUSH() {
    52     out.writeShort(b);
    45     }
    53   }
       
    54 
    46 
    55   /**
       
    56    * @return mnemonic for instruction
       
    57    */
       
    58   public String toString(boolean verbose) {
       
    59     return super.toString(verbose) + " " + b;
       
    60   }
       
    61 
    47 
    62   /**
    48     public SIPUSH(final short b) {
    63    * Read needed data (e.g. index) from file.
    49         super(com.sun.org.apache.bcel.internal.Const.SIPUSH, (short) 3);
    64    */
    50         this.b = b;
    65   protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
    51     }
    66   {
       
    67     length = 3;
       
    68     b      = bytes.readShort();
       
    69   }
       
    70 
    52 
    71   public Number getValue() { return Integer.valueOf(b); }
       
    72 
    53 
    73   /** @return Type.SHORT
    54     /**
    74    */
    55      * Dump instruction as short code to stream out.
    75   public Type getType(ConstantPoolGen cp) {
    56      */
    76     return Type.SHORT;
    57     @Override
    77   }
    58     public void dump( final DataOutputStream out ) throws IOException {
       
    59         super.dump(out);
       
    60         out.writeShort(b);
       
    61     }
    78 
    62 
    79   /**
    63 
    80    * Call corresponding visitor method(s). The order is:
    64     /**
    81    * Call visitor methods of implemented interfaces first, then
    65      * @return mnemonic for instruction
    82    * call methods according to the class hierarchy in descending order,
    66      */
    83    * i.e., the most specific visitXXX() call comes last.
    67     @Override
    84    *
    68     public String toString( final boolean verbose ) {
    85    * @param v Visitor object
    69         return super.toString(verbose) + " " + b;
    86    */
    70     }
    87   public void accept(Visitor v) {
    71 
    88     v.visitPushInstruction(this);
    72 
    89     v.visitStackProducer(this);
    73     /**
    90     v.visitTypedInstruction(this);
    74      * Read needed data (e.g. index) from file.
    91     v.visitConstantPushInstruction(this);
    75      */
    92     v.visitSIPUSH(this);
    76     @Override
    93   }
    77     protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
       
    78         super.setLength(3);
       
    79         b = bytes.readShort();
       
    80     }
       
    81 
       
    82 
       
    83     @Override
       
    84     public Number getValue() {
       
    85         return Integer.valueOf(b);
       
    86     }
       
    87 
       
    88 
       
    89     /** @return Type.SHORT
       
    90      */
       
    91     @Override
       
    92     public Type getType( final ConstantPoolGen cp ) {
       
    93         return Type.SHORT;
       
    94     }
       
    95 
       
    96 
       
    97     /**
       
    98      * Call corresponding visitor method(s). The order is:
       
    99      * Call visitor methods of implemented interfaces first, then
       
   100      * call methods according to the class hierarchy in descending order,
       
   101      * i.e., the most specific visitXXX() call comes last.
       
   102      *
       
   103      * @param v Visitor object
       
   104      */
       
   105     @Override
       
   106     public void accept( final Visitor v ) {
       
   107         v.visitPushInstruction(this);
       
   108         v.visitStackProducer(this);
       
   109         v.visitTypedInstruction(this);
       
   110         v.visitConstantPushInstruction(this);
       
   111         v.visitSIPUSH(this);
       
   112     }
    94 }
   113 }