2003/06/10 21:45:35
[org.ibex.core.git] / src / org / xwt / js / Context.java
1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
2 package org.xwt.js;
3
4 import org.xwt.util.*;
5 import java.io.*;
6
7 /** encapsulates a single JavaScript thread and its state */
8 public class Context {
9
10     private static Hash javaThreadToContextMap = new Hash();
11
12     public Vec stack = new Vec();
13
14     /** at any point in time, one JS Context can be bound to each Java thread; this determines which context any call()s execute in */
15     public void bindToCurrentThread() { javaThreadToContextMap.put(Thread.currentThread(), this); }
16     public static Context getContextForCurrentThread() {
17         Context ret = (Context)javaThreadToContextMap.get(Thread.currentThread());
18         if (ret == null) {
19             ret = new Context();
20             ret.bindToCurrentThread();
21         }
22         return ret;
23     }
24
25     public static class CallMarker { public CallMarker() { } }
26     public static class LoopMarker { public int location; public LoopMarker(int location) { this.location = location; } }
27
28 }