Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

JSR.java

00001 package de.fub.bytecode.generic;
00002 
00003 import java.io.*;
00004 
00005 /** 
00006  * JSR - Jump to subroutine
00007  *
00008  * @version $Id: JSR.java,v 1.1.1.1 2002/01/24 03:41:40 pserver Exp $
00009  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00010  */
00011 public class JSR extends BranchInstruction implements VariableLengthInstruction {
00012   /**
00013    * Empty constructor needed for the Class.newInstance() statement in
00014    * Instruction.readInstruction(). Not to be used otherwise.
00015    */
00016   JSR() {}  
00017   public JSR(InstructionHandle target) {
00018     super(de.fub.bytecode.Constants.JSR, target);
00019   }  
00020   /**
00021    * Call corresponding visitor method(s). The order is:
00022    * Call visitor methods of implemented interfaces first, then
00023    * call methods according to the class hierarchy in descending order,
00024    * i.e., the most specific visitXXX() call comes last.
00025    *
00026    * @param v Visitor object
00027    */
00028   public void accept(Visitor v) {
00029     v.visitVariableLengthInstruction(this);
00030     v.visitInstructionTargeter(this);
00031     v.visitBranchInstruction(this);
00032     v.visitJSR(this);
00033   }  
00034   /**
00035    * Dump instruction as byte code to stream out.
00036    * @param out Output stream
00037    */
00038   public void dump(DataOutputStream out) throws IOException {
00039     index = getTargetOffset();
00040     if(tag == de.fub.bytecode.Constants.JSR)
00041       super.dump(out);
00042     else { // JSR_W
00043       index = getTargetOffset();
00044       out.writeByte(tag);
00045       out.writeInt(index);
00046     }
00047   }  
00048   protected int updatePosition(int offset, int max_offset) {
00049     int i = getTargetOffset(); // Depending on old position value
00050 
00051     position += offset; // Position may be shifted by preceding expansions
00052 
00053     if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate)
00054       tag    = de.fub.bytecode.Constants.JSR_W;
00055       length = 5;
00056       return 2; // 5 - 3
00057     }
00058 
00059     return 0;
00060   }  
00061 }

Generated at Thu Feb 7 06:48:59 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001