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

Method canPut

src/main/java/org/dynjs/runtime/DynObject.java:216–250  ·  view source on GitHub ↗
(ExecutionContext context, String name)

Source from the content-addressed store, hash-verified

214 }
215
216 @Override
217 public boolean canPut(ExecutionContext context, String name) {
218 // 8.12.4
219 Object d = getOwnProperty(context, name, false);
220
221 // Find the property on ourself, or our prototype
222 if (d == Types.UNDEFINED) {
223 if (this.prototype != null) {
224 d = this.prototype.getProperty(context, name, false);
225 }
226 }
227
228 // System.err.println("canPut?: " + name + " > " + d);
229
230 // If either has it, deal with descriptor appropriately
231 if (d != Types.UNDEFINED) {
232 PropertyDescriptor desc = (PropertyDescriptor) d;
233 if (desc.isAccessorDescriptor()) {
234 if (desc.getSetter() == Types.UNDEFINED) {
235 // System.err.println("NO SET");
236 return false;
237 }
238 return true;
239 } else {
240 // System.err.println("writable? " + writable);
241 if (!desc.hasWritable()) {
242 return true;
243 }
244 return desc.isWritable();
245 }
246 }
247
248 // Else, just determine if we are extensible directly
249 return isExtensible();
250 }
251
252 @Override
253 public boolean delete(ExecutionContext context, String name, boolean shouldThrow) {

Callers 1

putMethod · 0.95

Calls 7

getOwnPropertyMethod · 0.95
isAccessorDescriptorMethod · 0.95
getSetterMethod · 0.95
hasWritableMethod · 0.95
isWritableMethod · 0.95
isExtensibleMethod · 0.95
getPropertyMethod · 0.65

Tested by

no test coverage detected