(call FunctionCall)
| 530 | } |
| 531 | |
| 532 | func (r *Runtime) arrayproto_unshift(call FunctionCall) Value { |
| 533 | o := call.This.ToObject(r) |
| 534 | length := toLength(o.self.getStr("length", nil)) |
| 535 | argCount := int64(len(call.Arguments)) |
| 536 | newLen := intToValue(length + argCount) |
| 537 | if argCount > 0 { |
| 538 | newSize := length + argCount |
| 539 | if newSize >= maxInt { |
| 540 | panic(r.NewTypeError("Invalid array length")) |
| 541 | } |
| 542 | if arr := r.checkStdArrayObjWithProto(o); arr != nil && newSize < math.MaxUint32 { |
| 543 | if int64(cap(arr.values)) >= newSize { |
| 544 | arr.values = arr.values[:newSize] |
| 545 | copy(arr.values[argCount:], arr.values[:length]) |
| 546 | } else { |
| 547 | values := make([]Value, newSize) |
| 548 | copy(values[argCount:], arr.values) |
| 549 | arr.values = values |
| 550 | } |
| 551 | copy(arr.values, call.Arguments) |
| 552 | arr.objCount = int(arr.length) |
| 553 | } else { |
| 554 | for k := length - 1; k >= 0; k-- { |
| 555 | from := valueInt(k) |
| 556 | to := valueInt(k + argCount) |
| 557 | if o.self.hasPropertyIdx(from) { |
| 558 | o.self.setOwnIdx(to, nilSafe(o.self.getIdx(from, nil)), true) |
| 559 | } else { |
| 560 | o.self.deleteIdx(to, true) |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | for k, arg := range call.Arguments { |
| 565 | o.self.setOwnIdx(valueInt(int64(k)), arg, true) |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | o.self.setOwnStr("length", newLen, true) |
| 571 | return newLen |
| 572 | } |
| 573 | |
| 574 | func (r *Runtime) arrayproto_at(call FunctionCall) Value { |
| 575 | o := call.This.ToObject(r) |
nothing calls this directly
no test coverage detected