379 return new ValueIterator(this); 380 } 381 382 /** 383 * ECMA 8.10.1 IsAccessorDescriptor ( Desc ) 384 * @return true if this has a {@link AccessorPropertyDescriptor} with a getter or a setter 385 */ 386 public final boolean isAccessorDescriptor() { 387 return has(GET) || has(SET); 388 } 389 390 /** 391 * ECMA 8.10.2 IsDataDescriptor ( Desc ) 392 * @return true if this has a {@link DataPropertyDescriptor}, i.e. the object has a property value and is writable 393 */ 394 public final boolean isDataDescriptor() { 395 return has(VALUE) || has(WRITABLE); 396 } 397 398 /** 399 * ECMA 8.10.3 IsGenericDescriptor ( Desc ) 400 * @return true if this has a descriptor describing an {@link AccessorPropertyDescriptor} or {@link DataPropertyDescriptor} 401 */ 402 public final boolean isGenericDescriptor() { 403 return isAccessorDescriptor() || isDataDescriptor(); 404 } 405 406 /** 407 * ECMA 8.10.5 ToPropertyDescriptor ( Obj ) 408 * 409 * @return property descriptor 410 */ 411 public final PropertyDescriptor toPropertyDescriptor() { 412 final Global global = Context.getGlobal(); 413 414 final PropertyDescriptor desc; 415 if (isDataDescriptor()) { 416 if (has(SET) || has(GET)) { 417 throw typeError(global, "inconsistent.property.descriptor"); 418 } 419 420 desc = global.newDataDescriptor(UNDEFINED, false, false, false); 421 } else if (isAccessorDescriptor()) { 422 if (has(VALUE) || has(WRITABLE)) { 423 throw typeError(global, "inconsistent.property.descriptor"); 424 } 425 426 desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false); | 379 return new ValueIterator(this); 380 } 381 382 /** 383 * ECMA 8.10.1 IsAccessorDescriptor ( Desc ) 384 * @return true if this has a {@link AccessorPropertyDescriptor} with a getter or a setter 385 */ 386 public final boolean isAccessorDescriptor() { 387 return has(GET) || has(SET); 388 } 389 390 /** 391 * ECMA 8.10.2 IsDataDescriptor ( Desc ) 392 * @return true if this has a {@link DataPropertyDescriptor}, i.e. the object has a property value and is writable 393 */ 394 public final boolean isDataDescriptor() { 395 return has(VALUE) || has(WRITABLE); 396 } 397 398 /** 399 * ECMA 8.10.5 ToPropertyDescriptor ( Obj ) 400 * 401 * @return property descriptor 402 */ 403 public final PropertyDescriptor toPropertyDescriptor() { 404 final Global global = Context.getGlobal(); 405 406 final PropertyDescriptor desc; 407 if (isDataDescriptor()) { 408 if (has(SET) || has(GET)) { 409 throw typeError(global, "inconsistent.property.descriptor"); 410 } 411 412 desc = global.newDataDescriptor(UNDEFINED, false, false, false); 413 } else if (isAccessorDescriptor()) { 414 if (has(VALUE) || has(WRITABLE)) { 415 throw typeError(global, "inconsistent.property.descriptor"); 416 } 417 418 desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false); |