(val super.Value, length int, base1 bool)
| 86 | } |
| 87 | |
| 88 | func (s *Slice) sliceIndex(val super.Value, length int, base1 bool) super.Value { |
| 89 | if val.IsNull() || val.IsError() { |
| 90 | return val |
| 91 | } |
| 92 | index, ok := coerce.ToInt(val, super.TypeInt64) |
| 93 | if !ok { |
| 94 | return s.sctx.NewError(errors.New("slice index is not a number")) |
| 95 | } |
| 96 | if base1 && index > 0 { |
| 97 | index-- |
| 98 | } |
| 99 | if index < 0 { |
| 100 | index += int64(length) |
| 101 | } |
| 102 | return super.NewInt64(index) |
| 103 | } |
| 104 | |
| 105 | func FixSliceBounds(start, end, size int) (int, int) { |
| 106 | if start > end || end < 0 { |