(l uint32, throw bool)
| 394 | } |
| 395 | |
| 396 | func (a *templatedArrayObject) setLength(l uint32, throw bool) bool { |
| 397 | lenProp := a.getLenProp() |
| 398 | oldLen := uint32(lenProp.value.ToInteger()) |
| 399 | if l == oldLen { |
| 400 | return true |
| 401 | } |
| 402 | if !lenProp.writable { |
| 403 | a.val.runtime.typeErrorResult(throw, "length is not writable") |
| 404 | return false |
| 405 | } |
| 406 | ret := true |
| 407 | if l < oldLen { |
| 408 | a.materialisePropNames() |
| 409 | a.fixPropOrder() |
| 410 | i := sort.Search(a.idxPropCount, func(idx int) bool { |
| 411 | return strToArrayIdx(a.propNames[idx]) >= l |
| 412 | }) |
| 413 | for j := a.idxPropCount - 1; j >= i; j-- { |
| 414 | if !a.deleteStr(a.propNames[j], false) { |
| 415 | l = strToArrayIdx(a.propNames[j]) + 1 |
| 416 | ret = false |
| 417 | break |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | lenProp.value = intToValue(int64(l)) |
| 422 | return ret |
| 423 | } |
| 424 | |
| 425 | func (a *templatedArrayObject) setOwnStr(name unistring.String, value Value, throw bool) bool { |
| 426 | if name == "length" { |
no test coverage detected