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 de.fub.bytecode.classfile.ConstantPool;
00004 import gov.nasa.arc.ase.jpf.jvm.SystemState;
00005 import gov.nasa.arc.ase.jpf.jvm.KernelState;
00006 import gov.nasa.arc.ase.jpf.jvm.ThreadInfo;
00007 import gov.nasa.arc.ase.jpf.jvm.ElementInfo;
00008 import gov.nasa.arc.ase.jpf.InternalErrorException;
00009 import gov.nasa.arc.ase.util.Debug;
00010 
00011 public class MULTIANEWARRAY extends Instruction {
00012   private String type;
00013   private int dimensions;
00014 
00015   public int allocateArray(String type, int[] dim, ThreadInfo th, int d) {
00016     int l = dim[d++];
00017     int arrayRef = th.list.ks.da.newArray(type.substring(d), l, th);
00018     ElementInfo e = th.list.ks.da.get(arrayRef);
00019 
00020     if(dim.length > d)
00021       for(int i = 0; i < l; i++)
00022     e.setField(i, allocateArray(type, dim, th, d));
00023     else
00024       for(int i = 0; i < l; i++)
00025     e.setField(i, -1);
00026 
00027     return arrayRef;
00028   }  
00029   public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
00030     int[] dim = new int[dimensions];
00031 
00032     for(int i = dimensions - 1; i >= 0; i--)
00033       dim[i] = th.pop();
00034 
00035     int arrayRef = allocateArray(type, dim, th, 0);
00036 
00037     // put the result (the array reference) on the stack
00038     th.push(arrayRef, true);
00039 
00040     return th.getPC().getNext();
00041   }  
00042   public void setPeer(de.fub.bytecode.generic.Instruction i, ConstantPool cp) {
00043     type = cp.constantToString(cp.getConstant(((de.fub.bytecode.generic.MULTIANEWARRAY)i).getIndex()));
00044     dimensions = ((de.fub.bytecode.generic.MULTIANEWARRAY)i).getDimensions();
00045   }  
00046 }

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