MCPcopy Create free account
hub / github.com/dop251/goja / defineArrayLength

Method defineArrayLength

array.go:381–420  ·  view source on GitHub ↗
(prop *valueProperty, descr PropertyDescriptor, setter func(uint32, bool) bool, throw bool)

Source from the content-addressed store, hash-verified

379}
380
381func (r *Runtime) defineArrayLength(prop *valueProperty, descr PropertyDescriptor, setter func(uint32, bool) bool, throw bool) bool {
382 var newLen uint32
383 ret := true
384 if descr.Value != nil {
385 newLen = r.toLengthUint32(descr.Value)
386 }
387
388 if descr.Configurable == FLAG_TRUE || descr.Enumerable == FLAG_TRUE || descr.Getter != nil || descr.Setter != nil {
389 ret = false
390 goto Reject
391 }
392
393 if descr.Value != nil {
394 oldLen := uint32(prop.value.ToInteger())
395 if oldLen != newLen {
396 ret = setter(newLen, false)
397 }
398 } else {
399 ret = true
400 }
401
402 if descr.Writable != FLAG_NOT_SET {
403 w := descr.Writable.Bool()
404 if prop.writable {
405 prop.writable = w
406 } else {
407 if w {
408 ret = false
409 goto Reject
410 }
411 }
412 }
413
414Reject:
415 if !ret {
416 r.typeErrorResult(throw, "Cannot redefine property: length")
417 }
418
419 return ret
420}
421
422func (a *arrayObject) _defineIdxProperty(idx uint32, desc PropertyDescriptor, throw bool) bool {
423 var existing Value

Callers 5

defineOwnPropertyStrMethod · 0.80
defineOwnPropertyStrMethod · 0.80
defineOwnPropertyStrMethod · 0.80
defineOwnPropertyStrMethod · 0.80
defineOwnPropertyStrMethod · 0.80

Calls 4

toLengthUint32Method · 0.95
typeErrorResultMethod · 0.95
BoolMethod · 0.80
ToIntegerMethod · 0.65

Tested by

no test coverage detected