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

changeset 344
b0dcc3727fc3
parent 334
918a986b0478
child 350
3d947baa33cc
     1.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Wed Jun 12 16:41:38 2013 +0200
     1.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Thu Jun 13 16:08:35 2013 +0530
     1.3 @@ -105,6 +105,9 @@
     1.4      /** Is this a prototype PropertyMap? */
     1.5      public static final int IS_PROTOTYPE   = 0b0000_1000;
     1.6  
     1.7 +    /** Is length property not-writable? */
     1.8 +    public static final int IS_LENGTH_NOT_WRITABLE = 0b0001_0000;
     1.9 +
    1.10      /** Spill growth rate - by how many elements does {@link ScriptObject#spill} when full */
    1.11      public static final int SPILL_RATE = 8;
    1.12  
    1.13 @@ -443,7 +446,7 @@
    1.14              if (newValue && property != null) {
    1.15                  // Temporarily clear flags.
    1.16                  property = modifyOwnProperty(property, 0);
    1.17 -                set(key, value, getContext()._strict);
    1.18 +                set(key, value, false);
    1.19              }
    1.20  
    1.21              if (property == null) {
    1.22 @@ -998,7 +1001,7 @@
    1.23       * @param value the value to write at the given index
    1.24       */
    1.25      public void setArgument(final int key, final Object value) {
    1.26 -        set(key, value, getContext()._strict);
    1.27 +        set(key, value, false);
    1.28      }
    1.29  
    1.30      /**
    1.31 @@ -1277,14 +1280,14 @@
    1.32       *
    1.33       * @return {@code true} if is prototype
    1.34       */
    1.35 -    public boolean isPrototype() {
    1.36 +    public final boolean isPrototype() {
    1.37          return (flags & IS_PROTOTYPE) != 0;
    1.38      }
    1.39  
    1.40      /**
    1.41       * Flag this object as having a prototype.
    1.42       */
    1.43 -    public void setIsPrototype() {
    1.44 +    public final void setIsPrototype() {
    1.45          if (proto != null && !isPrototype()) {
    1.46              proto.addPropertyListener(this);
    1.47          }
    1.48 @@ -1292,6 +1295,22 @@
    1.49      }
    1.50  
    1.51      /**
    1.52 +     * Check if this object has non-writable length property
    1.53 +     *
    1.54 +     * @return {@code true} if 'length' property is non-writable
    1.55 +     */
    1.56 +    public final boolean isLengthNotWritable() {
    1.57 +        return (flags & IS_LENGTH_NOT_WRITABLE) != 0;
    1.58 +    }
    1.59 +
    1.60 +    /**
    1.61 +     * Flag this object as having non-writable length property
    1.62 +     */
    1.63 +    public void setIsLengthNotWritable() {
    1.64 +        flags |= IS_LENGTH_NOT_WRITABLE;
    1.65 +    }
    1.66 +
    1.67 +    /**
    1.68       * Get the {@link ArrayData} for this ScriptObject if it is an array
    1.69       * @return array data
    1.70       */
    1.71 @@ -1393,7 +1412,7 @@
    1.72       * (java.util.Map-like method to help ScriptObjectMirror implementation)
    1.73       */
    1.74      public void clear() {
    1.75 -        final boolean strict = getContext()._strict;
    1.76 +        final boolean strict = isStrictContext();
    1.77          final Iterator<String> iter = propertyIterator();
    1.78          while (iter.hasNext()) {
    1.79              delete(iter.next(), strict);
    1.80 @@ -1481,7 +1500,7 @@
    1.81       */
    1.82      public Object put(final Object key, final Object value) {
    1.83          final Object oldValue = get(key);
    1.84 -        set(key, value, getContext()._strict);
    1.85 +        set(key, value, isStrictContext());
    1.86          return oldValue;
    1.87      }
    1.88  
    1.89 @@ -1493,7 +1512,7 @@
    1.90       * @param otherMap a {@literal <key,value>} map of properties to add
    1.91       */
    1.92      public void putAll(final Map<?, ?> otherMap) {
    1.93 -        final boolean strict = getContext()._strict;
    1.94 +        final boolean strict = isStrictContext();
    1.95          for (final Map.Entry<?, ?> entry : otherMap.entrySet()) {
    1.96              set(entry.getKey(), entry.getValue(), strict);
    1.97          }
    1.98 @@ -1508,7 +1527,7 @@
    1.99       */
   1.100      public Object remove(final Object key) {
   1.101          final Object oldValue = get(key);
   1.102 -        delete(key, getContext()._strict);
   1.103 +        delete(key, isStrictContext());
   1.104          return oldValue;
   1.105      }
   1.106  
   1.107 @@ -1520,7 +1539,7 @@
   1.108       * @return if the delete was successful or not
   1.109       */
   1.110      public boolean delete(final Object key) {
   1.111 -        return delete(key, getContext()._strict);
   1.112 +        return delete(key, isStrictContext());
   1.113      }
   1.114  
   1.115      /**
   1.116 @@ -2222,7 +2241,7 @@
   1.117             return;
   1.118         }
   1.119  
   1.120 -       final boolean isStrict = getContext()._strict;
   1.121 +       final boolean isStrict = isStrictContext();
   1.122  
   1.123         if (newLength > arrayLength) {
   1.124             setArray(getArray().ensure(newLength - 1));

mercurial