2003/07/05 02:38:15
[org.ibex.core.git] / src / org / xwt / js / CompiledFunctionImpl.java
index 5aff71a..ae344d0 100644 (file)
@@ -33,7 +33,6 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
     /** the scope in which this function was declared; by default this function is called in a fresh subscope of the parentScope */
     private JS.Scope parentScope;
 
-
     // Constructors ////////////////////////////////////////////////////////
 
     private CompiledFunctionImpl cloneWithNewParentScope(JS.Scope s) throws IOException {
@@ -136,11 +135,10 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
             case TYPEOF: {
                 Object o = t.pop();
                 if (o == null) t.push(null);
-                else if (o instanceof org.xwt.Box) t.push("Box");
-                else if (o instanceof JS) t.push("Object");
-                else if (o instanceof String) t.push("String");
-                else if (o instanceof Number) t.push("Number");
-                else if (o.getClass().getName().startsWith("org.xwt.js.")) t.push(o.getClass().getName().substring(11));
+                else if (o instanceof JS) t.push(((JS)o).typeName());
+                else if (o instanceof String) t.push("string");
+                else if (o instanceof Number) t.push("number");
+                else if (o instanceof Boolean) t.push("boolean");
                 else t.push("unknown");
                 break;
             }
@@ -215,6 +213,8 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
                     throw je("tried to put a value to the " + key + " property on the null value");
                 if (!(target instanceof JS))
                     throw je("tried to put a value to the " + key + " property on a " + target.getClass().getName());
+                if (key == null)
+                    throw je("tried to assign \"" + (val==null?"(null)":val.toString()) + "\" to the null key");
                 ((JS)target).put(key, val);
                 t.push(val);
                 break;
@@ -449,12 +449,6 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
         String sourceName;
         public FunctionScope(String sourceName, Scope parentScope) { super(parentScope); this.sourceName = sourceName; }
         public String getSourceName() { return sourceName; }
-        public Object get(Object key) throws JS.Exn {
-            if (key.equals("trapee")) return org.xwt.Trap.currentTrapee();
-            else if (key.equals("trapname")) return org.xwt.Trap.currentTrapname();
-            else if (key.equals("cascade")) return org.xwt.Trap.cascadeFunction;
-            return super.get(key);
-        }
     }