From 10d0296318104e8b9ac8afbea71ef118aa77387c Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 07:02:00 +0000 Subject: [PATCH] 2003/06/18 07:38:54 darcs-hash:20040130070200-2ba56-5a74941cdd63e5c565da0c7be285168967746e5c.gz --- src/org/xwt/js/ArrayImpl.java | 4 +++- src/org/xwt/js/JS.java | 8 ++++---- src/org/xwt/js/Parser.java | 15 +++++++-------- src/org/xwt/js/ScopeImpl.java | 6 ++++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/org/xwt/js/ArrayImpl.java b/src/org/xwt/js/ArrayImpl.java index 22e9f23..c4e4bf6 100644 --- a/src/org/xwt/js/ArrayImpl.java +++ b/src/org/xwt/js/ArrayImpl.java @@ -23,7 +23,8 @@ class ArrayImpl extends JS.Obj { for(int i=0; i '9') return Integer.MIN_VALUE; return Integer.parseInt(s); } - public Object get(Object key) throws JS.Exn { + // we use _get instead of get solely to work around a GCJ bug + public Object _get(Object key) throws JS.Exn { // FIXME: HACK! if (key.equals("cascade")) return org.xwt.Trap.cascadeFunction; if (key.equals("trapee")) return org.xwt.Trap.currentTrapee(); @@ -36,6 +37,7 @@ class ArrayImpl extends JS.Obj { return null; } } + // we use _put instead of put solely to work around a GCJ bug public void put(Object key, Object val) { if (key.equals("length")) vec.setSize(toNumber(val).intValue()); int i = intVal(key); diff --git a/src/org/xwt/js/JS.java b/src/org/xwt/js/JS.java index b89b61c..094eba1 100644 --- a/src/org/xwt/js/JS.java +++ b/src/org/xwt/js/JS.java @@ -92,8 +92,8 @@ public abstract class JS { public Object elementAt(int i) { return super.elementAt(i); } public void addElement(Object o) { super.addElement(o); } public void setElementAt(Object o, int i) { super.setElementAt(o, i); } - public Object get(Object key) { return super.get(key); } - public void put(Object key, Object val) { super.put(key, val); } + public Object get(Object key) { return super._get(key); } + public void put(Object key, Object val) { super._put(key, val); } } /** Any object which becomes part of the scope chain must support this interface */ @@ -103,8 +103,8 @@ public abstract class JS { /** transparent scopes are not returned by THIS */ public boolean isTransparent() { return super.isTransparent(); } public boolean has(Object key) { return super.has(key); } - public Object get(Object key) { return super.get(key); } - public void put(Object key, Object val) { super.put(key, val); } + public Object get(Object key) { return super._get(key); } + public void put(Object key, Object val) { super._put(key, val); } public void declare(String s) { super.declare(s); } } diff --git a/src/org/xwt/js/Parser.java b/src/org/xwt/js/Parser.java index c3f90ca..670f68e 100644 --- a/src/org/xwt/js/Parser.java +++ b/src/org/xwt/js/Parser.java @@ -133,7 +133,7 @@ class Parser extends Lexer implements ByteCodes { /** gets a token and throws an exception if it is not code */ private void consume(int code) throws IOException { - if (getToken() != code) throw new ParserException("expected " + codeToString[code] + ", got " + (op == -1 ? "EOF" : codeToString[op])); + if (getToken() != code) throw pe("expected " + codeToString[code] + ", got " + (op == -1 ? "EOF" : codeToString[op])); } /** @@ -152,7 +152,7 @@ class Parser extends Lexer implements ByteCodes { CompiledFunctionImpl b = appendTo; switch (tok) { - case -1: throw new ParserException("expected expression"); + case -1: throw pe("expected expression"); // all of these simply push values onto the stack case NUMBER: b.add(parserLine, LITERAL, number); break; @@ -195,7 +195,7 @@ class Parser extends Lexer implements ByteCodes { case INC: case DEC: { // prefix (not postfix) startExpr(b, precedence[tok]); if (b.get(b.size() - 1) != GET) - throw new ParserException("prefixed increment/decrement can only be performed on a valid assignment target"); + throw pe("prefixed increment/decrement can only be performed on a valid assignment target"); b.set(b.size() - 1, tok, new Boolean(true)); break; } @@ -209,7 +209,7 @@ class Parser extends Lexer implements ByteCodes { if (peekToken() != RC) while(true) { if (peekToken() != NAME && peekToken() != STRING) - throw new ParserException("expected NAME or STRING"); + throw pe("expected NAME or STRING"); getToken(); b.add(parserLine, LITERAL, string); // grab the key consume(COLON); @@ -284,7 +284,7 @@ class Parser extends Lexer implements ByteCodes { break; } - default: throw new ParserException("expected expression, found " + codeToString[tok] + ", which cannot start an expression"); + default: throw pe("expected expression, found " + codeToString[tok] + ", which cannot start an expression"); } // attempt to continue the expression @@ -561,7 +561,7 @@ class Parser extends Lexer implements ByteCodes { b.add(parserLine, BREAK); // break out of the loop if we 'fall through' break; } else { - throw new ParserException("expected CASE, DEFAULT, or RC; got " + codeToString[peekToken()]); + throw pe("expected CASE, DEFAULT, or RC; got " + codeToString[peekToken()]); } b.set(size0 - 1, new Integer(b.size() - size0 + 1)); // end of the loop break; @@ -735,8 +735,7 @@ class Parser extends Lexer implements ByteCodes { // ParserException ////////////////////////////////////////////////////////////////////// - - private class ParserException extends IOException { public ParserException(String s) { super(sourceName + ":" + parserLine + " " + s); } } + private IOException pe(String s) { return new IOException(sourceName + ":" + parserLine + " " + s); } } diff --git a/src/org/xwt/js/ScopeImpl.java b/src/org/xwt/js/ScopeImpl.java index 5162c0e..bf5acc9 100644 --- a/src/org/xwt/js/ScopeImpl.java +++ b/src/org/xwt/js/ScopeImpl.java @@ -16,11 +16,13 @@ class ScopeImpl extends JS.Obj { } public Object[] keys() { throw new Error("you can't enumerate the properties of a Scope"); } public boolean has(Object key) { return super.get(key) != null; } - public Object get(Object key) { + // we use _get instead of get solely to work around a GCJ bug + public Object _get(Object key) { if (!has(key)) return parentScope == null ? null : parentScope.get(key); Object ret = super.get(key); return ret == NULL ? null : ret; } - public void put(Object key, Object val) { + // we use _put instead of put solely to work around a GCJ bug + public void _put(Object key, Object val) { if (!has(key) && parentScope != null) parentScope.put(key, val); else super.put(key, val == null ? NULL : val); } -- 1.7.10.4