2020-04-29 18:31:50 +03:00
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
2020-08-18 07:36:36 +03:00
|
|
|
"bytes"
|
2020-05-08 14:22:57 +03:00
|
|
|
"encoding"
|
2020-08-18 18:32:45 +03:00
|
|
|
"fmt"
|
2020-05-08 19:07:33 +03:00
|
|
|
"math"
|
2020-04-29 18:31:50 +03:00
|
|
|
"reflect"
|
2021-01-22 10:28:12 +03:00
|
|
|
"runtime"
|
2020-09-16 08:51:37 +03:00
|
|
|
"sort"
|
2020-05-08 19:07:33 +03:00
|
|
|
"strconv"
|
2020-04-29 18:31:50 +03:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2020-09-01 16:26:26 +03:00
|
|
|
const startDetectingCyclesAfter = 1000
|
|
|
|
|
2020-08-30 21:14:37 +03:00
|
|
|
func load(base uintptr, idx uintptr) uintptr {
|
2020-11-14 23:27:15 +03:00
|
|
|
addr := base + idx
|
|
|
|
return **(**uintptr)(unsafe.Pointer(&addr))
|
2020-08-30 17:58:58 +03:00
|
|
|
}
|
|
|
|
|
2020-08-30 21:14:37 +03:00
|
|
|
func store(base uintptr, idx uintptr, p uintptr) {
|
2020-11-14 23:27:15 +03:00
|
|
|
addr := base + idx
|
|
|
|
**(**uintptr)(unsafe.Pointer(&addr)) = p
|
2020-08-30 17:58:58 +03:00
|
|
|
}
|
|
|
|
|
2021-01-31 16:45:59 +03:00
|
|
|
func ptrToInt(p uintptr) int { return **(**int)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToInt8(p uintptr) int8 { return **(**int8)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToInt16(p uintptr) int16 { return **(**int16)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToInt32(p uintptr) int32 { return **(**int32)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToInt64(p uintptr) int64 { return **(**int64)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToUint(p uintptr) uint { return **(**uint)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToUint8(p uintptr) uint8 { return **(**uint8)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToUint16(p uintptr) uint16 { return **(**uint16)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToUint32(p uintptr) uint32 { return **(**uint32)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToSlice(p uintptr) *sliceHeader { return *(**sliceHeader)(unsafe.Pointer(&p)) }
|
|
|
|
func ptrToPtr(p uintptr) uintptr {
|
|
|
|
return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
}
|
|
|
|
func ptrToUnsafePtr(p uintptr) unsafe.Pointer {
|
|
|
|
return *(*unsafe.Pointer)(unsafe.Pointer(&p))
|
|
|
|
}
|
|
|
|
func ptrToInterface(code *opcode, p uintptr) interface{} {
|
|
|
|
return *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
|
|
|
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2020-09-15 14:48:02 +03:00
|
|
|
func errUnsupportedValue(code *opcode, ptr uintptr) *UnsupportedValueError {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)),
|
2020-09-15 14:48:02 +03:00
|
|
|
}))
|
|
|
|
return &UnsupportedValueError{
|
|
|
|
Value: reflect.ValueOf(v),
|
|
|
|
Str: fmt.Sprintf("encountered a cycle via %s", code.typ),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-17 09:06:05 +03:00
|
|
|
func errUnsupportedFloat(v float64) *UnsupportedValueError {
|
|
|
|
return &UnsupportedValueError{
|
|
|
|
Value: reflect.ValueOf(v),
|
|
|
|
Str: strconv.FormatFloat(v, 'g', -1, 64),
|
|
|
|
}
|
|
|
|
}
|
2020-11-17 09:08:12 +03:00
|
|
|
|
|
|
|
func errMarshaler(code *opcode, err error) *MarshalerError {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-31 16:45:59 +03:00
|
|
|
func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) {
|
2020-09-04 07:53:25 +03:00
|
|
|
recursiveLevel := 0
|
2020-09-03 09:36:11 +03:00
|
|
|
ptrOffset := uintptr(0)
|
2020-08-30 17:58:58 +03:00
|
|
|
ctxptr := ctx.ptr()
|
2021-01-24 09:17:39 +03:00
|
|
|
code := codeSet.code
|
2020-12-29 19:29:29 +03:00
|
|
|
|
2020-04-29 18:31:50 +03:00
|
|
|
for {
|
|
|
|
switch code.op {
|
2020-11-16 13:10:46 +03:00
|
|
|
default:
|
2021-02-01 06:01:56 +03:00
|
|
|
return nil, fmt.Errorf("encoder: opcode %s has not been implemented", code.op)
|
2021-01-10 23:16:37 +03:00
|
|
|
case opPtr:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2020-04-29 18:31:50 +03:00
|
|
|
case opInt:
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(load(ctxptr, code.idx))
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opUint:
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx))&code.mask)
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opFloat32:
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opFloat64:
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(load(ctxptr, code.idx))
|
2020-05-08 19:07:33 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-12-19 16:40:03 +03:00
|
|
|
return nil, errUnsupportedFloat(v)
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opString:
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(load(ctxptr, code.idx)))
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opBool:
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
case opBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-31 16:45:59 +03:00
|
|
|
slice := ptrToSlice(ptr)
|
2020-11-17 09:09:06 +03:00
|
|
|
if ptr == 0 || uintptr(slice.data) == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-21 05:51:33 +03:00
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr))
|
2020-08-21 05:51:33 +03:00
|
|
|
}
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-30 07:39:47 +03:00
|
|
|
case opInterface:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-09-17 15:50:27 +03:00
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-15 10:25:00 +03:00
|
|
|
for _, seen := range ctx.seenPtr {
|
|
|
|
if ptr == seen {
|
|
|
|
return nil, errUnsupportedValue(code, ptr)
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
2021-01-15 10:25:00 +03:00
|
|
|
ctx.seenPtr = append(ctx.seenPtr, ptr)
|
2021-01-31 16:45:59 +03:00
|
|
|
iface := (*interfaceHeader)(ptrToUnsafePtr(ptr))
|
2021-01-24 17:27:23 +03:00
|
|
|
if iface == nil || iface.ptr == nil {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-24 17:27:23 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(iface))
|
2021-01-31 16:45:59 +03:00
|
|
|
ifaceCodeSet, err := encodeCompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ)))
|
2020-12-07 04:44:24 +03:00
|
|
|
if err != nil {
|
2020-12-22 19:37:54 +03:00
|
|
|
return nil, err
|
2020-12-07 04:44:24 +03:00
|
|
|
}
|
2021-01-24 17:27:23 +03:00
|
|
|
|
|
|
|
totalLength := uintptr(codeSet.codeLength)
|
|
|
|
nextTotalLength := uintptr(ifaceCodeSet.codeLength)
|
|
|
|
|
2020-09-03 09:36:11 +03:00
|
|
|
curlen := uintptr(len(ctx.ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
2020-09-03 16:05:46 +03:00
|
|
|
|
2020-09-03 09:36:11 +03:00
|
|
|
newLen := offsetNum + totalLength + nextTotalLength
|
|
|
|
if curlen < newLen {
|
|
|
|
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
2020-08-30 17:58:58 +03:00
|
|
|
}
|
2021-01-24 17:27:23 +03:00
|
|
|
oldPtrs := ctx.ptrs
|
2020-09-03 16:05:46 +03:00
|
|
|
|
2021-01-24 17:27:23 +03:00
|
|
|
newPtrs := ctx.ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:]
|
|
|
|
newPtrs[0] = uintptr(iface.ptr)
|
|
|
|
|
|
|
|
ctx.ptrs = newPtrs
|
|
|
|
|
2021-01-31 16:45:59 +03:00
|
|
|
bb, err := encodeRun(ctx, b, ifaceCodeSet, opt)
|
2021-01-24 17:27:23 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-09-03 09:36:11 +03:00
|
|
|
|
2021-01-24 17:27:23 +03:00
|
|
|
ctx.ptrs = oldPtrs
|
|
|
|
ctxptr = ctx.ptr()
|
|
|
|
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
|
2020-09-03 09:36:11 +03:00
|
|
|
|
2021-01-24 17:27:23 +03:00
|
|
|
b = bb
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-04 12:39:17 +03:00
|
|
|
case opMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-22 07:28:33 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, ptr)
|
2020-12-19 16:40:03 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
2020-05-04 12:39:17 +03:00
|
|
|
if err != nil {
|
2020-12-19 16:40:03 +03:00
|
|
|
return nil, errMarshaler(code, err)
|
2020-05-04 12:39:17 +03:00
|
|
|
}
|
2021-01-22 10:28:12 +03:00
|
|
|
runtime.KeepAlive(v)
|
2020-12-19 16:40:03 +03:00
|
|
|
if len(bb) == 0 {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
2020-08-18 18:32:45 +03:00
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
2020-12-19 16:40:03 +03:00
|
|
|
return nil, err
|
2020-08-18 07:36:36 +03:00
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
b = buf.Bytes()
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-05-04 12:39:17 +03:00
|
|
|
case opMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-20 11:47:38 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToUnsafePtr(ptr)
|
2020-12-22 19:42:49 +03:00
|
|
|
if p == nil || isPtr && *(*unsafe.Pointer)(p) == nil {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '"', '"', ',')
|
2020-11-16 13:10:46 +03:00
|
|
|
} else {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
|
|
|
ptr: p,
|
|
|
|
}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-12-19 16:40:03 +03:00
|
|
|
return nil, errMarshaler(code, err)
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
2021-01-11 13:47:33 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opSliceHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-31 16:45:59 +03:00
|
|
|
slice := ptrToSlice(p)
|
2020-11-17 09:09:06 +03:00
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.length, uintptr(slice.len))
|
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
|
|
|
if slice.len > 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[')
|
2020-04-29 19:44:48 +03:00
|
|
|
code = code.next
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[', ']', ',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
}
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
|
|
|
case opSliceElem:
|
2020-08-31 15:59:22 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
length := load(ctxptr, code.length)
|
|
|
|
idx++
|
|
|
|
if idx < length {
|
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
data := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
size := code.size
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, data+idx*size)
|
2020-04-29 18:31:50 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = ']'
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
2020-04-30 07:39:47 +03:00
|
|
|
case opArrayHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2020-04-30 07:39:47 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
if code.length > 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[')
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
2020-04-30 07:39:47 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-04-30 07:39:47 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[', ']', ',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opArrayElem:
|
2020-08-31 15:59:22 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
idx++
|
|
|
|
if idx < code.length {
|
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
p := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
size := code.size
|
2020-04-30 07:39:47 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p+idx*size)
|
2020-04-30 07:39:47 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = ']'
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opMapHead:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
uptr := ptrToUnsafePtr(ptr)
|
2021-01-10 23:16:37 +03:00
|
|
|
mlen := maplen(uptr)
|
|
|
|
if mlen > 0 {
|
|
|
|
b = append(b, '{')
|
|
|
|
iter := mapiterinit(code.typ, uptr)
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, iter)
|
2020-09-16 08:51:37 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
|
|
|
store(ctxptr, code.length, uintptr(mlen))
|
|
|
|
store(ctxptr, code.mapIter, uintptr(iter))
|
2021-01-31 16:45:59 +03:00
|
|
|
if (opt & EncodeOptionUnorderedMap) == 0 {
|
2021-01-25 07:10:07 +03:00
|
|
|
mapCtx := newMapContext(mlen)
|
|
|
|
mapCtx.pos = append(mapCtx.pos, len(b))
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
|
|
|
|
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
|
2020-09-16 12:15:47 +03:00
|
|
|
}
|
2020-09-16 08:51:37 +03:00
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{', '}', ',')
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapHeadLoad:
|
2020-09-16 08:51:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
// load pointer
|
2021-01-31 16:45:59 +03:00
|
|
|
ptr = ptrToPtr(ptr)
|
|
|
|
uptr := ptrToUnsafePtr(ptr)
|
2020-09-17 15:50:27 +03:00
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(uptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
if mlen > 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-11-14 23:27:15 +03:00
|
|
|
iter := mapiterinit(code.typ, uptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, iter)
|
|
|
|
store(ctxptr, code.elemIdx, 0)
|
|
|
|
store(ctxptr, code.length, uintptr(mlen))
|
|
|
|
store(ctxptr, code.mapIter, uintptr(iter))
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
2021-01-31 16:45:59 +03:00
|
|
|
if (opt & EncodeOptionUnorderedMap) == 0 {
|
2021-01-25 07:10:07 +03:00
|
|
|
mapCtx := newMapContext(mlen)
|
|
|
|
mapCtx.pos = append(mapCtx.pos, len(b))
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
|
|
|
|
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
|
2020-09-16 12:15:47 +03:00
|
|
|
}
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{', '}', ',')
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapKey:
|
2020-09-16 08:51:37 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
length := load(ctxptr, code.length)
|
|
|
|
idx++
|
2021-01-31 16:45:59 +03:00
|
|
|
if (opt & EncodeOptionUnorderedMap) != 0 {
|
2020-09-16 12:15:47 +03:00
|
|
|
if idx < length {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2021-01-31 16:45:59 +03:00
|
|
|
iter := ptrToUnsafePtr(ptr)
|
2020-09-16 12:15:47 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
2020-09-16 12:15:47 +03:00
|
|
|
code = code.end.next
|
|
|
|
}
|
2020-09-16 08:51:37 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.end.mapPos)
|
2021-01-31 16:45:59 +03:00
|
|
|
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
|
2021-01-25 07:10:07 +03:00
|
|
|
mapCtx.pos = append(mapCtx.pos, len(b))
|
2020-09-16 12:15:47 +03:00
|
|
|
if idx < length {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2021-01-31 16:45:59 +03:00
|
|
|
iter := ptrToUnsafePtr(ptr)
|
2020-09-16 12:15:47 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
|
|
|
code = code.end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opMapValue:
|
2021-01-31 16:45:59 +03:00
|
|
|
if (opt & EncodeOptionUnorderedMap) != 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = ':'
|
2020-09-16 12:15:47 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.end.mapPos)
|
2021-01-31 16:45:59 +03:00
|
|
|
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
|
2021-01-25 07:10:07 +03:00
|
|
|
mapCtx.pos = append(mapCtx.pos, len(b))
|
2020-09-16 08:51:37 +03:00
|
|
|
}
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2021-01-31 16:45:59 +03:00
|
|
|
iter := ptrToUnsafePtr(ptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
value := mapitervalue(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(value))
|
|
|
|
mapiternext(iter)
|
|
|
|
code = code.next
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapEnd:
|
|
|
|
// this operation only used by sorted map.
|
2020-09-16 08:51:37 +03:00
|
|
|
length := int(load(ctxptr, code.length))
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapPos)
|
2021-01-31 16:45:59 +03:00
|
|
|
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
|
2021-01-25 07:10:07 +03:00
|
|
|
pos := mapCtx.pos
|
2020-09-16 08:51:37 +03:00
|
|
|
for i := 0; i < length; i++ {
|
|
|
|
startKey := pos[i*2]
|
|
|
|
startValue := pos[i*2+1]
|
|
|
|
var endValue int
|
|
|
|
if i+1 < length {
|
|
|
|
endValue = pos[i*2+2]
|
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
endValue = len(b)
|
2020-09-16 08:51:37 +03:00
|
|
|
}
|
2021-01-25 07:10:07 +03:00
|
|
|
mapCtx.slice.items = append(mapCtx.slice.items, mapItem{
|
|
|
|
key: b[startKey:startValue],
|
|
|
|
value: b[startValue:endValue],
|
2020-09-16 08:51:37 +03:00
|
|
|
})
|
|
|
|
}
|
2021-01-25 07:10:07 +03:00
|
|
|
sort.Sort(mapCtx.slice)
|
|
|
|
buf := mapCtx.buf
|
|
|
|
for _, item := range mapCtx.slice.items {
|
|
|
|
buf = append(buf, item.key...)
|
2020-11-16 13:10:46 +03:00
|
|
|
buf[len(buf)-1] = ':'
|
2021-01-25 07:10:07 +03:00
|
|
|
buf = append(buf, item.value...)
|
2020-09-16 08:51:37 +03:00
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
buf[len(buf)-1] = '}'
|
|
|
|
buf = append(buf, ',')
|
2020-12-19 16:40:03 +03:00
|
|
|
b = b[:pos[0]]
|
|
|
|
b = append(b, buf...)
|
2021-01-25 07:10:07 +03:00
|
|
|
mapCtx.buf = buf
|
|
|
|
releaseMapContext(mapCtx)
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadRecursive:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-11-16 15:28:33 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadRecursive:
|
2020-11-16 15:28:33 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldRecursive:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-31 15:59:22 +03:00
|
|
|
if ptr != 0 {
|
2020-09-01 16:26:26 +03:00
|
|
|
if recursiveLevel > startDetectingCyclesAfter {
|
2021-01-15 10:25:00 +03:00
|
|
|
for _, seen := range ctx.seenPtr {
|
|
|
|
if ptr == seen {
|
|
|
|
return nil, errUnsupportedValue(code, ptr)
|
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
}
|
2020-08-20 17:56:12 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-15 10:25:00 +03:00
|
|
|
ctx.seenPtr = append(ctx.seenPtr, ptr)
|
2020-09-04 07:48:21 +03:00
|
|
|
c := code.jmp.code
|
|
|
|
curlen := uintptr(len(ctx.ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
|
|
|
oldOffset := ptrOffset
|
2021-01-15 10:25:00 +03:00
|
|
|
ptrOffset += code.jmp.curLen * uintptrSize
|
2020-09-04 07:48:21 +03:00
|
|
|
|
2021-01-15 10:25:00 +03:00
|
|
|
newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen
|
2020-09-04 07:48:21 +03:00
|
|
|
if curlen < newLen {
|
|
|
|
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
2020-08-12 12:42:29 +03:00
|
|
|
}
|
2020-09-04 07:48:21 +03:00
|
|
|
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
|
|
|
|
|
2020-09-15 14:48:16 +03:00
|
|
|
store(ctxptr, c.idx, ptr)
|
2021-01-15 10:25:00 +03:00
|
|
|
store(ctxptr, c.end.next.idx, oldOffset)
|
|
|
|
store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next)))
|
2020-09-04 07:48:21 +03:00
|
|
|
code = c
|
|
|
|
recursiveLevel++
|
|
|
|
case opStructFieldRecursiveEnd:
|
|
|
|
recursiveLevel--
|
|
|
|
|
|
|
|
// restore ctxptr
|
|
|
|
offset := load(ctxptr, code.idx)
|
2021-01-15 10:25:00 +03:00
|
|
|
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
|
|
|
|
|
|
|
|
codePtr := load(ctxptr, code.elemIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
code = (*opcode)(ptrToUnsafePtr(codePtr))
|
2020-09-04 07:48:21 +03:00
|
|
|
ctxptr = ctx.ptr() + offset
|
|
|
|
ptrOffset = offset
|
2020-04-29 19:44:48 +03:00
|
|
|
case opStructFieldPtrHead:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2020-04-29 19:44:48 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 18:31:50 +03:00
|
|
|
if ptr == 0 {
|
2021-01-09 07:55:34 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-08-31 15:59:22 +03:00
|
|
|
if !code.anonymousKey {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-13 18:02:58 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
|
2021-01-09 07:55:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
if !code.anonymousKey {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldHeadOmitEmptyOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
if !code.anonymousKey {
|
|
|
|
if ptr != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
} else {
|
|
|
|
code = code.nextField
|
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-22 06:58:34 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-22 06:58:34 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-08-22 06:58:34 +03:00
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-13 18:02:58 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
}
|
2020-04-29 19:44:48 +03:00
|
|
|
case opStructFieldPtrHeadInt:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-04-29 19:44:48 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 19:44:48 +03:00
|
|
|
if ptr == 0 {
|
2021-01-09 08:24:43 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-11 20:40:12 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-11 20:40:12 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendInt(b, v, v>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-11 20:40:12 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
2021-01-09 07:55:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-09 07:55:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
v := u64 & code.mask
|
2021-01-11 20:40:12 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendInt(b, v, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 07:55:34 +03:00
|
|
|
case opStructFieldPtrHeadIntPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 07:55:34 +03:00
|
|
|
fallthrough
|
2020-12-23 07:13:34 +03:00
|
|
|
case opStructFieldHeadIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-09 07:55:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2020-12-23 07:13:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2020-12-25 16:26:59 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-11 20:40:12 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-11 20:40:12 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagIntPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-11 20:40:12 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-11 20:40:12 +03:00
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-11 20:40:12 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 07:55:34 +03:00
|
|
|
case opStructFieldPtrHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 07:55:34 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-09 07:55:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-11 20:40:12 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyIntPtrOnly:
|
|
|
|
b = append(b, '{')
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-11 20:40:12 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-11 20:40:12 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-23 07:13:34 +03:00
|
|
|
case opStructFieldHeadIntNPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadInt:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-11 20:40:12 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-11 20:40:12 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendInt(b, v, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-11 20:40:12 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-13 18:02:58 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendInt(b, v, u64>>code.rshiftNum == 1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadIntPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadIntPtr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 13:55:15 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2020-09-17 15:50:27 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-13 18:02:58 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-13 18:02:58 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadUint:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToUint64(ptr+code.offset) & code.mask
|
2021-01-16 20:53:54 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToUint64(p) & code.mask
|
2021-01-16 20:53:54 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadUintPtr:
|
2020-12-25 16:26:59 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-09 13:55:15 +03:00
|
|
|
if p == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadUintPtrOnly:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadUintPtrOnly:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p+code.offset)&code.mask)
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadUintNPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToUint64(ptr+code.offset) & code.mask
|
2021-01-16 20:53:54 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUintOnly, opStructFieldAnonymousHeadUintOnly:
|
2021-01-09 13:55:15 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUintOnly, opStructFieldAnonymousHeadOmitEmptyUintOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToUint64(ptr+code.offset) & code.mask
|
2021-01-16 20:53:54 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUintOnly, opStructFieldAnonymousHeadStringTagUintOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadUintPtr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 13:55:15 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2020-09-17 15:50:27 +03:00
|
|
|
if p == 0 {
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUintPtrOnly:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUintPtrOnly:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUintPtrOnly:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat32:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeNull(b)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-09 13:55:15 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '{')
|
2021-01-09 13:55:15 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '{')
|
2021-01-09 13:55:15 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only:
|
2021-01-09 13:55:15 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '{')
|
2021-01-09 13:55:15 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 09:49:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat32Ptr:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 13:55:15 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:14:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32Ptr:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:14:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat32Ptr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:14:34 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat32PtrOnly:
|
2021-01-09 14:14:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:14:34 +03:00
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:14:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat32PtrOnly:
|
2021-01-09 14:14:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32PtrOnly:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 14:14:34 +03:00
|
|
|
if p == 0 {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-09 14:14:34 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32PtrOnly:
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat32PtrOnly:
|
2021-01-09 14:14:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat32PtrOnly:
|
2021-01-09 14:14:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '{')
|
2021-01-09 14:14:34 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat32NPtr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 09:49:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-17 09:49:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32Only, opStructFieldAnonymousHeadFloat32Only:
|
2021-01-09 14:14:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-09 14:14:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Only, opStructFieldAnonymousHeadOmitEmptyFloat32Only:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32Only, opStructFieldAnonymousHeadStringTagFloat32Only:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:14:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat32Ptr:
|
2021-01-09 14:14:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:14:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 09:49:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat32Ptr:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 09:49:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat32Ptr:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32PtrOnly:
|
2021-01-09 14:14:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:14:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat32PtrOnly:
|
2021-01-09 14:14:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat32PtrOnly:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32PtrOnly:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat32PtrOnly:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat64:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-18 15:50:52 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 14:33:55 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if v != 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat64Ptr:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:33:55 +03:00
|
|
|
break
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat64PtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-09 14:33:55 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat64PtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat64NPtr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-18 15:50:52 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64Only, opStructFieldAnonymousHeadFloat64Only:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 19:44:48 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Only, opStructFieldAnonymousHeadOmitEmptyFloat64Only:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-18 15:50:52 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64Only, opStructFieldAnonymousHeadStringTagFloat64Only:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat64Ptr:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:33:55 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64PtrOnly:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2020-08-19 04:34:11 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat64PtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat64PtrOnly:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadString:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadString:
|
2021-01-09 14:33:55 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(ptr+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToString(ptr + code.offset)
|
|
|
|
if v == "" {
|
2021-01-18 16:35:10 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, v)
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
s := ptrToString(ptr + code.offset)
|
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToString(p)
|
|
|
|
if v != "" {
|
2021-01-18 16:35:10 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, v)
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringPtr:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringNPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadString:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadString:
|
2021-01-09 14:33:55 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(ptr+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToString(ptr + code.offset)
|
|
|
|
if v == "" {
|
2021-01-18 16:35:10 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, v)
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(ptr))))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringOnly, opStructFieldAnonymousHeadStringOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(ptr+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyStringOnly, opStructFieldAnonymousHeadOmitEmptyStringOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToString(ptr + code.offset)
|
|
|
|
if v == "" {
|
2021-01-18 16:35:10 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, v)
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagStringOnly, opStructFieldAnonymousHeadStringTagStringOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(ptr))))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringPtr:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagStringPtrOnly:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBool:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBool:
|
2021-01-09 14:33:55 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
} else {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBool(p)
|
|
|
|
if v {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBoolPtr:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBoolPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBoolPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBoolPtrOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBoolPtrOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBoolPtrOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagBoolPtrOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBoolNPtr:
|
2021-01-17 09:49:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBool:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadBool:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
} else {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-09 14:33:55 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
} else {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadBoolPtr:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBoolPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadBoolPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-19 08:54:27 +03:00
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBoolPtrOnly:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBytes:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-09 14:33:55 +03:00
|
|
|
code = code.end.next
|
2021-02-18 21:06:21 +03:00
|
|
|
break
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
if code.op == opStructFieldPtrHeadBytes {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '}', ',')
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBytes:
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadBytes:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-23 19:50:18 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadArray:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-02-18 21:06:21 +03:00
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadArray:
|
|
|
|
ptr := load(ctxptr, code.idx) + code.offset
|
|
|
|
if ptr == 0 {
|
|
|
|
if code.op == opStructFieldPtrHeadArray {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '[', ']', ',')
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
if !code.anonymousKey {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadArray:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadArray:
|
|
|
|
ptr := load(ctxptr, code.idx) + code.offset
|
|
|
|
if ptr == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:33:55 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
|
|
|
code = code.next
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadSlice:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-09 14:33:55 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadSlice:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
p := ptr + code.offset
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
if code.op == opStructFieldPtrHeadSlice {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '[', ']', ',')
|
|
|
|
}
|
|
|
|
code = code.end.next
|
2021-01-09 14:33:55 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
if !code.anonymousKey {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadSlice:
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadSlice:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
p := ptr + code.offset
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
2021-02-18 21:06:21 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
code = code.next
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadMarshalJSON:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-09 14:33:55 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-09 14:33:55 +03:00
|
|
|
} else {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
v := ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.end
|
|
|
|
break
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
bb, err := rv.Interface().(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
if len(bb) == 0 {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = buf.Bytes()
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadMarshalJSON:
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadMarshalJSON:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 15:08:29 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
v := ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
b = encodeNull(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
bb, err := rv.Interface().(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = buf.Bytes()
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadMarshalText:
|
2021-01-09 15:08:29 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-09 15:08:29 +03:00
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '{')
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
v := ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end
|
|
|
|
break
|
|
|
|
}
|
|
|
|
bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadMarshalText:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 15:08:29 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadMarshalText:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
v := ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) == 0 {
|
|
|
|
code = code.nextField
|
2021-01-09 15:08:29 +03:00
|
|
|
} else {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = buf.Bytes()
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyMarshalJSON:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = buf.Bytes()
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyMarshalText:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyMarshalText:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalText:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyMarshalText:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTag:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTag:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
p := ptr + code.offset
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTag:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTag:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, ptr+code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '{')
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagMarshalJSON:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagMarshalJSON:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"', '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagMarshalJSON:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagMarshalJSON:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"', '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
2021-01-17 09:49:34 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2021-02-18 21:06:21 +03:00
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-17 09:49:34 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := ptrToUnsafePtr(ptr)
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-22 12:31:07 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructField:
|
|
|
|
if !code.anonymousKey {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
ptr := load(ctxptr, code.headIdx) + code.offset
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
|
|
|
case opStructFieldOmitEmpty:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-02-18 21:06:21 +03:00
|
|
|
if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 {
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-01-22 12:31:07 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
2021-01-22 12:31:07 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTag:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldInt:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyInt:
|
2021-01-12 18:14:46 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-12 18:14:46 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendInt(b, v, u64>>code.rshiftNum == 1)
|
|
|
|
b = encodeComma(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagInt:
|
2021-01-12 18:14:46 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-12 18:14:46 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldIntPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyIntPtr:
|
2021-01-12 18:14:46 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-12 18:14:46 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
|
|
|
b = encodeComma(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagIntPtr:
|
2021-01-12 18:14:46 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-12 18:14:46 +03:00
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-12 18:14:46 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldIntNPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
|
|
|
b = encodeComma(b)
|
2021-01-16 20:53:54 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToUint64(ptr+code.offset) & code.mask
|
2021-01-16 20:53:54 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, v)
|
|
|
|
b = encodeComma(b)
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-16 20:53:54 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldUintPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyUintPtr:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
|
|
|
b = encodeComma(b)
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
|
|
|
b = encodeComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldFloat32Ptr:
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyFloat32Ptr:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-02-18 21:06:21 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
|
|
|
b = encodeComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagFloat32Ptr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptrToPtr(ptr + code.offset)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
|
|
|
b = append(b, '"')
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v != 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2021-01-22 14:06:20 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldFloat64Ptr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
break
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2021-01-22 14:06:20 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-18 15:50:52 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToString(ptr + code.offset)
|
|
|
|
if v != "" {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
s := ptrToString(ptr + code.offset)
|
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
|
|
|
b = encodeComma(b)
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-18 16:35:10 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, v)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldBoolPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyBytes:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) > 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, v)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBytes(ptr + code.offset)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldBytesPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyBytesPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(p))
|
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagBytesPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldMarshalJSON:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = buf.Bytes()
|
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
if code.typ.Kind() == reflect.Ptr && code.typ.Elem().Implements(marshalJSONType) {
|
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
if v != nil && p != 0 {
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
|
|
|
return nil, err
|
2021-01-22 14:06:20 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = buf.Bytes()
|
|
|
|
b = encodeComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagMarshalText:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
if v != nil {
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldArray:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldOmitEmptyArray:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
array := ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(array.data) == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 23:16:37 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldSlice:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldOmitEmptySlice:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
slice := ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
case opStructFieldMap:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldOmitEmptyMap:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
2021-01-22 14:06:20 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
if mlen == 0 {
|
|
|
|
code = code.nextField
|
2021-01-22 14:06:20 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-22 14:06:20 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldMapLoad:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldOmitEmptyMapLoad:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
if mlen == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStruct:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructEnd:
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '}')
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructAnonymousEnd:
|
|
|
|
code = code.next
|
|
|
|
case opStructEndInt:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyInt:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-17 09:49:34 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendInt(b, v, u64>>code.rshiftNum == 1)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndStringTagInt:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndIntPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyIntPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndStringTagIntPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndIntNPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(p)
|
|
|
|
b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndUint:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyUint:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToUint64(ptr+code.offset) & code.mask
|
2021-01-10 23:16:37 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = appendUint(b, v)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndStringTagUint:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndUintPtr:
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyUintPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndStringTagUintPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndUintNPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p)&code.mask)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndOmitEmptyFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndStringTagFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndFloat32Ptr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-19 14:41:14 +03:00
|
|
|
case opStructEndOmitEmptyFloat32Ptr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-19 14:41:14 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructEndStringTagFloat32Ptr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndFloat32NPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 14:41:14 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-19 14:41:14 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if v != 0 {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndStringTagFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndFloat64Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
break
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(p)
|
2021-01-17 09:49:34 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-19 14:41:14 +03:00
|
|
|
case opStructEndOmitEmptyFloat64Ptr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(p)
|
2021-01-19 14:41:14 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-19 14:41:14 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructEndStringTagFloat64Ptr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(p)
|
2021-01-19 14:41:14 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndFloat64NPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 14:41:14 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(p)
|
2021-01-19 14:41:14 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndOmitEmptyString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToString(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v != "" {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeNoEscapedString(b, v)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndStringTagString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
s := ptrToString(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndStringPtr:
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-20 18:22:20 +03:00
|
|
|
case opStructEndOmitEmptyStringPtr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-20 18:22:20 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-20 18:22:20 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructEndStringTagStringPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-20 18:22:20 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToString(p)
|
2021-01-20 18:22:20 +03:00
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, v)))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndStringNPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-20 18:22:20 +03:00
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-20 18:22:20 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2021-01-20 18:22:20 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndOmitEmptyBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToBool(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, v)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndStringTagBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndBoolPtr:
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-02-15 06:57:16 +03:00
|
|
|
case opStructEndOmitEmptyBoolPtr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptrToPtr(ptr + code.offset)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, ptrToBool(p))
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructEndStringTagBoolPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeBool(b, ptrToBool(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndOmitEmptyBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToBytes(ptr + code.offset)
|
2021-01-17 09:49:34 +03:00
|
|
|
if len(v) > 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, v)
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndStringTagBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToBytes(ptr + code.offset)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeByteSlice(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-17 09:49:34 +03:00
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2021-01-17 09:49:34 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
2021-01-17 09:49:34 +03:00
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
b = buf.Bytes()
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndOmitEmptyMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-17 09:49:34 +03:00
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
if v != nil && (code.typ.Kind() != reflect.Ptr || ptrToPtr(p) != 0) {
|
2021-01-17 09:49:34 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
buf := bytes.NewBuffer(b)
|
|
|
|
//TODO: we should validate buffer with `compact`
|
|
|
|
if err := compact(buf, bb, false); err != nil {
|
2021-01-17 09:49:34 +03:00
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
b = buf.Bytes()
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2020-12-29 17:17:39 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
2021-01-29 19:14:22 +03:00
|
|
|
if err := compact(&buf, bb, false); err != nil {
|
2020-12-29 17:17:39 +03:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-17 09:49:34 +03:00
|
|
|
case opStructEndMarshalText:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2021-01-17 09:49:34 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndOmitEmptyMarshalText:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2021-01-17 09:49:34 +03:00
|
|
|
if v != nil {
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2021-01-22 14:06:20 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
}
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2020-12-29 17:17:39 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opEnd:
|
|
|
|
goto END
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END:
|
2020-12-19 16:40:03 +03:00
|
|
|
return b, nil
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|