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:44:03 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(JSR, target);
00019   }  
00020   /**
00021    * Dump instruction as byte code to stream out.
00022    * @param out Output stream
00023    */
00024   public void dump(DataOutputStream out) throws IOException {
00025     index = getTargetOffset();
00026     if(tag == JSR)
00027       super.dump(out);
00028     else { // JSR_W
00029       index = getTargetOffset();
00030       out.writeByte(tag);
00031       out.writeInt(index);
00032     }
00033   }  
00034   protected int updatePosition(int offset, int max_offset) {
00035     int i = getTargetOffset(); // Depending on old position value
00036 
00037     position += offset; // Position may be shifted by preceding expansions
00038 
00039     if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate)
00040       tag    = JSR_W;
00041       length = 5;
00042       return 2; // 5 - 3
00043     }
00044 
00045     return 0;
00046   }  
00047 }

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