00001 package gov.nasa.arc.ase.jpf.jvm.bytecode;
00002
00003 import de.fub.bytecode.classfile.Constant;
00004 import de.fub.bytecode.classfile.ConstantPool;
00005 import de.fub.bytecode.Constants;
00006 import de.fub.bytecode.generic.ConstantPoolGen;
00007 import de.fub.bytecode.generic.InstructionHandle;
00008 import gov.nasa.arc.ase.jpf.*;
00009 import gov.nasa.arc.ase.jpf.jvm.*;
00010 import gov.nasa.arc.ase.util.Debug;
00011
00012 public class ANEWARRAY extends AbstractInstruction {
00013 private de.fub.bytecode.generic.ANEWARRAY peer;
00014
00015 public InstructionHandle execute(SystemState ss, KernelState ks, ThreadInfo th) {
00016 StaticArea sa = ks.static_area;
00017 DynamicArea da = ks.dynamic_area;
00018 ConstantPoolGen cpg = th.getCPG();
00019 ConstantPool cp = cpg.getConstantPool();
00020 Constant constant = cp.getConstant(peer.getIndex());
00021 String classname = cp.constantToString(constant);
00022
00023
00024 int size = th.pop();
00025 int objref;
00026
00027
00028 if(!classname.startsWith("["))
00029 classname = "L" + classname + ";";
00030
00031 objref = da.newArrayObject(classname, size, th);
00032
00033
00034 th.push(objref);
00035
00036 th.setOperandRef();
00037
00038
00039 return th.getPC().getNext();
00040 }
00041 public void setPeer(de.fub.bytecode.generic.Instruction i) {
00042 peer = (de.fub.bytecode.generic.ANEWARRAY)i;
00043 }
00044 }