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

LDC_W.java

00001 package gov.nasa.arc.ase.jpf.jvm.bytecode;
00002 
00003 import gov.nasa.arc.ase.jpf.*;
00004 import gov.nasa.arc.ase.jpf.jvm.*;
00005 import de.fub.bytecode.classfile.ConstantPool;
00006 import de.fub.bytecode.classfile.Constant;
00007 import de.fub.bytecode.classfile.ConstantFloat;
00008 import de.fub.bytecode.classfile.ConstantString;
00009 import de.fub.bytecode.classfile.ConstantInteger;
00010 import de.fub.bytecode.generic.Type;
00011 import de.fub.bytecode.generic.ConstantPoolGen;
00012 import de.fub.bytecode.generic.InstructionHandle;
00013 import gov.nasa.arc.ase.util.Debug;
00014 
00015 public class LDC_W extends AbstractInstruction {
00016   private de.fub.bytecode.generic.LDC_W peer;
00017 
00018   public InstructionHandle execute(SystemState ss, KernelState ks, ThreadInfo th) {
00019     ConstantPoolGen cpg = th.getCPG();
00020     ConstantPool cp = cpg.getConstantPool();
00021     Constant cons = cp.getConstant(peer.getIndex());
00022 
00023     if (peer.getType(cpg) == Type.STRING) {
00024       // loads the constant string
00025       int index = ((ConstantString)cons).getStringIndex();
00026       Constant c = cp.getConstant(index);
00027       String str =  cp.constantToString(c);
00028 
00029       // creates a string object
00030       int objref = ks.dynamic_area.newStringObject(str, th);
00031 
00032       // pushes the object reference onto the stack
00033       th.push(objref);
00034 // ifdef MARK_N_SWEEP
00035       th.setOperandRef();
00036 //#endif MARK_N_SWEEP
00037     } else if (peer.getType(cpg) == Type.INT) {
00038       // loads the constant value
00039       int value = ((ConstantInteger)cons).getBytes();
00040 
00041       // pushes the value onto the stack
00042       th.push(value);
00043     } else {
00044       // loads the constant value
00045       float value = ((ConstantFloat)cons).getBytes();
00046 
00047       // pushes the value onto the stack
00048       th.push(Types.floatToInt(value));
00049     }
00050 
00051     return th.getPC().getNext();
00052   }  
00053   public void setPeer(de.fub.bytecode.generic.Instruction i) {
00054     peer = (de.fub.bytecode.generic.LDC_W)i;
00055   }  
00056 }

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