# NOT A PART OF SEAMONKEY IN ANY WAY
Some new, some old filres copiedfrom Rhino to form start of prototyping environment for Project Brenda git-svn-id: svn://10.0.0.236/trunk@27571 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
79
mozilla/js/js2/java/Context.java
Normal file
79
mozilla/js/js2/java/Context.java
Normal file
@@ -0,0 +1,79 @@
|
||||
import java.util.Hashtable;
|
||||
|
||||
class Context {
|
||||
|
||||
static boolean printTrees = true;
|
||||
public static final int VERSION_DEFAULT = 0;
|
||||
public static final int VERSION_1_2 = 120;
|
||||
|
||||
public Context() {
|
||||
setLanguageVersion(VERSION_DEFAULT);
|
||||
}
|
||||
|
||||
public synchronized void enter() throws ThreadLinkException,
|
||||
InterruptedException
|
||||
{
|
||||
Thread t = Thread.currentThread();
|
||||
|
||||
while (currentThread != null) {
|
||||
|
||||
// Check to avoid deadlock
|
||||
if (t == currentThread) {
|
||||
throw new ThreadLinkException(
|
||||
"Context already associated with a Thread");
|
||||
}
|
||||
wait();
|
||||
}
|
||||
currentThread = t;
|
||||
|
||||
synchronized (threadContexts) {
|
||||
Context cx = (Context) threadContexts.get(t);
|
||||
if (cx != null) {
|
||||
currentThread = null;
|
||||
throw new ThreadLinkException(
|
||||
"Thread already associated with a Context");
|
||||
}
|
||||
threadContexts.put(t, this);
|
||||
}
|
||||
}
|
||||
|
||||
static Context getContext() {
|
||||
Thread t = Thread.currentThread();
|
||||
Context cx = (Context) threadContexts.get(t);
|
||||
if (cx == null) {
|
||||
throw new WrappedException(new ThreadLinkException(
|
||||
"No Context associated with current Thread"));
|
||||
}
|
||||
return cx;
|
||||
}
|
||||
|
||||
public void setLanguageVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public int getLanguageVersion() {
|
||||
return version;
|
||||
}
|
||||
int version;
|
||||
|
||||
static String getMessage(String messageId, Object[] arguments)
|
||||
{
|
||||
return messageId;
|
||||
}
|
||||
|
||||
static void reportError(String message, String sourceName,
|
||||
int lineno, String lineSource,
|
||||
int lineOffset)
|
||||
{
|
||||
}
|
||||
|
||||
static void reportWarning(String message, String sourceName,
|
||||
int lineno, String lineSource,
|
||||
int lineOffset)
|
||||
{
|
||||
}
|
||||
|
||||
private Thread currentThread;
|
||||
private static Hashtable threadContexts = new Hashtable(11);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user