From 7334d6f1bbc7fdd32b99c137a1d86d7ad0818d02 Mon Sep 17 00:00:00 2001 From: crawshaw Date: Wed, 5 Jan 2005 10:34:22 +0000 Subject: [PATCH] remove dead code from JSScope darcs-hash:20050105103422-2eb37-c7b3346de9d4730e31ca337a73b388b8212dcbb5.gz --- src/org/ibex/js/JSScope.java | 140 ------------------------------------------ 1 file changed, 140 deletions(-) diff --git a/src/org/ibex/js/JSScope.java b/src/org/ibex/js/JSScope.java index 5dee438..5bd3a76 100644 --- a/src/org/ibex/js/JSScope.java +++ b/src/org/ibex/js/JSScope.java @@ -47,144 +47,4 @@ class JSScope { void put(int i, JS o) throws JSExn { if(i < base) parent.put(i,o); else vars[i-base] = o; } JS getGlobal() { return parent.getGlobal(); } - - /*private JSScope parentScope; - - private static final JS NULL_PLACEHOLDER = new JS() { }; - - public JSScope(JSScope parentScope) { this.parentScope = parentScope; } - public void declare(JS s) throws JSExn { super.put(s, NULL_PLACEHOLDER); } - public JSScope getParentScope() { return parentScope; } - - public JS get(JS key) throws JSExn { - JS o = super.get(key); - if (o != null) return o == NULL_PLACEHOLDER ? null : o; - else return parentScope == null ? null : parentScope.get(key); - } - - public boolean has(JS key) throws JSExn { return super.get(key) != null; } - public void put(JS key, JS val) throws JSExn { - if (parentScope != null && !has(key)) parentScope.put(key, val); - else super.put(key, val == null ? NULL_PLACEHOLDER : val); - } - - public JSScope top() { - JSScope s = this; - while(s.parentScope != null) s = s.parentScope; - return s; - } - - public static class Global extends JSScope { - private final static JS NaN = N(Double.NaN); - private final static JS POSITIVE_INFINITY = N(Double.POSITIVE_INFINITY); - - public Global() { super(null); } - public Global(JSScope p) { super(p); } - - public void declare(JS k) throws JSExn { throw new JSExn("can't declare variables in the global scope"); } - - // HACK: "this" gets lost on the way back through the scope chain - // We'll have to do something better with this when Scope is rewritten - public JS get(JS key) throws JSExn { - JS ret = _get(key); - if(ret == METHOD) return new Interpreter.Stub(this,key); - return ret; - } - - public JS _get(JS key) throws JSExn { - #switch(JS.str(key)) - case "NaN": return NaN; - case "Infinity": return POSITIVE_INFINITY; - case "undefined": return null; - case "stringFromCharCode": return METHOD; - case "parseInt": return METHOD; - case "parseFloat": return METHOD; - case "isNaN": return METHOD; - case "isFinite": return METHOD; - case "decodeURI": return METHOD; - case "decodeURIComponent": return METHOD; - case "encodeURI": return METHOD; - case "encodeURIComponent": return METHOD; - case "escape": return METHOD; - case "unescape": return METHOD; - #end - return super.get(key); - } - - public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn { - #switch(JS.str(method)) - case "parseInt": return parseInt(a0, N(0)); - case "parseFloat": return parseFloat(a0); - case "isNaN": { double d = toDouble(a0); return d == d ? F : T; } - case "isFinite": { double d = toDouble(a0); return (d == d && !Double.isInfinite(d)) ? T : F; } - case "decodeURI": throw new JSExn("unimplemented"); - case "decodeURIComponent": throw new JSExn("unimplemented"); - case "encodeURI": throw new JSExn("unimplemented"); - case "encodeURIComponent": throw new JSExn("unimplemented"); - case "escape": throw new JSExn("unimplemented"); - case "unescape": throw new JSExn("unimplemented"); - case "parseInt": return parseInt(a0, a1); - #end - return super.callMethod(method, a0, a1, a2, rest, nargs); - } - - private JS parseInt(JS arg, JS r) throws JSExn { - int radix = JS.toInt(r); - String s = JS.toString(arg); - int start = 0; - int length = s.length(); - int sign = 1; - long n = 0; - if(radix != 0 && (radix < 2 || radix > 36)) return NaN; - while(start < length && Character.isWhitespace(s.charAt(start))) start++; - if((length >= start+1) && (s.charAt(start) == '+' || s.charAt(start) == '-')) { - sign = s.charAt(start) == '+' ? 1 : -1; - start++; - } - if(radix == 0 && length >= start+1 && s.charAt(start) == '0') { - start++; - if(length >= start+1 && (s.charAt(start) == 'x' || s.charAt(start) == 'X')) { - start++; - radix = 16; - } else { - radix = 8; - if(length == start || Character.digit(s.charAt(start+1),8)==-1) return JS.ZERO; - } - } - if(radix == 0) radix = 10; - if(length == start || Character.digit(s.charAt(start),radix) == -1) return NaN; - // try the fast way first - try { - String s2 = start == 0 ? s : s.substring(start); - return JS.N(sign*Integer.parseInt(s2,radix)); - } catch(NumberFormatException e) { } - // fall through to a slower but emca-compliant method - for(int i=start;i