MCPcopy Create free account
hub / github.com/dynjs/dynjs / put

Method put

src/main/java/org/dynjs/runtime/DynObject.java:170–214  ·  view source on GitHub ↗
(ExecutionContext context, final String name, final Object value, final boolean shouldThrow)

Source from the content-addressed store, hash-verified

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) {

Callers 7

setupConsoleMethod · 0.95
interpretMethod · 0.95
singleAbstractMethodMethod · 0.95
createShadowMethod · 0.95
RequireMethod · 0.95
callMethod · 0.95
parseObjectMethod · 0.95

Calls 15

toUint32Method · 0.95
canPutMethod · 0.95
getOwnPropertyMethod · 0.95
setValueMethod · 0.95
defineOwnPropertyMethod · 0.95
getPropertyMethod · 0.95
getMethod · 0.95
createTypeErrorMethod · 0.80
isDataDescriptorMethod · 0.80
isAccessorDescriptorMethod · 0.80
getSetterMethod · 0.80

Tested by 1

setupConsoleMethod · 0.76