src/jdk/nashorn/internal/runtime/AccessorProperty.java

Print this page




 140      */
 141     private Class<?> currentType;
 142 
 143     /**
 144      * Delegate constructor. This is used when adding properties to the Global scope, which
 145      * is necessary for outermost levels in a script (the ScriptObject is represented by
 146      * a JO-prefixed ScriptObject class, but the properties need to be in the Global scope
 147      * and are thus rebound with that as receiver
 148      *
 149      * @param property  accessor property to rebind
 150      * @param delegate  delegate object to rebind receiver to
 151      */
 152     AccessorProperty(final AccessorProperty property, final Object delegate) {
 153         super(property);
 154 
 155         this.primitiveGetter = bindTo(property.primitiveGetter, delegate);
 156         this.primitiveSetter = bindTo(property.primitiveSetter, delegate);
 157         this.objectGetter    = bindTo(property.ensureObjectGetter(), delegate);
 158         this.objectSetter    = bindTo(property.ensureObjectSetter(), delegate);
 159 

 160         setCurrentType(property.getCurrentType());
 161     }
 162 
 163     /**
 164      * Constructor for spill properties. Array getters and setters will be created on demand.
 165      *
 166      * @param key    the property key
 167      * @param flags  the property flags
 168      * @param slot   spill slot
 169      */
 170     public AccessorProperty(final String key, final int flags, final int slot) {
 171         super(key, flags, slot);
 172         assert (flags & IS_SPILL) == IS_SPILL;
 173 
 174         setCurrentType(Object.class);
 175     }
 176 
 177     /**
 178      * Constructor. Similar to the constructor with both primitive getters and setters, the difference
 179      * here being that only one getter and setter (setter is optional for non writable fields) is given




 140      */
 141     private Class<?> currentType;
 142 
 143     /**
 144      * Delegate constructor. This is used when adding properties to the Global scope, which
 145      * is necessary for outermost levels in a script (the ScriptObject is represented by
 146      * a JO-prefixed ScriptObject class, but the properties need to be in the Global scope
 147      * and are thus rebound with that as receiver
 148      *
 149      * @param property  accessor property to rebind
 150      * @param delegate  delegate object to rebind receiver to
 151      */
 152     AccessorProperty(final AccessorProperty property, final Object delegate) {
 153         super(property);
 154 
 155         this.primitiveGetter = bindTo(property.primitiveGetter, delegate);
 156         this.primitiveSetter = bindTo(property.primitiveSetter, delegate);
 157         this.objectGetter    = bindTo(property.ensureObjectGetter(), delegate);
 158         this.objectSetter    = bindTo(property.ensureObjectSetter(), delegate);
 159 
 160         this.flags |= IS_BOUND;
 161         setCurrentType(property.getCurrentType());
 162     }
 163 
 164     /**
 165      * Constructor for spill properties. Array getters and setters will be created on demand.
 166      *
 167      * @param key    the property key
 168      * @param flags  the property flags
 169      * @param slot   spill slot
 170      */
 171     public AccessorProperty(final String key, final int flags, final int slot) {
 172         super(key, flags, slot);
 173         assert (flags & IS_SPILL) == IS_SPILL;
 174 
 175         setCurrentType(Object.class);
 176     }
 177 
 178     /**
 179      * Constructor. Similar to the constructor with both primitive getters and setters, the difference
 180      * here being that only one getter and setter (setter is optional for non writable fields) is given