src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java

Print this page




3693         return true;
3694     }
3695 
3696     /**
3697      * Return a shallow copy of this ScriptObject.
3698      * @return a shallow copy.
3699      */
3700     public final ScriptObject copy() {
3701         try {
3702             return clone();
3703         } catch (final CloneNotSupportedException e) {
3704             throw new RuntimeException(e);
3705         }
3706     }
3707 
3708     @Override
3709     protected ScriptObject clone() throws CloneNotSupportedException {
3710         final ScriptObject clone = (ScriptObject) super.clone();
3711         if (objectSpill != null) {
3712             clone.objectSpill = objectSpill.clone();

3713             clone.primitiveSpill = primitiveSpill.clone();

3714         }
3715         clone.arrayData = arrayData.copy();
3716         return clone;
3717     }
3718 
3719     /**
3720      * Make a new UserAccessorProperty property. getter and setter functions are stored in
3721      * this ScriptObject and slot values are used in property object.
3722      *
3723      * @param key the property name
3724      * @param propertyFlags attribute flags of the property
3725      * @param getter getter function for the property
3726      * @param setter setter function for the property
3727      * @return the newly created UserAccessorProperty
3728      */
3729     protected final UserAccessorProperty newUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
3730         final UserAccessorProperty uc = getMap().newUserAccessors(key, propertyFlags);
3731         //property.getSetter(Object.class, getMap());
3732         uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter));
3733         return uc;




3693         return true;
3694     }
3695 
3696     /**
3697      * Return a shallow copy of this ScriptObject.
3698      * @return a shallow copy.
3699      */
3700     public final ScriptObject copy() {
3701         try {
3702             return clone();
3703         } catch (final CloneNotSupportedException e) {
3704             throw new RuntimeException(e);
3705         }
3706     }
3707 
3708     @Override
3709     protected ScriptObject clone() throws CloneNotSupportedException {
3710         final ScriptObject clone = (ScriptObject) super.clone();
3711         if (objectSpill != null) {
3712             clone.objectSpill = objectSpill.clone();
3713             if (primitiveSpill != null) {
3714                 clone.primitiveSpill = primitiveSpill.clone();
3715             }
3716         }
3717         clone.arrayData = arrayData.copy();
3718         return clone;
3719     }
3720 
3721     /**
3722      * Make a new UserAccessorProperty property. getter and setter functions are stored in
3723      * this ScriptObject and slot values are used in property object.
3724      *
3725      * @param key the property name
3726      * @param propertyFlags attribute flags of the property
3727      * @param getter getter function for the property
3728      * @param setter setter function for the property
3729      * @return the newly created UserAccessorProperty
3730      */
3731     protected final UserAccessorProperty newUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
3732         final UserAccessorProperty uc = getMap().newUserAccessors(key, propertyFlags);
3733         //property.getSetter(Object.class, getMap());
3734         uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter));
3735         return uc;