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

StaticArea.java

00001 package gov.nasa.arc.ase.jpf.jvm;
00002 
00003 import gov.nasa.arc.ase.util.Debug;
00004 import gov.nasa.arc.ase.jpf.InternalErrorException;
00005 //#ifdef RACE
00006 
00007 
00008 
00009 //#endif RACE
00010 
00011 public class StaticArea extends Area {
00012   /**
00013    * Creates a new empty static area.
00014    */
00015   public StaticArea(KernelState ks) {
00016     super(ks, true);
00017   }  
00018   public StaticArea(StaticArea sa) {
00019     super(sa);
00020   }  
00021   public Object clone() {
00022     return new StaticArea(this);
00023   }  
00024 //#else !NO_STATIC_SYMMETRY
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 //#endif !NO_STATIC_SYMMETRY
00044 
00045   public boolean containsClass(String cname) {
00046     return indexOf(cname) != -1;
00047   }  
00048   public ElementInfo get(String cname) {
00049     int index = indexOf(cname);
00050 
00051     if(index == -1)
00052       return get(newClass(ClassInfo.getClassInfo(cname)));
00053 
00054     return get(indexOf(cname));
00055   }  
00056   private static int indexFor(String cname) {
00057     return StaticMap.addEntry(cname);
00058   }  
00059   /**
00060    * Returns the index of a given class.
00061    */
00062 //#ifdef !NO_STATIC_SYMMETRY
00063   
00064   public int indexOf(String cname) {
00065     synchronized(StaticMap.class) {
00066       if(!StaticMap.hasEntry(cname))
00067     return -1;
00068 
00069       int index = StaticMap.getEntry(cname);
00070 
00071       if(index >= 0 &&
00072       index < elements.length &&
00073       elements[index] != null)
00074     return index;
00075       else
00076     return -1;
00077     }
00078   }  
00079   public void initializeClasses() {
00080     int length = elements.length;
00081 
00082     for(int i = 0; i < length; i++)
00083       if(elements[i] != null)
00084     ks.ss.initializeClass(elements[i].getClassInfo());
00085   }  
00086 //#endif MARK_N_SWEEP
00087 
00088   public void log() {
00089     Debug.println(Debug.MESSAGE, "SA");
00090     for(int i = 0; i < elements.length; i++)
00091       if(elements[i] != null)
00092     elements[i].log();
00093   }  
00094 //#ifdef MARK_N_SWEEP
00095   public void mark() {
00096     int length = elements.length;
00097 
00098     for(int i = 0; i < length; i++)
00099       if(elements[i] != null)
00100     elements[i].mark();
00101   }  
00102   public int newClass(ClassInfo ci) {
00103     if(containsClass(ci.getName()))
00104       throw new InternalErrorException("cannot load class " + ci.getName() + " twice");
00105 
00106     ClassInfo superClass = ci.getSuperClass();
00107 
00108     if(superClass != null && !containsClass(superClass.getName()))
00109       newClass(superClass);
00110 
00111     Fields f = ci.createClassFields();
00112     Monitor m = new Monitor();
00113 //#ifdef RACE
00114 
00115 
00116 
00117 //#endif RACE
00118 
00119     int index = indexFor(ci.getName());
00120 
00121     add(index, new ElementInfo(f, m
00122 //#ifdef RACE
00123 
00124 //#endif RACE
00125       ));
00126 
00127     ks.ss.initializeClass(ci);
00128 
00129     return index;
00130   }  
00131 }

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