GOTO_W xref

View Javadoc

    1   /*
    2    * Copyright  2000-2004 The Apache Software Foundation
    3    *
    4    *  Licensed under the Apache License, Version 2.0 (the "License");
    5    *  you may not use this file except in compliance with the License.
    6    *  You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   *  Unless required by applicable law or agreed to in writing, software
    11   *  distributed under the License is distributed on an "AS IS" BASIS,
    12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   *  See the License for the specific language governing permissions and
    14   *  limitations under the License.
    15   *
    16   */
    17  package org.apache.bcel.generic;
    18
    19  import java.io.DataOutputStream;
    20  import java.io.IOException;
    21  import org.apache.bcel.util.ByteSequence;
    22
    23  /***
    24   * GOTO_W - Branch always (to relative offset, not absolute address)
    25   *
    26   * @version $Id: GOTO_W.java 386056 2006-03-15 11:31:56Z tcurdt $
    27   * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
    28   */
    29  public class GOTO_W extends GotoInstruction {
    30
    31      /***
    32       * Empty constructor needed for the Class.newInstance() statement in
    33       * Instruction.readInstruction(). Not to be used otherwise.
    34       */
    35      GOTO_W() {
    36      }
    37
    38
    39      public GOTO_W(InstructionHandle target) {
    40          super(org.apache.bcel.Constants.GOTO_W, target);
    41          length = 5;
    42      }
    43
    44
    45      /***
    46       * Dump instruction as byte code to stream out.
    47       * @param out Output stream
    48       */
    49      public void dump( DataOutputStream out ) throws IOException {
    50          index = getTargetOffset();
    51          out.writeByte(opcode);
    52          out.writeInt(index);
    53      }
    54
    55
    56      /***
    57       * Read needed data (e.g. index) from file.
    58       */
    59      protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
    60          index = bytes.readInt();
    61          length = 5;
    62      }
    63
    64
    65      /***
    66       * Call corresponding visitor method(s). The order is:
    67       * Call visitor methods of implemented interfaces first, then
    68       * call methods according to the class hierarchy in descending order,
    69       * i.e., the most specific visitXXX() call comes last.
    70       *
    71       * @param v Visitor object
    72       */
    73      public void accept( Visitor v ) {
    74          v.visitUnconditionalBranch(this);
    75          v.visitBranchInstruction(this);
    76          v.visitGotoInstruction(this);
    77          v.visitGOTO_W(this);
    78      }
    79  }