From 9b9482f2939c8cb7526a8ca7ff43a7f2c2b5f97a Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 06:59:47 +0000 Subject: [PATCH] 2003/05/03 08:46:05 darcs-hash:20040130065947-2ba56-159081d977bb6d0139d3c4153ebd90a7d1b4b86a.gz --- src/org/xwt/js/JS.java | 10 +++--- src/org/xwt/js/Parser.java | 85 +++++++++++++++----------------------------- 2 files changed, 34 insertions(+), 61 deletions(-) diff --git a/src/org/xwt/js/JS.java b/src/org/xwt/js/JS.java index 1da4c54..51929af 100644 --- a/src/org/xwt/js/JS.java +++ b/src/org/xwt/js/JS.java @@ -3,16 +3,18 @@ package org.xwt.js; import org.xwt.util.*; -/** all objects other than Strings and Numbers which are exposed to JS code must implement this interface */ +/** The public API for the JS engine */ public interface JS { public Object get(Object key) throws JS.Exn; public Object put(Object key, Object val) throws JS.Exn; public Object[] enumerateProperties(); public String coerceToString() throws JS.Exn; + /* public Num coerceToNumber() throws JS.Exn; + public boolean coerceToBoolean() throws JS.Exn; public Object call(Object[] args) throws JS.Exn; - + */ /** if JS calls a Java method, and the Java method throws an exception, it can only be caught by JS if it is a subclass of Exn. */ public static class Exn extends RuntimeException { private Object js = null; @@ -28,10 +30,10 @@ public interface JS { } /** A mutable, boxed numeric value. These are recycled -- never duplicate references -- use duplicate() instead. */ + /* public static class Num implements Cloneable, JS { private Num() { } - public boolean isDouble = false; public long longVal = -1; public double doubleVal = -1; @@ -48,6 +50,6 @@ public interface JS { public String coerceToString() throws JS.Exn { return isDouble ? String.valueOf(doubleVal) : String.valueOf(longVal); } public Num coerceToNumber() throws JS.Exn { return duplicate(); } public Object call(Object[] args) throws JS.Exn { throw new JS.Exn("attempt to apply the () operator to a Number"); } - } + */ } diff --git a/src/org/xwt/js/Parser.java b/src/org/xwt/js/Parser.java index 0535d50..82da503 100644 --- a/src/org/xwt/js/Parser.java +++ b/src/org/xwt/js/Parser.java @@ -46,42 +46,8 @@ public class Parser extends Lexer { } - // Useful Types ///////////////////////////////////////////////////////// - - /** sorta like gcc trees */ - public static class Expr { - - int code = -1; - - Expr left = null; - Expr right = null; - Expr next = null; // if this expr is part of a list - - String string = null; - Number number = null; - - public String toString() { return toString(0); } - public String toString(int indent) { - String ret = ""; - for(int i=0; i