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

MULTIANEWARRAY.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.Constants;
00006 import de.fub.bytecode.classfile.Constant;
00007 import de.fub.bytecode.classfile.ConstantPool;
00008 import de.fub.bytecode.generic.ConstantPoolGen;
00009 import de.fub.bytecode.generic.InstructionHandle;
00010 import gov.nasa.arc.ase.util.Debug;
00011 
00012 public class MULTIANEWARRAY extends AbstractInstruction {
00013   private de.fub.bytecode.generic.MULTIANEWARRAY peer;
00014 
00015   public InstructionHandle execute(SystemState ss, KernelState ks, ThreadInfo th) {
00016     JPFVM jpfvm = JPFVM.getJPFVM();
00017 
00018     ConstantPoolGen cpg = th.getCPG();
00019     ConstantPool cp = cpg.getConstantPool();
00020     Constant constant = cp.getConstant(peer.getIndex());
00021 
00022     // type of the array to be constructed
00023     String typename =  cp.constantToString(constant);
00024 
00025     // number of dimensions
00026     int ndim = peer.getDimensions();
00027     int[] dim = new int[ndim];
00028 
00029     for(int i= 0; i < ndim; i++) {
00030       // gets from the stack each dimension
00031       dim[i] = th.pop();
00032     }
00033 
00034     DynamicArea da = ks.dynamic_area;
00035 
00036     int arrayref = da.newArrayObject(typename.substring(1), dim[0], th);
00037 
00038     // put the result (the array reference) on the stack
00039     th.push(arrayref);
00040 // ifdef MARK_N_SWEEP
00041     th.setOperandRef();
00042 //#endif MARK_N_SWEEP
00043 
00044     // we still have to allocate the space for it tough
00045     for(int i = 1; i < ndim; i++) {
00046       for(int j = 0, s = dim[i-1]; j < s; j++) {
00047     int objref = da.newArrayObject(typename.substring(i+1), dim[i], th);
00048 
00049     da.setValue(arrayref, j, objref);
00050       }
00051     }
00052 
00053     return th.getPC().getNext();
00054   }  
00055   public void setPeer(de.fub.bytecode.generic.Instruction i) {
00056     peer = (de.fub.bytecode.generic.MULTIANEWARRAY)i;
00057   }  
00058 }

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