From: bdemsky Date: Wed, 18 Feb 2009 08:54:42 +0000 (+0000) Subject: Massive commit... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d2178dde3360bf7dd63d3f54794ad54501f7796f;p=IRC.git Massive commit... Changes: 1) Put Class Library files in directories by when we use them 2) Change class paths in buildscript 3) Only load/compile classes that we actually use --- diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java index be82555b..6081ae0f 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java @@ -25,9 +25,9 @@ public class TaskAnalysis { * @param state a flattened State object * @see State */ - public TaskAnalysis(State state, TagAnalysis taganalysis) { + public TaskAnalysis(State state, TagAnalysis taganalysis, TypeUtil typeutil) { this.state=state; - this.typeutil=new TypeUtil(state); + this.typeutil=typeutil; this.taganalysis=taganalysis; } diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java index 6a2d3aab..602cd7ea 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java @@ -23,9 +23,9 @@ public class TaskTagAnalysis { * Class Constructor * */ - public TaskTagAnalysis(State state, TagAnalysis taganalysis) { + public TaskTagAnalysis(State state, TagAnalysis taganalysis, TypeUtil typeutil) { this.state=state; - this.typeutil=new TypeUtil(state); + this.typeutil=typeutil; this.taganalysis=taganalysis; this.flaginfo=new FlagInfo(state); this.toprocess=new HashSet(); diff --git a/Robust/src/ClassLibrary/Barrier.java b/Robust/src/ClassLibrary/Barrier.java deleted file mode 100644 index f8389c47..00000000 --- a/Robust/src/ClassLibrary/Barrier.java +++ /dev/null @@ -1,52 +0,0 @@ -public class BarrierServer extends Thread { - int numthreads; - boolean done; - - public BarrierServer(int n) { - numthreads=n; - done=false; - } - - public void run() { - int n; - ServerSocket ss=new ServerSocket(2000); - atomic { - n=numthreads; - done=true; - } - Socket ar[]=new Socket[n]; - for(int i=0; i(loadFactor*dhe.array.length)) { - //Resize the table - resize(index1); - } - return null; - } -} - - -class DistributedHashEntry { - public DistributedHashEntry(int capacity) { - array=global new DHashEntry[capacity]; - } - int count; - DHashEntry[] array; -} - - -class DHashEntry { - public DHashEntry() { - } - int hashval; - Object key; - Object value; - DHashEntry next; -} diff --git a/Robust/src/ClassLibrary/Java/Object.java b/Robust/src/ClassLibrary/Java/Object.java new file mode 100644 index 00000000..4968cfa3 --- /dev/null +++ b/Robust/src/ClassLibrary/Java/Object.java @@ -0,0 +1,28 @@ +public class Object { + public int cachedCode; //first field has to be a primitive + public boolean cachedHash; + + public native int nativehashCode(); + + public int hashCode() { + if (!cachedHash) { + cachedCode=nativehashCode(); + cachedHash=true; + } + return cachedCode; + } + + /* DON'T USE THIS METHOD UNLESS NECESSARY */ + /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ + public native int getType(); + + public String toString() { + return "Object"+hashCode(); + } + + public boolean equals(Object o) { + if (o==this) + return true; + return false; + } +} diff --git a/Robust/src/ClassLibrary/Java/ServerSocket.java b/Robust/src/ClassLibrary/Java/ServerSocket.java new file mode 100644 index 00000000..1cf07f29 --- /dev/null +++ b/Robust/src/ClassLibrary/Java/ServerSocket.java @@ -0,0 +1,28 @@ +public class ServerSocket { + /* File Descriptor */ + int fd; + + private native int createSocket(int port); + + public ServerSocket(int port) { + this.fd=createSocket(port); + } + + public Socket accept() { + Socket s=new Socket(); + int newfd=nativeaccept(s); + s.setFD(newfd); + return s; + } + + /* Lets caller pass in their own Socket object. */ + public void accept(Socket s) { + int newfd=nativeaccept(s); + s.setFD(newfd); + } + + private native int nativeaccept(Socket s); + + public void close(); + +} diff --git a/Robust/src/ClassLibrary/Java/Socket.java b/Robust/src/ClassLibrary/Java/Socket.java new file mode 100644 index 00000000..297fe3d0 --- /dev/null +++ b/Robust/src/ClassLibrary/Java/Socket.java @@ -0,0 +1,61 @@ +public class Socket { + /* File Descriptor */ + int fd; + SocketInputStream sin; + SocketOutputStream sout; + + public Socket() { + sin=new SocketInputStream(this); + sout=new SocketOutputStream(this); + } + + public InputStream getInputStream() { + return sin; + } + + public OutputStream getOutputStream() { + return sout; + } + + public Socket(String host, int port) { + InetAddress address=InetAddress.getByName(host); + fd=nativeBind(address.getAddress(), port); + nativeConnect(fd, address.getAddress(), port); + sin=new SocketInputStream(this); + sout=new SocketOutputStream(this); + } + + public Socket(InetAddress address, int port) { + fd=nativeBind(address.getAddress(), port); + nativeConnect(fd, address.getAddress(), port); + sin=new SocketInputStream(this); + sout=new SocketOutputStream(this); + } + + public static native int nativeBind(byte[] address, int port); + + public static native int nativeConnect(int fd, byte[] address, int port); + + int setFD(int filed) { + fd=filed; + } + + public int read(byte[] b) { + return nativeRead(b); + } + public void write(byte[] b) { + nativeWrite(b, 0, b.length); + } + + public void write(byte[] b, int offset, int len) { + nativeWrite(b, offset, len); + } + + private native int nativeRead(byte[] b); + private native void nativeWrite(byte[] b, int offset, int len); + private native void nativeClose(); + + public void close() { + nativeClose(); + } +} diff --git a/Robust/src/ClassLibrary/JavaDSM/Barrier.java b/Robust/src/ClassLibrary/JavaDSM/Barrier.java new file mode 100644 index 00000000..f8389c47 --- /dev/null +++ b/Robust/src/ClassLibrary/JavaDSM/Barrier.java @@ -0,0 +1,52 @@ +public class BarrierServer extends Thread { + int numthreads; + boolean done; + + public BarrierServer(int n) { + numthreads=n; + done=false; + } + + public void run() { + int n; + ServerSocket ss=new ServerSocket(2000); + atomic { + n=numthreads; + done=true; + } + Socket ar[]=new Socket[n]; + for(int i=0; i 1) + b.cleared=true; + b.entercount--; + ret1 = true; + } + retry=false; + } + } + } while(retry); + if (ret1) { + return; + } + while(ret2) { + atomic { + if (b.cleared) { + b.entercount--; + int count = b.entercount; + if (count==0) + b.cleared=false; + ret2=false; + } + } + } + } +} diff --git a/Robust/src/ClassLibrary/JavaDSM/DistributedHashMap.java b/Robust/src/ClassLibrary/JavaDSM/DistributedHashMap.java new file mode 100644 index 00000000..76d16fb4 --- /dev/null +++ b/Robust/src/ClassLibrary/JavaDSM/DistributedHashMap.java @@ -0,0 +1,170 @@ +public class DistributedHashMap { + DistributedHashEntry[] table; + float loadFactor; + int secondcapacity; + + public DistributedHashMap(int initialCapacity, int secondcapacity, float loadFactor) { + init(initialCapacity, secondcapacity, loadFactor); + } + + private void init(int initialCapacity, int secondcapacity, float loadFactor) { + table=global new DistributedHashEntry[initialCapacity]; + this.loadFactor=loadFactor; + this.secondcapacity=secondcapacity; + } + + private static int hash1(int hashcode, int length) { + int value=hashcode%length; + if (value<0) + return -value; + else + return value; + } + + private static int hash2(int hashcode, int length1, int length2) { + int value=(hashcode*31)%length2; + if (value<0) + return -value; + else + return value; + } + + void resize(int index) { + DHashEntry[] oldtable=table[index].array; + int newCapacity=oldtable.length*2+1; + DHashEntry [] newtable=global new DHashEntry[newCapacity]; + table[index].array=newtable; + + for(int i=0; i(loadFactor*dhe.array.length)) { + //Resize the table + resize(index1); + } + return null; + } +} + + +class DistributedHashEntry { + public DistributedHashEntry(int capacity) { + array=global new DHashEntry[capacity]; + } + int count; + DHashEntry[] array; +} + + +class DHashEntry { + public DHashEntry() { + } + int hashval; + Object key; + Object value; + DHashEntry next; +} diff --git a/Robust/src/ClassLibrary/JavaDSM/Object.java b/Robust/src/ClassLibrary/JavaDSM/Object.java new file mode 100644 index 00000000..308e81f3 --- /dev/null +++ b/Robust/src/ClassLibrary/JavaDSM/Object.java @@ -0,0 +1,30 @@ +public class Object { + public int cachedCode; //first field has to be a primitive + public boolean cachedHash; + public Object nextobject; /* Oid */ + public Object localcopy; + + public native int nativehashCode(); + + public int hashCode() { + if (!cachedHash) { + cachedCode=nativehashCode(); + cachedHash=true; + } + return cachedCode; + } + + /* DON'T USE THIS METHOD UNLESS NECESSARY */ + /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ + public native int getType(); + + public String toString() { + return "Object"+hashCode(); + } + + public boolean equals(Object o) { + if (o==this) + return true; + return false; + } +} diff --git a/Robust/src/ClassLibrary/JavaDSM/Thread.java b/Robust/src/ClassLibrary/JavaDSM/Thread.java new file mode 100644 index 00000000..4fb2c7b1 --- /dev/null +++ b/Robust/src/ClassLibrary/JavaDSM/Thread.java @@ -0,0 +1,20 @@ +public class Thread { + /* Don't allow overriding this method. If you do, it will break dispatch + * because we don't have the type information necessary. */ + public boolean threadDone; + + public Thread() { + threadDone = false; + } + + public static native void yield(); + + public final native void join(); + + public final native void start(int mid); + + public native static void sleep(long millis); + + public void run() { + } +} diff --git a/Robust/src/ClassLibrary/JavaThread/Object.java b/Robust/src/ClassLibrary/JavaThread/Object.java new file mode 100644 index 00000000..a9bf6f4d --- /dev/null +++ b/Robust/src/ClassLibrary/JavaThread/Object.java @@ -0,0 +1,33 @@ +public class Object { + public int cachedCode; //first field has to be a primitive + public boolean cachedHash; + + public native int nativehashCode(); + private Object nextlockobject; + private Object prevlockobject; + + public int hashCode() { + if (!cachedHash) { + cachedCode=nativehashCode(); + cachedHash=true; + } + return cachedCode; + } + + /* DON'T USE THIS METHOD UNLESS NECESSARY */ + /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ + public native int getType(); + + public native int MonitorEnter(); + public native int MonitorExit(); + + public String toString() { + return "Object"+hashCode(); + } + + public boolean equals(Object o) { + if (o==this) + return true; + return false; + } +} diff --git a/Robust/src/ClassLibrary/JavaThread/Thread.java b/Robust/src/ClassLibrary/JavaThread/Thread.java new file mode 100644 index 00000000..50c5580f --- /dev/null +++ b/Robust/src/ClassLibrary/JavaThread/Thread.java @@ -0,0 +1,27 @@ +public class Thread { + private boolean finished; + + public void start() { + nativeCreate(); + } + + private static void staticStart(Thread t) { + t.run(); + } + + public static native void yield(); + + public void join() { + nativeJoin(); + } + + private native void nativeJoin(); + + public native static void sleep(long millis); + + public void run() { + } + + private native void nativeCreate(); + +} diff --git a/Robust/src/ClassLibrary/Object.java b/Robust/src/ClassLibrary/Object.java deleted file mode 100644 index f2d05d25..00000000 --- a/Robust/src/ClassLibrary/Object.java +++ /dev/null @@ -1,30 +0,0 @@ -public class Object { - public native int nativehashCode(); - private int cachedCode; //first field has to be a primitive - private boolean cachedHash; - - /* DO NOT USE ANY OF THESE - THEY ARE FOR IMPLEMENTING TAGS */ - private Object tags; - - public int hashCode() { - if (!cachedHash) { - cachedCode=nativehashCode(); - cachedHash=true; - } - return cachedCode; - } - - /* DON'T USE THIS METHOD UNLESS NECESSARY */ - /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ - public native int getType(); - - public String toString() { - return "Object"+hashCode(); - } - - public boolean equals(Object o) { - if (o==this) - return true; - return false; - } -} diff --git a/Robust/src/ClassLibrary/ObjectFC.java b/Robust/src/ClassLibrary/ObjectFC.java deleted file mode 100644 index ae2c437a..00000000 --- a/Robust/src/ClassLibrary/ObjectFC.java +++ /dev/null @@ -1,31 +0,0 @@ -public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; - public Object nextobject; /* Oid */ - public Object localcopy; - private Object tags; - - public native int nativehashCode(); - - public int hashCode() { - if (!cachedHash) { - cachedCode=nativehashCode(); - cachedHash=true; - } - return cachedCode; - } - - /* DON'T USE THIS METHOD UNLESS NECESSARY */ - /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ - public native int getType(); - - public String toString() { - return "Object"+hashCode(); - } - - public boolean equals(Object o) { - if (o==this) - return true; - return false; - } -} diff --git a/Robust/src/ClassLibrary/ObjectJava.java b/Robust/src/ClassLibrary/ObjectJava.java deleted file mode 100644 index a9bf6f4d..00000000 --- a/Robust/src/ClassLibrary/ObjectJava.java +++ /dev/null @@ -1,33 +0,0 @@ -public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; - - public native int nativehashCode(); - private Object nextlockobject; - private Object prevlockobject; - - public int hashCode() { - if (!cachedHash) { - cachedCode=nativehashCode(); - cachedHash=true; - } - return cachedCode; - } - - /* DON'T USE THIS METHOD UNLESS NECESSARY */ - /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ - public native int getType(); - - public native int MonitorEnter(); - public native int MonitorExit(); - - public String toString() { - return "Object"+hashCode(); - } - - public boolean equals(Object o) { - if (o==this) - return true; - return false; - } -} diff --git a/Robust/src/ClassLibrary/ObjectJavaDSM.java b/Robust/src/ClassLibrary/ObjectJavaDSM.java deleted file mode 100644 index 308e81f3..00000000 --- a/Robust/src/ClassLibrary/ObjectJavaDSM.java +++ /dev/null @@ -1,30 +0,0 @@ -public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; - public Object nextobject; /* Oid */ - public Object localcopy; - - public native int nativehashCode(); - - public int hashCode() { - if (!cachedHash) { - cachedCode=nativehashCode(); - cachedHash=true; - } - return cachedCode; - } - - /* DON'T USE THIS METHOD UNLESS NECESSARY */ - /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ - public native int getType(); - - public String toString() { - return "Object"+hashCode(); - } - - public boolean equals(Object o) { - if (o==this) - return true; - return false; - } -} diff --git a/Robust/src/ClassLibrary/ObjectJavaNT.java b/Robust/src/ClassLibrary/ObjectJavaNT.java deleted file mode 100644 index 4968cfa3..00000000 --- a/Robust/src/ClassLibrary/ObjectJavaNT.java +++ /dev/null @@ -1,28 +0,0 @@ -public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; - - public native int nativehashCode(); - - public int hashCode() { - if (!cachedHash) { - cachedCode=nativehashCode(); - cachedHash=true; - } - return cachedCode; - } - - /* DON'T USE THIS METHOD UNLESS NECESSARY */ - /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ - public native int getType(); - - public String toString() { - return "Object"+hashCode(); - } - - public boolean equals(Object o) { - if (o==this) - return true; - return false; - } -} diff --git a/Robust/src/ClassLibrary/ServerSocket.java b/Robust/src/ClassLibrary/ServerSocket.java deleted file mode 100644 index 723e886c..00000000 --- a/Robust/src/ClassLibrary/ServerSocket.java +++ /dev/null @@ -1,38 +0,0 @@ -public class ServerSocket { - /* Socket pending flag */ - external flag SocketPending; - /* File Descriptor */ - int fd; - - private native int createSocket(int port); - - public ServerSocket(int port) { - this.fd=createSocket(port); - } - - public Socket accept() { - Socket s=new Socket(); - int newfd=nativeaccept(s); - s.setFD(newfd); - return s; - } - - public Socket accept(tag td) { - Socket s=new Socket() { - } {td}; - int newfd=nativeaccept(s); - s.setFD(newfd); - return s; - } - - /* Lets caller pass in their own Socket object. */ - public void accept(Socket s) { - int newfd=nativeaccept(s); - s.setFD(newfd); - } - - private native int nativeaccept(Socket s); - - public void close(); - -} diff --git a/Robust/src/ClassLibrary/ServerSocketJava.java b/Robust/src/ClassLibrary/ServerSocketJava.java deleted file mode 100644 index 1cf07f29..00000000 --- a/Robust/src/ClassLibrary/ServerSocketJava.java +++ /dev/null @@ -1,28 +0,0 @@ -public class ServerSocket { - /* File Descriptor */ - int fd; - - private native int createSocket(int port); - - public ServerSocket(int port) { - this.fd=createSocket(port); - } - - public Socket accept() { - Socket s=new Socket(); - int newfd=nativeaccept(s); - s.setFD(newfd); - return s; - } - - /* Lets caller pass in their own Socket object. */ - public void accept(Socket s) { - int newfd=nativeaccept(s); - s.setFD(newfd); - } - - private native int nativeaccept(Socket s); - - public void close(); - -} diff --git a/Robust/src/ClassLibrary/Socket.java b/Robust/src/ClassLibrary/Socket.java deleted file mode 100644 index 506c3272..00000000 --- a/Robust/src/ClassLibrary/Socket.java +++ /dev/null @@ -1,71 +0,0 @@ -public class Socket { - /* Data pending flag */ - external flag IOPending; - /* File Descriptor */ - int fd; - private SocketInputStream sin; - private SocketOutputStream sout; - - public Socket() { - sin=new SocketInputStream(this); - sout=new SocketOutputStream(this); - } - - public InputStream getInputStream() { - return sin; - } - - public OutputStream getOutputStream() { - return sout; - } - - public Socket(String host, int port) { - InetAddress address=InetAddress.getByName(host); - fd=nativeBind(address.getAddress(), port); - nativeConnect(fd, address.getAddress(), port); - } - - public Socket(InetAddress address, int port) { - fd=nativeBind(address.getAddress(), port); - nativeConnect(fd, address.getAddress(), port); - } - - public void connect(String host, int port) { - InetAddress address=InetAddress.getByName(host); - fd=nativeBind(address.getAddress(), port); - nativeConnect(fd, address.getAddress(), port); - } - - public void connect(InetAddress address, int port) { - fd=nativeBind(address.getAddress(), port); - nativeConnect(fd, address.getAddress(), port); - } - - public static native int nativeBind(byte[] address, int port); - - public native int nativeConnect(int fd, byte[] address, int port); - - int setFD(int filed) { - fd=filed; - } - - public int read(byte[] b) { - return nativeRead(b); - } - public void write(byte[] b) { - nativeWrite(b, 0, b.length); - } - - public void write(byte[] b, int offset, int len) { - nativeWrite(b, offset, len); - } - - private native void nativeBindFD(int fd); - private native int nativeRead(byte[] b); - private native void nativeWrite(byte[] b, int offset, int len); - private native void nativeClose(); - - public void close() { - nativeClose(); - } -} diff --git a/Robust/src/ClassLibrary/SocketJava.java b/Robust/src/ClassLibrary/SocketJava.java deleted file mode 100644 index 297fe3d0..00000000 --- a/Robust/src/ClassLibrary/SocketJava.java +++ /dev/null @@ -1,61 +0,0 @@ -public class Socket { - /* File Descriptor */ - int fd; - SocketInputStream sin; - SocketOutputStream sout; - - public Socket() { - sin=new SocketInputStream(this); - sout=new SocketOutputStream(this); - } - - public InputStream getInputStream() { - return sin; - } - - public OutputStream getOutputStream() { - return sout; - } - - public Socket(String host, int port) { - InetAddress address=InetAddress.getByName(host); - fd=nativeBind(address.getAddress(), port); - nativeConnect(fd, address.getAddress(), port); - sin=new SocketInputStream(this); - sout=new SocketOutputStream(this); - } - - public Socket(InetAddress address, int port) { - fd=nativeBind(address.getAddress(), port); - nativeConnect(fd, address.getAddress(), port); - sin=new SocketInputStream(this); - sout=new SocketOutputStream(this); - } - - public static native int nativeBind(byte[] address, int port); - - public static native int nativeConnect(int fd, byte[] address, int port); - - int setFD(int filed) { - fd=filed; - } - - public int read(byte[] b) { - return nativeRead(b); - } - public void write(byte[] b) { - nativeWrite(b, 0, b.length); - } - - public void write(byte[] b, int offset, int len) { - nativeWrite(b, offset, len); - } - - private native int nativeRead(byte[] b); - private native void nativeWrite(byte[] b, int offset, int len); - private native void nativeClose(); - - public void close() { - nativeClose(); - } -} diff --git a/Robust/src/ClassLibrary/StartupObject.java b/Robust/src/ClassLibrary/StartupObject.java deleted file mode 100644 index 541c26f5..00000000 --- a/Robust/src/ClassLibrary/StartupObject.java +++ /dev/null @@ -1,5 +0,0 @@ -public class StartupObject { - flag initialstate; - - String [] parameters; -} diff --git a/Robust/src/ClassLibrary/TagDescriptor.java b/Robust/src/ClassLibrary/TagDescriptor.java deleted file mode 100644 index be067fa7..00000000 --- a/Robust/src/ClassLibrary/TagDescriptor.java +++ /dev/null @@ -1,5 +0,0 @@ -/** This class is not to be used by the end user. It's intended for - * internal use to keep track of tags. */ - -private class TagDescriptor { -} diff --git a/Robust/src/ClassLibrary/Thread.java b/Robust/src/ClassLibrary/Thread.java deleted file mode 100644 index 50c5580f..00000000 --- a/Robust/src/ClassLibrary/Thread.java +++ /dev/null @@ -1,27 +0,0 @@ -public class Thread { - private boolean finished; - - public void start() { - nativeCreate(); - } - - private static void staticStart(Thread t) { - t.run(); - } - - public static native void yield(); - - public void join() { - nativeJoin(); - } - - private native void nativeJoin(); - - public native static void sleep(long millis); - - public void run() { - } - - private native void nativeCreate(); - -} diff --git a/Robust/src/ClassLibrary/ThreadDSM.java b/Robust/src/ClassLibrary/ThreadDSM.java deleted file mode 100644 index 4fb2c7b1..00000000 --- a/Robust/src/ClassLibrary/ThreadDSM.java +++ /dev/null @@ -1,20 +0,0 @@ -public class Thread { - /* Don't allow overriding this method. If you do, it will break dispatch - * because we don't have the type information necessary. */ - public boolean threadDone; - - public Thread() { - threadDone = false; - } - - public static native void yield(); - - public final native void join(); - - public final native void start(int mid); - - public native static void sleep(long millis); - - public void run() { - } -} diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index e02d09d9..ef5aa45d 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -8,6 +8,7 @@ import Analysis.TaskStateAnalysis.*; public class State { public State() { this.classes=new SymbolTable(); + this.discclass=new HashSet(); this.tasks=new SymbolTable(); this.treemethodmap=new Hashtable(); this.flatmethodmap=new Hashtable(); @@ -17,6 +18,7 @@ public class State { this.tagmap=new Hashtable(); this.selfloops=new HashSet(); this.excprefetch=new HashSet(); + this.classpath=new Vector(); } public void addParseNode(ParseNode parsetree) { @@ -79,6 +81,8 @@ public class State { public HashSet selfloops; public HashSet excprefetch; + public Vector classpath; + public HashSet discclass; public SymbolTable classes; public SymbolTable tasks; public Set parsetrees; diff --git a/Robust/src/IR/TagVarDescriptor.java b/Robust/src/IR/TagVarDescriptor.java index 4cca52da..f076b3c1 100644 --- a/Robust/src/IR/TagVarDescriptor.java +++ b/Robust/src/IR/TagVarDescriptor.java @@ -17,6 +17,7 @@ public class TagVarDescriptor extends Descriptor { this.identifier=identifier; this.safename = "___" + name + "___"; this.uniqueid=count++; + throw new Error(); } public String getName() { diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 12149c3e..2e61224f 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -13,18 +13,18 @@ public class BuildIR { this.m_taskexitnum = 0; } - public void buildtree() { - for(Iterator it=state.parsetrees.iterator(); it.hasNext();) { - ParseNode pn=(ParseNode)it.next(); + public void buildtree(ParseNode pn) { parseFile(pn); - } } + Vector singleimports; + Vector multiimports; + NameDescriptor packages; + /** Parse the classes in this file */ public void parseFile(ParseNode pn) { - NameDescriptor packages; - Vector singleimports=new Vector(); - Vector multiimports=new Vector(); + singleimports=new Vector(); + multiimports=new Vector(); ParseNode ipn=pn.getChild("imports").getChild("import_decls_list"); if (ipn!=null) { @@ -396,6 +396,7 @@ public class BuildIR { return new LiteralNode(literaltype, literal_obj); } else if (isNode(pn,"createobject")) { TypeDescriptor td=parseTypeDescriptor(pn); + Vector args=parseArgumentList(pn); boolean isglobal=pn.getChild("global")!=null; String disjointId=null; diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index d2fc664c..59bc63ac 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -6,60 +6,70 @@ import IR.*; public class SemanticCheck { State state; TypeUtil typeutil; - Stack loopstack; + Stack loopstack; + HashSet toanalyze; + HashSet completed; public SemanticCheck(State state, TypeUtil tu) { this.state=state; this.typeutil=tu; this.loopstack=new Stack(); + this.toanalyze=new HashSet(); + this.completed=new HashSet(); } - public void semanticCheck() { - SymbolTable classtable=state.getClassSymbolTable(); - Iterator it=classtable.getDescriptorsIterator(); - // Do descriptors first - while(it.hasNext()) { - ClassDescriptor cd=(ClassDescriptor)it.next(); + public ClassDescriptor getClass(String classname) { + ClassDescriptor cd=typeutil.getClass(classname, toanalyze); + if (!completed.contains(cd)) { + completed.add(cd); //System.out.println("Checking class: "+cd); //Set superclass link up if (cd.getSuper()!=null) { - cd.setSuper(typeutil.getClass(cd.getSuper())); + cd.setSuper(getClass(cd.getSuper())); // Link together Field, Method, and Flag tables so classes // inherit these from their superclasses cd.getFieldTable().setParent(cd.getSuperDesc().getFieldTable()); cd.getMethodTable().setParent(cd.getSuperDesc().getMethodTable()); cd.getFlagTable().setParent(cd.getSuperDesc().getFlagTable()); } - + /* Check to see that fields are well typed */ for(Iterator field_it=cd.getFields(); field_it.hasNext();) { FieldDescriptor fd=(FieldDescriptor)field_it.next(); //System.out.println("Checking field: "+fd); checkField(cd,fd); } - + for(Iterator method_it=cd.getMethods(); method_it.hasNext();) { MethodDescriptor md=(MethodDescriptor)method_it.next(); checkMethod(cd,md); } } + return cd; + } - it=classtable.getDescriptorsIterator(); - // Do descriptors first - while(it.hasNext()) { - ClassDescriptor cd=(ClassDescriptor)it.next(); - for(Iterator method_it=cd.getMethods(); method_it.hasNext();) { - MethodDescriptor md=(MethodDescriptor)method_it.next(); - checkMethodBody(cd,md); - } - } + public void semanticCheck() { + SymbolTable classtable=state.getClassSymbolTable(); + toanalyze.addAll(classtable.getValueSet()); + //Start with any tasks for(Iterator task_it=state.getTaskSymbolTable().getDescriptorsIterator(); task_it.hasNext();) { TaskDescriptor td=(TaskDescriptor)task_it.next(); checkTask(td); } + + // Do methods next + while(!toanalyze.isEmpty()) { + ClassDescriptor cd=(ClassDescriptor)toanalyze.iterator().next(); + toanalyze.remove(cd); + for(Iterator method_it=cd.getMethods(); method_it.hasNext();) { + MethodDescriptor md=(MethodDescriptor)method_it.next(); + checkMethodBody(cd,md); + } + } + } public void checkTypeDescriptor(TypeDescriptor td) { @@ -67,7 +77,7 @@ public class SemanticCheck { return; /* Done */ else if (td.isClass()) { String name=td.toString(); - ClassDescriptor field_cd=(ClassDescriptor)state.getClassSymbolTable().get(name); + ClassDescriptor field_cd=getClass(name); if (field_cd==null) throw new Error("Undefined class "+name); td.setClassDescriptor(field_cd); @@ -412,7 +422,7 @@ public class SemanticCheck { if (cn.getType()==null) { NameDescriptor typenamed=cn.getTypeName().getName(); String typename=typenamed.toString(); - TypeDescriptor ntd=new TypeDescriptor(typeutil.getClass(typename)); + TypeDescriptor ntd=new TypeDescriptor(getClass(typename)); cn.setType(ntd); } @@ -491,7 +501,7 @@ public class SemanticCheck { } else if (o instanceof Character) { ln.setType(new TypeDescriptor(TypeDescriptor.CHAR)); } else if (o instanceof String) { - ln.setType(new TypeDescriptor(typeutil.getClass(TypeUtil.StringClass))); + ln.setType(new TypeDescriptor(getClass(TypeUtil.StringClass))); } if (td!=null) @@ -599,7 +609,7 @@ public class SemanticCheck { if (an.getDest().getType().isString()&&an.getOperation().getOp()==AssignOperation.PLUSEQ) { //String add - ClassDescriptor stringcl=typeutil.getClass(TypeUtil.StringClass); + ClassDescriptor stringcl=getClass(TypeUtil.StringClass); TypeDescriptor stringtd=new TypeDescriptor(stringcl); NameDescriptor nd=new NameDescriptor("String"); NameDescriptor valuend=new NameDescriptor(nd, "valueOf"); @@ -788,7 +798,7 @@ NextMethod: typetolookin=min.getExpression().getType(); } else { //we have a type - ClassDescriptor cd=typeutil.getClass(min.getBaseName().getSymbol()); + ClassDescriptor cd=getClass(min.getBaseName().getSymbol()); if (cd==null) throw new Error("md = "+ md.toString()+ " "+min.getBaseName()+" undefined"); typetolookin=new TypeDescriptor(cd); @@ -976,7 +986,7 @@ NextMethod: case Operation.ADD: if (ltd.isString()||rtd.isString()) { - ClassDescriptor stringcl=typeutil.getClass(TypeUtil.StringClass); + ClassDescriptor stringcl=getClass(TypeUtil.StringClass); TypeDescriptor stringtd=new TypeDescriptor(stringcl); NameDescriptor nd=new NameDescriptor("String"); NameDescriptor valuend=new NameDescriptor(nd, "valueOf"); diff --git a/Robust/src/IR/TypeUtil.java b/Robust/src/IR/TypeUtil.java index 91fd0fdc..0bda49cb 100644 --- a/Robust/src/IR/TypeUtil.java +++ b/Robust/src/IR/TypeUtil.java @@ -1,5 +1,8 @@ package IR; import java.util.*; +import IR.Tree.*; +import java.io.File; +import Main.Main; public class TypeUtil { public static final String StringClass="String"; @@ -10,32 +13,62 @@ public class TypeUtil { State state; Hashtable supertable; Hashtable subclasstable; + BuildIR bir; - public TypeUtil(State state) { + public TypeUtil(State state, BuildIR bir) { this.state=state; + this.bir=bir; createTables(); } + public void addNewClass(String cl) { + if (state.discclass.contains(cl)) + return; + for(int i=0;i