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

Print this page

        

*** 118,130 **** private PropertyMap map; /** objects proto. */ private ScriptObject proto; - /** Context of the object, lazily cached. */ - private Context context; - /** Object flags. */ private int flags; /** Area for properties added to object after instantiation, see {@link AccessorProperty} */ public Object[] spill; --- 118,127 ----
*** 1041,1084 **** public void setArgument(final int key, final Object value) { set(key, value, false); } /** - * Return true if the script object context is strict - * @return true if strict context - */ - public final boolean isStrictContext() { - return getContext()._strict; - } - - /** - * Checks if this object belongs to the given context - * @param ctx context to check against - * @return true if this object belongs to the given context - */ - public final boolean isOfContext(final Context ctx) { - return context == ctx; - } - - /** * Return the current context from the object's map. * @return Current context. */ ! protected final Context getContext() { ! if (context == null) { ! context = Context.fromClass(getClass()); ! } ! return context; ! } ! ! /** ! * Set the current context. ! * @param ctx context instance to set ! */ ! protected final void setContext(final Context ctx) { ! ctx.getClass(); ! this.context = ctx; } /** * Return the map of an object. * @return PropertyMap object. --- 1038,1052 ---- public void setArgument(final int key, final Object value) { set(key, value, false); } /** * Return the current context from the object's map. * @return Current context. */ ! protected Context getContext() { ! return Context.fromClass(getClass()); } /** * Return the map of an object. * @return PropertyMap object.
*** 1480,1492 **** } /** * Clears the properties from a ScriptObject * (java.util.Map-like method to help ScriptObjectMirror implementation) */ ! public void clear() { ! final boolean strict = isStrictContext(); final Iterator<String> iter = propertyIterator(); while (iter.hasNext()) { delete(iter.next(), strict); } } --- 1448,1461 ---- } /** * Clears the properties from a ScriptObject * (java.util.Map-like method to help ScriptObjectMirror implementation) + * + * @param strict strict mode or not */ ! public void clear(final boolean strict) { final Iterator<String> iter = propertyIterator(); while (iter.hasNext()) { delete(iter.next(), strict); } }
*** 1566,1622 **** * Put a property in the ScriptObject * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @param key property key * @param value property value * @return oldValue if property with same key existed already */ ! public Object put(final Object key, final Object value) { final Object oldValue = get(key); ! set(key, value, isStrictContext()); return oldValue; } /** * Put several properties in the ScriptObject given a mapping * of their keys to their values * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @param otherMap a {@literal <key,value>} map of properties to add */ ! public void putAll(final Map<?, ?> otherMap) { ! final boolean strict = isStrictContext(); for (final Map.Entry<?, ?> entry : otherMap.entrySet()) { set(entry.getKey(), entry.getValue(), strict); } } /** * Remove a property from the ScriptObject. * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @param key the key of the property * @return the oldValue of the removed property */ ! public Object remove(final Object key) { final Object oldValue = get(key); ! delete(key, isStrictContext()); return oldValue; } /** - * Delete a property from the ScriptObject. - * (to help ScriptObjectMirror implementation) - * - * @param key the key of the property - * @return if the delete was successful or not - */ - public boolean delete(final Object key) { - return delete(key, isStrictContext()); - } - - /** * Return the size of the ScriptObject - i.e. the number of properties * it contains * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @return number of properties in ScriptObject --- 1535,1582 ---- * Put a property in the ScriptObject * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @param key property key * @param value property value + * @param strict strict mode or not * @return oldValue if property with same key existed already */ ! public Object put(final Object key, final Object value, final boolean strict) { final Object oldValue = get(key); ! set(key, value, strict); return oldValue; } /** * Put several properties in the ScriptObject given a mapping * of their keys to their values * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @param otherMap a {@literal <key,value>} map of properties to add + * @param strict strict mode or not */ ! public void putAll(final Map<?, ?> otherMap, final boolean strict) { for (final Map.Entry<?, ?> entry : otherMap.entrySet()) { set(entry.getKey(), entry.getValue(), strict); } } /** * Remove a property from the ScriptObject. * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @param key the key of the property + * @param strict strict mode or not * @return the oldValue of the removed property */ ! public Object remove(final Object key, final boolean strict) { final Object oldValue = get(key); ! delete(key, strict); return oldValue; } /** * Return the size of the ScriptObject - i.e. the number of properties * it contains * (java.util.Map-like method to help ScriptObjectMirror implementation) * * @return number of properties in ScriptObject
*** 2331,2345 **** final long arrayLength = getArray().length(); if (newLength == arrayLength) { return; } - final boolean isStrict = isStrictContext(); - if (newLength > arrayLength) { setArray(getArray().ensure(newLength - 1)); ! if (getArray().canDelete(arrayLength, (newLength - 1), isStrict)) { setArray(getArray().delete(arrayLength, (newLength - 1))); } return; } --- 2291,2303 ---- final long arrayLength = getArray().length(); if (newLength == arrayLength) { return; } if (newLength > arrayLength) { setArray(getArray().ensure(newLength - 1)); ! if (getArray().canDelete(arrayLength, (newLength - 1), false)) { setArray(getArray().delete(arrayLength, (newLength - 1))); } return; }