| 704 | } |
| 705 | |
| 706 | func getNumericIndex(sctx *super.Context, index super.Value, base1 bool) (int, bool, *super.Value) { |
| 707 | id := index.Type().ID() |
| 708 | if super.IsUnsigned(id) { |
| 709 | index = LookupPrimitiveCaster(sctx, super.TypeInt64).Eval(index) |
| 710 | id = index.Type().ID() |
| 711 | } |
| 712 | if !super.IsInteger(index.Type().ID()) { |
| 713 | if index.IsError() { |
| 714 | return 0, false, index.Ptr() |
| 715 | } |
| 716 | return 0, false, nil |
| 717 | } |
| 718 | if index.IsNull() { |
| 719 | return 0, false, sctx.Missing().Ptr() |
| 720 | } |
| 721 | idx := int(index.AsInt()) |
| 722 | if base1 { |
| 723 | if idx == 0 { |
| 724 | return -1, false, sctx.Missing().Ptr() |
| 725 | } |
| 726 | if idx > 0 { |
| 727 | idx-- |
| 728 | } |
| 729 | } |
| 730 | return idx, true, nil |
| 731 | } |
| 732 | |
| 733 | func indexArrayOrSet(sctx *super.Context, inner super.Type, vector scode.Bytes, idx int) super.Value { |
| 734 | bytes, idx := getNthFromContainer(vector, idx) |