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

LDC2_W.java

00001 package de.fub.bytecode.generic;
00002 
00003 /** 
00004  * LDC2_W - Push long or double from constant pool
00005  *
00006  * <PRE>Stack: ... -&gt; ..., item.word1, item.word2</PRE>
00007  *
00008  * @version $Id: LDC2_W.java,v 1.1.1.1 2002/01/24 03:41:41 pserver Exp $
00009  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00010  */
00011 public class LDC2_W extends CPInstruction
00012   implements PushInstruction, TypedInstruction {
00013   /**
00014    * Empty constructor needed for the Class.newInstance() statement in
00015    * Instruction.readInstruction(). Not to be used otherwise.
00016    */
00017   LDC2_W() {}  
00018   public LDC2_W(int index) {
00019     super(de.fub.bytecode.Constants.LDC2_W, index);
00020   }  
00021   /**
00022    * Call corresponding visitor method(s). The order is:
00023    * Call visitor methods of implemented interfaces first, then
00024    * call methods according to the class hierarchy in descending order,
00025    * i.e., the most specific visitXXX() call comes last.
00026    *
00027    * @param v Visitor object
00028    */
00029   public void accept(Visitor v) {
00030     v.visitStackProducer(this);
00031     v.visitPushInstruction(this);
00032     v.visitTypedInstruction(this);
00033     v.visitCPInstruction(this);
00034     v.visitLDC2_W(this);
00035   }  
00036   public Type getType(ConstantPoolGen cpg) {
00037     switch(cpg.getConstantPool().getConstant(index).getTag()) {
00038     case de.fub.bytecode.Constants.CONSTANT_Long:   return Type.LONG;
00039     case de.fub.bytecode.Constants.CONSTANT_Double: return Type.DOUBLE;
00040     default: // Never reached
00041       throw new RuntimeException("Unknown constant type " + tag);
00042     }
00043   }  
00044   public Number getValue(ConstantPoolGen cpg) {
00045     de.fub.bytecode.classfile.Constant c = cpg.getConstantPool().getConstant(index);
00046 
00047     switch(c.getTag()) {
00048     case de.fub.bytecode.Constants.CONSTANT_Long:
00049     return new Long(((de.fub.bytecode.classfile.ConstantLong)c).getBytes());
00050 
00051     case de.fub.bytecode.Constants.CONSTANT_Double:
00052     return new Double(((de.fub.bytecode.classfile.ConstantDouble)c).getBytes());
00053 
00054     default: // Never reached
00055       throw new RuntimeException("Unknown or invalid constant type at " + index);
00056       }
00057   }  
00058 }

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