projects
/
org.ibex.core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
2003/06/13 09:19:10
[org.ibex.core.git]
/
src
/
org
/
xwt
/
Trap.java
diff --git
a/src/org/xwt/Trap.java
b/src/org/xwt/Trap.java
index
770ad51
..
581bd2a
100644
(file)
--- a/
src/org/xwt/Trap.java
+++ b/
src/org/xwt/Trap.java
@@
-44,7
+44,7
@@
public class Trap {
private JS rp = null;
/** the function for this trap */
private JS rp = null;
/** the function for this trap */
- JS.Function f = null;
+ CompiledFunction f = null;
/** the name of the property that this trap was placed on */
private String name = null;
/** the name of the property that this trap was placed on */
private String name = null;
@@
-72,7
+72,7
@@
public class Trap {
* @param isreadtrap true iff this is a read (double-underscore) trap
* @param rp if this trap is being placed via a rootproxy, this is that proxy object.
*/
* @param isreadtrap true iff this is a read (double-underscore) trap
* @param rp if this trap is being placed via a rootproxy, this is that proxy object.
*/
- static void addTrap(Box trapee, String name, JS.Function f, boolean isreadtrap, JS rp) {
+ static void addTrap(Box trapee, String name, CompiledFunction f, boolean isreadtrap, JS rp) {
if (PROHIBITED.get(name) != null || name.startsWith("xwt_")) {
Log.log(Trap.class, "Error: you cannot place traps on special property \"" + name + "\"");
if (PROHIBITED.get(name) != null || name.startsWith("xwt_")) {
Log.log(Trap.class, "Error: you cannot place traps on special property \"" + name + "\"");
@@
-80,7
+80,9
@@
public class Trap {
}
// find out what script is currently running
}
// find out what script is currently running
- String placerNodeName = JS.getCurrentFunctionSourceName();
+ CompiledFunction placer = Context.getContextForThread(Thread.currentThread()).getCurrentFunction();
+ if (placer == null) { Log.log(Trap.class, "placer is null"); return; }
+ String placerNodeName = placer.getSourceName();
// check if this script has already placed a trap on this property
if (trapee.traps == null) trapee.traps = new Hash(10, 3);
// check if this script has already placed a trap on this property
if (trapee.traps == null) trapee.traps = new Hash(10, 3);
@@
-108,7
+110,7
@@
public class Trap {
public static Trap getTrap(Box b, String name) {
if (b.traps == null) return null;
public static Trap getTrap(Box b, String name) {
if (b.traps == null) return null;
- String currentFunctionNodeName = JS.getCurrentFunctionSourceName();
+ String currentFunctionNodeName = Context.getContextForThread(Thread.currentThread()).getCurrentFunction().getSourceName();
for(Trap cur = (Trap)b.traps.get(name); cur != null; cur = cur.next)
if (cur.placerNodeName.equals(currentFunctionNodeName))
return cur;
for(Trap cur = (Trap)b.traps.get(name); cur != null; cur = cur.next)
if (cur.placerNodeName.equals(currentFunctionNodeName))
return cur;
@@
-118,10
+120,10
@@
public class Trap {
/** Called by Rhino's arguments.cascade. Note: cx will be null if this was invoked from perform() rather than from a script. */
public static final CascadeFunction cascadeFunction = new CascadeFunction();
/** Called by Rhino's arguments.cascade. Note: cx will be null if this was invoked from perform() rather than from a script. */
public static final CascadeFunction cascadeFunction = new CascadeFunction();
- private static class CascadeFunction extends JS.Function {
+ private static class CascadeFunction extends JS.Callable {
CascadeFunction() { setSeal(true); }
CascadeFunction() { setSeal(true); }
- public Object _call(JS.Array args) { return _call(args, JS.getCurrentFunction()); }
- public Object _call(JS.Array args, Function currentFunction) {
+ public Object call(Array args) { return call(args, Context.getContextForThread(Thread.currentThread()).getCurrentFunction()); }
+ public Object call(Array args, CompiledFunction currentFunction) {
Trap currentTrap = TrapContext.get().currentTrap;
if (args.length() != 0) TrapContext.get().putCascadeHappened = true;
Trap t = currentTrap.next;
Trap currentTrap = TrapContext.get().currentTrap;
if (args.length() != 0) TrapContext.get().putCascadeHappened = true;
Trap t = currentTrap.next;
@@
-156,7
+158,7
@@
public class Trap {
private Trap() { allTraps.put(myWeak, dummy); }
/** perform this trap -- arg.length == 0 if this is a get; otherwise it contains a single element to be put */
private Trap() { allTraps.put(myWeak, dummy); }
/** perform this trap -- arg.length == 0 if this is a get; otherwise it contains a single element to be put */
- public Object perform(JS.Array args) {
+ public Object perform(Array args) {
TrapContext tc = TrapContext.get();
// save both thread-locals on the stack and update their values
TrapContext tc = TrapContext.get();
// save both thread-locals on the stack and update their values
@@
-168,25
+170,19
@@
public class Trap {
// invoke the trap function
try {
// invoke the trap function
try {
- if (!isreadtrap && args.length() == 0) return cascadeFunction._call(args, f);
+ if (!isreadtrap && args.length() == 0) return cascadeFunction.call(args, f);
if (f == null) {
if (Log.verbose) Log.log(this, "debug: reclaimed a dangling trap on property " + name);
if (f == null) {
if (Log.verbose) Log.log(this, "debug: reclaimed a dangling trap on property " + name);
- Object ret = cascadeFunction._call(args, f);
+ Object ret = cascadeFunction.call(args, f);
delete();
return ret;
}
delete();
return ret;
}
- System.out.println("calling trap on " + name);
- Object ret = null;
- try {
- ret = f._call(args);
- } catch (org.xwt.js.ByteCodeBlock.ReturnException re) {
- ret = re.retval;
- }
+ Object ret = f.call(args);
// autocascade if required
// autocascade if required
- if (args.length() > 0 && !isreadtrap && !tc.putCascadeHappened) cascadeFunction._call(args, f);
+ if (args.length() > 0 && !isreadtrap && !tc.putCascadeHappened) cascadeFunction.call(args, f);
return ret;
return ret;