fix nasty bug in numerical comparison in Interpreter
[org.ibex.js.git] / src / org / ibex / js / JSSubProperties.java
1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
4
5 package org.ibex.js;
6
7 // FEATURE: cache JSSubProperties.Sub
8 public abstract class JSSubProperties extends JS.Immutable {
9     protected static final JS SUBPROPERTY = new JS.Immutable();
10     public abstract JS _get(JS key) throws JSExn;
11     public final JS get(JS key) throws JSExn {
12         JS ret = _get(key);
13         return ret==SUBPROPERTY ? new Sub(key) : ret;
14     }
15     private class Sub extends JS.Immutable {
16         final JS key;
17         Sub(JS key) { this.key = key; }
18         public void put(JS key, JS val) throws JSExn {
19             JSSubProperties.this.put(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key)), val); }
20         public JS get(JS key) throws JSExn {
21             return JSSubProperties.this.get(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key))); }
22         public JS call(JS method, JS[] args) throws JSExn {
23             return JSSubProperties.this.call(JSU.S(JSU.toString(this.key) + "." + JSU.toString(method)), args); }
24     }
25 }