in list.go [409:453]
func (d *Decoder) readUntypedList(tag byte) (interface{}, error) {
isVariableArr := tag == BC_LIST_VARIABLE_UNTYPED
var length int
if listFixedUntypedLenTag(tag) {
length = int(tag - _listFixedUntypedLenTagMin)
} else if tag == BC_LIST_FIXED_UNTYPED {
ii, err := d.decInt32(TAG_READ)
if err != nil {
return nil, perrors.WithStack(err)
}
length = int(ii)
} else if isVariableArr {
length = 0
} else {
return nil, perrors.Errorf("error untyped list tag: %x", tag)
}
ary := make([]interface{}, length)
aryValue := reflect.ValueOf(ary)
holder := d.appendRefs(aryValue)
for j := 0; j < length || isVariableArr; j++ {
it, err := d.DecodeValue()
if err != nil {
if perrors.Is(err, io.EOF) && isVariableArr {
break
}
return nil, perrors.WithStack(err)
}
if isVariableArr {
if it != nil {
aryValue = reflect.Append(aryValue, EnsureRawValue(it))
} else {
aryValue = reflect.Append(aryValue, reflect.Zero(aryValue.Type().Elem()))
}
holder.change(aryValue)
} else {
ary[j] = EnsureRawAny(it)
}
}
return holder, nil
}