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

State.java

00001 package gov.nasa.arc.ase.jpf.jvm.examine;
00002 
00003 import gov.nasa.arc.ase.jpf.jvm.SystemState;
00004 import gov.nasa.arc.ase.jpf.jvm.VirtualMachine;
00005 import gov.nasa.arc.ase.jpf.jvm.Types;
00006 import gov.nasa.arc.ase.jpf.jvm.ElementInfo;
00007 import gov.nasa.arc.ase.jpf.jvm.ThreadInfo;
00008 
00009 public class State implements iState {
00010   private SystemState ss;
00011 
00012   public State() {
00013     ss = VirtualMachine.getSS();
00014   }  
00015   public static iValue createValue(String type, long value, SystemState ss) {
00016     switch(Types.getBaseType(type)) {
00017       case Types.T_BYTE: return new ByteValue((byte)value);
00018       case Types.T_CHAR: return new CharValue((char)value);
00019       case Types.T_DOUBLE: return new DoubleValue(Types.longToDouble(value));
00020       case Types.T_FLOAT: return new FloatValue(Types.intToFloat((int)value));
00021       case Types.T_INT: return new IntValue((int)value);
00022       case Types.T_LONG: return new LongValue(value);
00023       case Types.T_REFERENCE: return new ObjectValue((int)value, ss);
00024       case Types.T_SHORT: return new ShortValue((short)value);
00025       case Types.T_BOOLEAN: return new BoolValue(Types.intToBoolean((int)value));
00026       case Types.T_ARRAY: return new ArrayValue((int)value, ss);
00027     }
00028 
00029     return null;
00030   }  
00031   public iMethodState getMethodState(int threadNumber) {
00032     return new MethodState((ThreadInfo)ss.getThreadInfo(threadNumber));
00033   }  
00034   public iValue getStaticFieldValue(String className, String fieldName) {
00035     ElementInfo e = ss.ks.sa.get(className);
00036 
00037     if(Types.getTypeSize(e.getFieldType(fieldName)) == 1)
00038       return State.createValue(e.getFieldType(fieldName), e.getField(fieldName), ss);
00039     else
00040       return State.createValue(e.getFieldType(fieldName), e.getLongField(fieldName), ss);
00041   }  
00042   public boolean isActive(int threadNumber) {
00043     return ((ThreadInfo)ss.getThreadInfo(threadNumber)).isAlive();  
00044   }  
00045   public boolean isLoaded(String className) {
00046     return ss.ks.sa.get(className) != null;
00047   }  
00048   public void newState() {
00049     ss = VirtualMachine.getSS();
00050   }  
00051   public int numOfThreads() {
00052     return ss.getThreadCount();
00053   }  
00054 }

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