| 168 | } |
| 169 | |
| 170 | @Override |
| 171 | public void put(ExecutionContext context, final String name, final Object value, final boolean shouldThrow) { |
| 172 | |
| 173 | if ( this.externalIndexedData != null ) { |
| 174 | Long num = Types.toUint32(context, name); |
| 175 | if ( name.equals( num.toString() ) ) { |
| 176 | Object externValue = value; |
| 177 | if ( value == Types.UNDEFINED || value == Types.NULL ) { |
| 178 | externValue = null; |
| 179 | } |
| 180 | this.externalIndexedData.put( num, externValue ); |
| 181 | return; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | // 8.12.5 |
| 186 | // System.err.println("PUT " + name + " > " + value); |
| 187 | if (!canPut(context, name)) { |
| 188 | // System.err.println("CANNOT PUT"); |
| 189 | if (shouldThrow) { |
| 190 | throw new ThrowException(context, context.createTypeError("cannot put property '" + name + "'")); |
| 191 | } |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | Object ownDesc = getOwnProperty(context, name, false); |
| 196 | |
| 197 | if ((ownDesc != Types.UNDEFINED) && ((PropertyDescriptor) ownDesc).isDataDescriptor()) { |
| 198 | // System.err.println("setting value on non-UNDEF"); |
| 199 | PropertyDescriptor newDesc = new PropertyDescriptor(); |
| 200 | newDesc.setValue(value); |
| 201 | defineOwnProperty(context, name, newDesc, shouldThrow); |
| 202 | return; |
| 203 | } |
| 204 | |
| 205 | Object desc = getProperty(context, name, false); |
| 206 | |
| 207 | if ((desc != Types.UNDEFINED) && ((PropertyDescriptor) desc).isAccessorDescriptor()) { |
| 208 | JSFunction setter = (JSFunction) ((PropertyDescriptor) desc).getSetter(); |
| 209 | context.call(setter, this, value); |
| 210 | } else { |
| 211 | defineOwnProperty(context, name, |
| 212 | PropertyDescriptor.newDataPropertyDescriptor(value, true, true, true), shouldThrow); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public boolean canPut(ExecutionContext context, String name) { |