projects
/
org.ibex.core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5133ba9
)
give an error when trying to trap private variables
author
brian
<brian@brianweb.net>
Wed, 2 Jun 2004 02:18:09 +0000
(
02:18
+0000)
committer
brian
<brian@brianweb.net>
Wed, 2 Jun 2004 02:18:09 +0000
(
02:18
+0000)
darcs-hash:
20040602021809
-24bed-
5a2b5c39ced1846a3557574c9875dc51ee25f9c9
.gz
src/org/ibex/js/Interpreter.java
patch
|
blob
|
history
diff --git
a/src/org/ibex/js/Interpreter.java
b/src/org/ibex/js/Interpreter.java
index
983b471
..
e89f752
100644
(file)
--- a/
src/org/ibex/js/Interpreter.java
+++ b/
src/org/ibex/js/Interpreter.java
@@
-402,7
+402,17
@@
class Interpreter implements ByteCodes, Tokens {
Object key = stack.pop();
Object obj = stack.peek();
// A trap addition/removal
Object key = stack.pop();
Object obj = stack.peek();
// A trap addition/removal
- JS js = obj instanceof JSScope ? ((JSScope)obj).top() : (JS) obj;
+ JS js = (JS) obj;
+ if(js instanceof JSScope) {
+ JSScope s = (JSScope) js;
+ while(s.getParentScope() != null) {
+ if(s.has(key)) throw new JSExn("cannot trap a variable that isn't at the top level scope");
+ s = s.getParentScope();
+ }
+ js = s;
+ }
+ // might want this?
+ // if(!js.has(key)) throw new JSExn("tried to add/remove a trap from an uninitialized variable");
if(op == ADD_TRAP) js.addTrap(key, (JSFunction)val);
else js.delTrap(key, (JSFunction)val);
break;
if(op == ADD_TRAP) js.addTrap(key, (JSFunction)val);
else js.delTrap(key, (JSFunction)val);
break;