go-json/encode_vm_escaped.go

5276 lines
136 KiB
Go
Raw Normal View History

2021-01-10 23:16:37 +03:00
package json
import (
"bytes"
"encoding"
"fmt"
"math"
"reflect"
"runtime"
2021-01-10 23:16:37 +03:00
"sort"
"unsafe"
)
2021-01-31 16:45:59 +03:00
func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) {
2021-01-10 23:16:37 +03:00
recursiveLevel := 0
ptrOffset := uintptr(0)
ctxptr := ctx.ptr()
2021-01-24 09:17:39 +03:00
code := codeSet.code
2021-01-10 23:16:37 +03:00
for {
switch code.op {
default:
2021-02-01 06:01:56 +03:00
return nil, fmt.Errorf("encoder (escaped): opcode %s has not been implemented", code.op)
2021-01-10 23:16:37 +03:00
case opPtr:
ptr := load(ctxptr, code.idx)
code = code.next
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
2021-01-10 23:16:37 +03:00
case opInt:
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opUint:
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opIntString:
b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUintString:
b = append(b, '"')
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opFloat32:
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opFloat64:
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(load(ctxptr, code.idx))
2021-01-10 23:16:37 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
case opString:
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opBool:
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opBytes:
ptr := load(ctxptr, code.idx)
2021-01-31 16:45:59 +03:00
slice := ptrToSlice(ptr)
2021-01-10 23:16:37 +03:00
if ptr == 0 || uintptr(slice.data) == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeByteSlice(b, ptrToBytes(ptr))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opInterface:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
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)
}
2021-01-10 23:16:37 +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 16:59:17 +03:00
if iface == nil || iface.ptr == nil {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
2021-01-24 16:59:17 +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)))
2021-01-10 23:16:37 +03:00
if err != nil {
return nil, err
}
2021-01-24 14:39:59 +03:00
totalLength := uintptr(codeSet.codeLength)
nextTotalLength := uintptr(ifaceCodeSet.codeLength)
2021-01-24 11:20:36 +03:00
2021-01-24 14:39:59 +03:00
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
2021-01-10 23:16:37 +03:00
2021-01-24 14:39:59 +03:00
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
2021-01-24 11:20:36 +03:00
}
2021-01-24 14:39:59 +03:00
oldPtrs := ctx.ptrs
newPtrs := ctx.ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:]
2021-01-24 16:59:17 +03:00
newPtrs[0] = uintptr(iface.ptr)
2021-01-24 14:39:59 +03:00
ctx.ptrs = newPtrs
2021-01-10 23:16:37 +03:00
2021-01-31 16:45:59 +03:00
bb, err := encodeRunEscaped(ctx, b, ifaceCodeSet, opt)
2021-01-24 11:20:36 +03:00
if err != nil {
return nil, err
}
2021-01-24 14:39:59 +03:00
ctx.ptrs = oldPtrs
ctxptr = ctx.ptr()
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
2021-01-10 23:16:37 +03:00
2021-01-24 11:20:36 +03:00
b = bb
code = code.next
2021-01-10 23:16:37 +03:00
case opMarshalJSON:
ptr := load(ctxptr, code.idx)
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)
2021-01-10 23:16:37 +03:00
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
}
runtime.KeepAlive(v)
2021-01-10 23:16:37 +03:00
if len(bb) == 0 {
return nil, errUnexpectedEndOfJSON(
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
0,
)
}
buf := bytes.NewBuffer(b)
if err := compact(buf, bb, true); err != nil {
2021-01-10 23:16:37 +03:00
return nil, err
}
b = buf.Bytes()
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opMarshalText:
ptr := load(ctxptr, code.idx)
isPtr := code.typ.Kind() == reflect.Ptr
2021-01-31 16:45:59 +03:00
p := ptrToUnsafePtr(ptr)
2021-02-18 13:20:07 +03:00
if p == nil || isPtr && **(**unsafe.Pointer)(unsafe.Pointer(&p)) == nil {
2021-01-10 23:16:37 +03:00
b = append(b, '"', '"', ',')
} else {
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-11 13:21:30 +03:00
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
}
code = code.next
case opSliceHead:
p := load(ctxptr, code.idx)
2021-01-31 16:45:59 +03:00
slice := ptrToSlice(p)
2021-01-10 23:16:37 +03:00
if p == 0 || uintptr(slice.data) == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(slice.len))
store(ctxptr, code.idx, uintptr(slice.data))
if slice.len > 0 {
b = append(b, '[')
code = code.next
store(ctxptr, code.idx, uintptr(slice.data))
} else {
b = append(b, '[', ']', ',')
code = code.end.next
}
}
case opSliceElem:
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
if idx < length {
store(ctxptr, code.elemIdx, idx)
data := load(ctxptr, code.headIdx)
size := code.size
code = code.next
store(ctxptr, code.idx, data+idx*size)
} else {
last := len(b) - 1
b[last] = ']'
b = encodeComma(b)
code = code.end.next
}
case opArrayHead:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
if code.length > 0 {
b = append(b, '[')
store(ctxptr, code.elemIdx, 0)
code = code.next
store(ctxptr, code.idx, p)
} else {
b = append(b, '[', ']', ',')
code = code.end.next
}
}
case opArrayElem:
idx := load(ctxptr, code.elemIdx)
idx++
if idx < code.length {
store(ctxptr, code.elemIdx, idx)
p := load(ctxptr, code.headIdx)
size := code.size
code = code.next
store(ctxptr, code.idx, p+idx*size)
} else {
last := len(b) - 1
b[last] = ']'
b = encodeComma(b)
code = code.end.next
}
case opMapHead:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} 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)
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 {
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)))
2021-01-10 23:16:37 +03:00
}
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
b = append(b, '{', '}', ',')
code = code.end.next
}
}
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
// load pointer
2021-01-31 16:45:59 +03:00
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{')
iter := mapiterinit(code.typ, uptr)
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 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
2021-01-31 16:45:59 +03:00
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
2021-01-10 23:16:37 +03:00
}
code = code.next
} else {
b = append(b, '{', '}', ',')
code = code.end.next
}
}
case opMapKey:
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) != 0 {
2021-01-10 23:16:37 +03:00
if idx < length {
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, idx)
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
last := len(b) - 1
b[last] = '}'
b = encodeComma(b)
code = code.end.next
}
} else {
ptr := load(ctxptr, code.end.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
mapCtx.pos = append(mapCtx.pos, len(b))
2021-01-10 23:16:37 +03:00
if idx < length {
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +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 {
2021-01-10 23:16:37 +03:00
last := len(b) - 1
b[last] = ':'
} else {
ptr := load(ctxptr, code.end.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
mapCtx.pos = append(mapCtx.pos, len(b))
2021-01-10 23:16:37 +03:00
}
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
value := mapitervalue(iter)
store(ctxptr, code.next.idx, uintptr(value))
mapiternext(iter)
code = code.next
case opMapEnd:
// this operation only used by sorted map.
length := int(load(ctxptr, code.length))
ptr := load(ctxptr, code.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
pos := mapCtx.pos
2021-01-10 23:16: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 {
endValue = len(b)
}
mapCtx.slice.items = append(mapCtx.slice.items, mapItem{
key: b[startKey:startValue],
value: b[startValue:endValue],
2021-01-10 23:16:37 +03:00
})
}
sort.Sort(mapCtx.slice)
2021-01-25 07:10:07 +03:00
buf := mapCtx.buf
for _, item := range mapCtx.slice.items {
2021-01-25 07:10:07 +03:00
buf = append(buf, item.key...)
buf[len(buf)-1] = ':'
buf = append(buf, item.value...)
2021-01-10 23:16:37 +03:00
}
2021-01-25 07:10:07 +03:00
buf[len(buf)-1] = '}'
buf = append(buf, ',')
2021-01-10 23:16:37 +03:00
b = b[:pos[0]]
2021-01-25 07:10:07 +03:00
b = append(b, buf...)
mapCtx.buf = buf
releaseMapContext(mapCtx)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadRecursive:
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-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadRecursive:
2021-01-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldRecursive:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
if recursiveLevel > startDetectingCyclesAfter {
2021-01-15 10:25:00 +03:00
for _, seen := range ctx.seenPtr {
if ptr == seen {
return nil, errUnsupportedValue(code, ptr)
}
2021-01-10 23:16:37 +03:00
}
}
}
2021-01-15 10:25:00 +03:00
ctx.seenPtr = append(ctx.seenPtr, ptr)
2021-01-11 13:21:30 +03:00
c := code.jmp.code
2021-01-10 23:16:37 +03:00
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
oldOffset := ptrOffset
2021-01-15 10:25:00 +03:00
ptrOffset += code.jmp.curLen * uintptrSize
2021-01-10 23:16:37 +03:00
2021-01-15 10:25:00 +03:00
newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen
2021-01-10 23:16:37 +03:00
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
}
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
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)))
2021-01-10 23:16:37 +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))
2021-01-10 23:16:37 +03:00
ctxptr = ctx.ptr() + offset
ptrOffset = offset
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHead:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHead:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
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:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
2021-01-13 18:02:58 +03:00
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.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
p := load(ctxptr, code.idx)
2021-01-10 23:16:37 +03:00
b = append(b, '{')
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
code = code.next
store(ctxptr, code.idx, p)
2021-01-13 18:02:58 +03:00
case opStructFieldHeadOmitEmptyOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
if !code.anonymousKey {
if p != 0 {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHead:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
code = code.next
store(ctxptr, code.idx, ptr)
}
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.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt:
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-01-11 13:21:30 +03:00
case opStructFieldHeadInt:
2021-01-10 23:16:37 +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.escapedKey...)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
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, '{')
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, u64, code)
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))
}
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.escapedKey...)
b = append(b, '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
u64 := ptrToUint64(p)
v := u64 & code.mask
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, u64, code)
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadIntPtr:
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-01-11 13:21:30 +03:00
case opStructFieldHeadIntPtr:
2021-01-10 23:16:37 +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.escapedKey...)
p = ptrToPtr(p + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyIntPtr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
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, '{')
p = ptrToPtr(p + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p), code)
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)))
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.escapedKey...)
p = ptrToPtr(p + code.offset)
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadIntPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadIntPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p+code.offset), code)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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))
fallthrough
case opStructFieldHeadOmitEmptyIntPtrOnly:
b = append(b, '{')
p := load(ctxptr, code.idx)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p), code)
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))
fallthrough
case opStructFieldHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldHeadIntNPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '{')
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; 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 {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt:
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-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt:
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.escapedKey...)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, u64, code)
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))
}
fallthrough
case opStructFieldAnonymousHeadStringTagInt:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
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.escapedKey...)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +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 {
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.escapedKey...)
b = appendInt(b, u64, code)
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.escapedKey...)
b = append(b, '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-13 18:02:58 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadIntPtr:
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-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadIntPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
p = ptrToPtr(p + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +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
}
p = ptrToPtr(p + code.offset)
2021-01-13 18:02:58 +03:00
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p), code)
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.escapedKey...)
p = ptrToPtr(p + code.offset)
2021-01-13 18:02:58 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
2021-01-13 18:02:58 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadIntPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadIntPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p+code.offset), code)
2021-01-10 23:16:37 +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.escapedKey...)
b = appendInt(b, ptrToUint64(p+code.offset), code)
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.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p+code.offset), code)
2021-01-13 18:02:58 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadUint:
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
case opStructFieldHeadUint:
2021-01-10 23:16:37 +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.escapedKey...)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
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
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, '{')
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-16 20:53:54 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, u64, code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
}
}
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
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.escapedKey...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
u64 := ptrToUint64(p)
v := u64 & code.mask
2021-01-16 20:53:54 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, u64, code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadUintPtr:
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
case opStructFieldHeadUintPtr:
2021-01-10 23:16:37 +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.escapedKey...)
p = ptrToPtr(p + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
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
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, '{')
p = ptrToPtr(p + code.offset)
2021-01-16 20:53:54 +03:00
if p != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
}
code = code.next
}
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
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.escapedKey...)
p = ptrToPtr(p + code.offset)
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadUintPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadUintPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
}
code = code.next
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
case opStructFieldHeadStringTagUintPtrOnly:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
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.escapedKey...)
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 {
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadUint:
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
case opStructFieldAnonymousHeadUint:
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.escapedKey...)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
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
case opStructFieldAnonymousHeadOmitEmptyUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-16 20:53:54 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, u64, code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
}
}
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
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.escapedKey...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadUintOnly, opStructFieldAnonymousHeadUintOnly:
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.escapedKey...)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyUintOnly, opStructFieldAnonymousHeadOmitEmptyUintOnly:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-16 20:53:54 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, u64, code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
}
}
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.escapedKey...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadUintPtr:
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
case opStructFieldAnonymousHeadUintPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
p = ptrToPtr(p + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
2021-01-16 20:53:54 +03:00
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
}
b = encodeComma(b)
code = code.next
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
case opStructFieldAnonymousHeadOmitEmptyUintPtr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
p = ptrToPtr(p + code.offset)
2021-01-16 20:53:54 +03:00
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
}
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
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.escapedKey...)
p = ptrToPtr(p + code.offset)
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
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
case opStructFieldAnonymousHeadUintPtrOnly:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-01-16 20:53:54 +03:00
}
b = encodeComma(b)
code = code.next
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
case opStructFieldAnonymousHeadOmitEmptyUintPtrOnly:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrAnonymousHeadStringTagUintPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldAnonymousHeadStringTagUintPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat32:
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
case opStructFieldHeadFloat32:
2021-01-10 23:16:37 +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.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadOmitEmptyFloat32:
2021-01-17 16:06:16 +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 16:06:16 +03:00
}
fallthrough
case opStructFieldHeadOmitEmptyFloat32:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
v := ptrToFloat32(ptr + code.offset)
2021-01-17 16:06:16 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrHeadStringTagFloat32:
2021-01-17 16:06:16 +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 16:06:16 +03:00
}
fallthrough
case opStructFieldHeadStringTagFloat32:
2021-01-17 16:06:16 +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.escapedKey...)
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
v := ptrToFloat32(p)
2021-01-17 16:06:16 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat32Ptr:
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
case opStructFieldHeadFloat32Ptr:
2021-01-10 23:16:37 +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.escapedKey...)
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 {
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat32Ptr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-17 16:06:16 +03:00
fallthrough
case opStructFieldHeadOmitEmptyFloat32Ptr:
2021-01-17 16:06:16 +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-17 16:06:16 +03:00
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
}
code = code.next
}
case opStructFieldPtrHeadStringTagFloat32Ptr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-17 16:06:16 +03:00
fallthrough
case opStructFieldHeadStringTagFloat32Ptr:
2021-01-17 16:06:16 +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.escapedKey...)
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat32PtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadFloat32PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat32PtrOnly:
2021-01-17 16:06:16 +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-17 16:06:16 +03:00
fallthrough
case opStructFieldHeadOmitEmptyFloat32PtrOnly:
2021-01-17 16:06:16 +03:00
b = append(b, '{')
p := load(ctxptr, code.idx)
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagFloat32PtrOnly:
2021-01-17 16:06:16 +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-17 16:06:16 +03:00
fallthrough
case opStructFieldHeadStringTagFloat32PtrOnly:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldHeadFloat32NPtr:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '{')
b = append(b, code.escapedKey...)
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 16:06:16 +03:00
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-17 16:06:16 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadFloat32:
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
case opStructFieldAnonymousHeadFloat32:
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.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32:
2021-01-17 16:06:16 +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 16:06:16 +03:00
}
fallthrough
case opStructFieldAnonymousHeadOmitEmptyFloat32:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToFloat32(ptr + code.offset)
2021-01-17 16:06:16 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagFloat32:
2021-01-17 16:06:16 +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 16:06:16 +03:00
}
fallthrough
case opStructFieldAnonymousHeadStringTagFloat32:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadFloat32Only, opStructFieldAnonymousHeadFloat32Only:
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.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Only, opStructFieldAnonymousHeadOmitEmptyFloat32Only:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToFloat32(ptr + code.offset)
2021-01-17 16:06:16 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagFloat32Only, opStructFieldAnonymousHeadStringTagFloat32Only:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadFloat32Ptr:
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
case opStructFieldAnonymousHeadFloat32Ptr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
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 {
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-17 16:06:16 +03:00
fallthrough
case opStructFieldAnonymousHeadOmitEmptyFloat32Ptr:
2021-01-17 16:06:16 +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 16:06:16 +03:00
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagFloat32Ptr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-17 16:06:16 +03:00
fallthrough
case opStructFieldAnonymousHeadStringTagFloat32Ptr:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadFloat32PtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldAnonymousHeadFloat32PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly:
2021-01-17 16:06:16 +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 16:06:16 +03:00
fallthrough
case opStructFieldAnonymousHeadOmitEmptyFloat32PtrOnly:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagFloat32PtrOnly:
2021-01-17 16:06:16 +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 16:06:16 +03:00
fallthrough
case opStructFieldAnonymousHeadStringTagFloat32PtrOnly:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-17 16:06:16 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat64:
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
case opStructFieldHeadFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
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, '{')
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
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
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, '{')
v := ptrToFloat64(ptr + code.offset)
2021-01-18 15:50:52 +03:00
if v == 0 {
code = code.nextField
} else {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = encodeComma(b)
code = code.next
}
}
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
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, '{')
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.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
v := ptrToFloat64(p)
2021-01-18 15:50:52 +03:00
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = append(b, '"')
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
case opStructFieldPtrHeadFloat64Ptr:
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
case opStructFieldHeadFloat64Ptr:
2021-01-10 23:16:37 +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.escapedKey...)
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 {
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
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
}
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
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.escapedKey...)
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, '"')
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
case opStructFieldPtrHeadFloat64PtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadFloat64PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
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
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
case opStructFieldHeadStringTagFloat64PtrOnly:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
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
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.escapedKey...)
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 {
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
case opStructFieldPtrAnonymousHeadFloat64:
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
case opStructFieldAnonymousHeadFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
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.escapedKey...)
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
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
case opStructFieldAnonymousHeadOmitEmptyFloat64:
2021-01-18 15:50:52 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToFloat64(ptr + code.offset)
2021-01-18 15:50:52 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
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
}
}
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
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.escapedKey...)
b = append(b, '"')
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
}
case opStructFieldPtrAnonymousHeadFloat64Only, opStructFieldAnonymousHeadFloat64Only:
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.escapedKey...)
v := ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Only, opStructFieldAnonymousHeadOmitEmptyFloat64Only:
2021-01-18 15:50:52 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToFloat64(ptr + code.offset)
2021-01-18 15:50:52 +03:00
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
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
}
}
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.escapedKey...)
b = append(b, '"')
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
}
case opStructFieldPtrAnonymousHeadFloat64Ptr:
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
case opStructFieldAnonymousHeadFloat64Ptr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
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 {
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
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
}
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
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.escapedKey...)
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, '"')
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
case opStructFieldPtrAnonymousHeadFloat64PtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldAnonymousHeadFloat64PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
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
}
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
case opStructFieldAnonymousHeadStringTagFloat64PtrOnly:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
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
case opStructFieldPtrHeadString:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadString:
2021-01-10 23:16:37 +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.escapedKey...)
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
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
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, '{')
v := ptrToString(ptr + code.offset)
if v == "" {
2021-01-18 16:35:10 +03:00
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
}
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
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.escapedKey...)
s := ptrToString(ptr + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
v := ptrToString(p)
if v != "" {
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadStringPtr:
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
case opStructFieldHeadStringPtr:
2021-01-10 23:16:37 +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.escapedKey...)
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 {
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
b = encodeEscapedString(b, ptrToString(p))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
}
code = code.next
}
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
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.escapedKey...)
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 {
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadStringPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadStringPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
}
code = code.next
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
case opStructFieldHeadStringTagStringPtrOnly:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
}
b = encodeComma(b)
code = code.next
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.escapedKey...)
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 {
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-18 16:35:10 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadString:
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
case opStructFieldAnonymousHeadString:
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.escapedKey...)
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
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
case opStructFieldAnonymousHeadOmitEmptyString:
2021-01-18 16:35:10 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToString(ptr + code.offset)
if v == "" {
2021-01-18 16:35:10 +03:00
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
}
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
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.escapedKey...)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(ptr))))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringOnly, opStructFieldAnonymousHeadStringOnly:
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.escapedKey...)
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyStringOnly, opStructFieldAnonymousHeadOmitEmptyStringOnly:
2021-01-18 16:35:10 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToString(ptr + code.offset)
if v == "" {
2021-01-18 16:35:10 +03:00
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
}
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.escapedKey...)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(ptr))))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringPtr:
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
case opStructFieldAnonymousHeadStringPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
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 {
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
b = encodeEscapedString(b, ptrToString(p))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
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
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.escapedKey...)
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 {
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadStringPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldAnonymousHeadStringPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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
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.escapedKey...)
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
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
case opStructFieldAnonymousHeadStringTagStringPtrOnly:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBool:
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
case opStructFieldHeadBool:
2021-01-10 23:16:37 +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.escapedKey...)
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadOmitEmptyBool:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmptyBool:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
v := ptrToBool(ptr + code.offset)
if v {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
code = code.next
} else {
code = code.nextField
}
}
case opStructFieldPtrHeadStringTagBool:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadStringTagBool:
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.escapedKey...)
b = append(b, '"')
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
v := ptrToBool(p)
if v {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeBool(b, ptrToBool(p))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBoolPtr:
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
case opStructFieldHeadBoolPtr:
2021-01-10 23:16:37 +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.escapedKey...)
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 {
b = encodeBool(b, ptrToBool(p+code.offset))
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBoolPtr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldHeadOmitEmptyBoolPtr:
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)
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p))
b = encodeComma(b)
}
code = code.next
}
case opStructFieldPtrHeadStringTagBoolPtr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldHeadStringTagBoolPtr:
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.escapedKey...)
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p+code.offset))
b = append(b, '"')
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBoolPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadBoolPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBoolPtrOnly:
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))
fallthrough
case opStructFieldHeadOmitEmptyBoolPtrOnly:
b = append(b, '{')
p := load(ctxptr, code.idx)
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p+code.offset))
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagBoolPtrOnly:
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))
fallthrough
case opStructFieldHeadStringTagBoolPtrOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p+code.offset))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldHeadBoolNPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '{')
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; 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 {
b = encodeBool(b, ptrToBool(p+code.offset))
2021-01-10 23:16:37 +03:00
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadBool:
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
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.escapedKey...)
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmptyBool:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToBool(ptr + code.offset)
if v {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
code = code.next
} else {
code = code.nextField
}
}
case opStructFieldPtrAnonymousHeadStringTagBool:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadStringTagBool:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly:
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.escapedKey...)
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToBool(ptr + code.offset)
if v {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
code = code.next
} else {
code = code.nextField
}
}
case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
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
case opStructFieldAnonymousHeadBoolPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
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 {
b = encodeBool(b, ptrToBool(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyBoolPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagBoolPtr:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagBoolPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p+code.offset))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadBoolPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldAnonymousHeadBoolPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldAnonymousHeadStringTagBoolPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p+code.offset))
b = append(b, '"')
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBytes:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadBytes:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
if code.op == opStructFieldPtrHeadBytes {
b = encodeNull(b)
b = encodeComma(b)
} else {
b = append(b, '{', '}', ',')
}
code = code.end.next
} else {
b = append(b, '{')
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadBytes:
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadBytes:
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.escapedKey...)
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadArray:
p := load(ctxptr, code.idx)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadArray:
ptr := load(ctxptr, code.idx) + code.offset
if ptr == 0 {
if code.op == opStructFieldPtrHeadArray {
b = encodeNull(b)
b = encodeComma(b)
} else {
b = append(b, '[', ']', ',')
}
2021-01-10 23:16:37 +03:00
code = code.end.next
} else {
b = append(b, '{')
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
2021-01-10 23:16:37 +03:00
code = code.next
store(ctxptr, code.idx, ptr)
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrAnonymousHeadArray:
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
case opStructFieldAnonymousHeadArray:
ptr := load(ctxptr, code.idx) + code.offset
if ptr == 0 {
2021-01-10 23:16:37 +03:00
code = code.end.next
} else {
b = append(b, code.escapedKey...)
store(ctxptr, code.idx, ptr)
code = code.next
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadSlice:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadSlice:
ptr := load(ctxptr, code.idx)
p := ptr + code.offset
2021-01-10 23:16:37 +03:00
if p == 0 {
if code.op == opStructFieldPtrHeadSlice {
b = encodeNull(b)
b = encodeComma(b)
} else {
b = append(b, '[', ']', ',')
}
code = code.end.next
2021-01-10 23:16:37 +03:00
} else {
b = append(b, '{')
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +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
if p == 0 {
2021-01-10 23:16:37 +03:00
code = code.end.next
} else {
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
store(ctxptr, code.idx, p)
code = code.next
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
2021-01-10 23:16:37 +03:00
} else {
b = append(b, '{')
b = append(b, code.escapedKey...)
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
break
}
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)
if err := compact(buf, bb, true); err != nil {
return nil, err
}
b = buf.Bytes()
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadMarshalJSON:
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
2021-01-10 23:16:37 +03:00
code = code.end.next
} else {
b = append(b, code.escapedKey...)
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
2021-01-10 23:16:37 +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)
if err := compact(buf, bb, true); err != nil {
return nil, err
}
b = buf.Bytes()
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadMarshalText:
2021-01-10 23:16:37 +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-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadMarshalText:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
b = append(b, code.escapedKey...)
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 = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadMarshalText:
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
case opStructFieldAnonymousHeadMarshalText:
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.escapedKey...)
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 = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadOmitEmptyBytes:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmptyBytes:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
v := ptrToBytes(ptr + code.offset)
if len(v) == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadOmitEmptyBytes:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmptyBytes:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := ptrToBytes(ptr + code.offset)
if len(v) == 0 {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
code = code.next
}
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
}
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadOmitEmptyMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
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.escapedKey...)
buf := bytes.NewBuffer(b)
if err := compact(buf, bb, true); err != nil {
return nil, err
}
b = buf.Bytes()
b = encodeComma(b)
code = code.next
}
}
}
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmptyMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
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.escapedKey...)
buf := bytes.NewBuffer(b)
if err := compact(buf, bb, true); err != nil {
return nil, err
}
b = buf.Bytes()
b = encodeComma(b)
code = code.next
}
}
}
case opStructFieldPtrHeadOmitEmptyMarshalText:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmptyMarshalText:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
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}))
bytes, err := v.(encoding.TextMarshaler).MarshalText()
if err != nil {
return nil, &MarshalerError{
Type: rtype2type(code.typ),
Err: err,
}
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalText:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmptyMarshalText:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
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}))
bytes, err := v.(encoding.TextMarshaler).MarshalText()
if err != nil {
return nil, &MarshalerError{
Type: rtype2type(code.typ),
Err: err,
}
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrHeadStringTag:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadStringTag:
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
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
case opStructFieldPtrAnonymousHeadStringTag:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadStringTag:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, ptr+code.offset)
}
case opStructFieldPtrHeadStringTagBytes:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadStringTagBytes:
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.escapedKey...)
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagBytes:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadStringTagBytes:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadStringTagMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
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.escapedKey...)
b = append(b, '"', '"')
b = encodeComma(b)
code = code.nextField
} else {
var buf bytes.Buffer
if err := compact(&buf, bb, true); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadStringTagMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
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.escapedKey...)
b = append(b, '"', '"')
b = encodeComma(b)
code = code.nextField
} else {
var buf bytes.Buffer
if err := compact(&buf, bb, true); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrHeadStringTagMarshalText:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadStringTagMarshalText:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
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, &MarshalerError{
Type: rtype2type(code.typ),
Err: err,
}
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagMarshalText:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, ptrToPtr(ptr))
2021-01-17 09:49:34 +03:00
}
fallthrough
case opStructFieldAnonymousHeadStringTagMarshalText:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
ptr += code.offset
p := ptrToUnsafePtr(ptr)
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
2021-01-10 23:16:37 +03:00
bytes, err := v.(encoding.TextMarshaler).MarshalText()
if err != nil {
return nil, errMarshaler(code, err)
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
code = code.next
2021-01-10 23:16:37 +03:00
}
case opStructField:
if !code.anonymousKey {
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +03:00
}
ptr := load(ctxptr, code.headIdx) + code.offset
2021-01-17 09:49:34 +03:00
code = code.next
store(ctxptr, code.idx, ptr)
case opStructFieldOmitEmpty:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 {
2021-01-10 23:16:37 +03:00
code = code.nextField
} else {
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +03:00
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldStringTag:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyInt:
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, u64, code)
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagInt:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldIntPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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 {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p), code)
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
b = append(b, code.escapedKey...)
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldIntNPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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 {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
case opStructFieldOmitEmptyUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-16 20:53:54 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, u64, code)
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
}
code = code.next
case opStructFieldStringTagUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
case opStructFieldUintPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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 {
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyUintPtr:
2021-01-10 23:16:37 +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.escapedKey...)
b = appendUint(b, ptrToUint64(p), code)
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
}
code = code.next
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)
b = append(b, code.escapedKey...)
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldFloat32:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
case opStructFieldOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat32(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
code = code.next
case opStructFieldFloat32Ptr:
2021-01-17 16:06:16 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-17 16:06:16 +03:00
}
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
code = code.next
case opStructFieldOmitEmptyFloat32Ptr:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p))
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
}
code = code.next
case opStructFieldStringTagFloat32Ptr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
b = append(b, code.escapedKey...)
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
2021-01-17 16:06:16 +03:00
}
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
code = code.next
case opStructFieldFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
v := ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-22 14:06:20 +03:00
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
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.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeFloat64(b, v)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldFloat64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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)
b = encodeComma(b)
code = code.next
break
2021-01-10 23:16:37 +03:00
}
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
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.escapedKey...)
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-22 14:06:20 +03:00
}
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-18 15:50:52 +03:00
}
code = code.next
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)
b = append(b, code.escapedKey...)
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
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, '"')
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = append(b, '"')
}
b = encodeComma(b)
2021-01-18 15:50:52 +03:00
code = code.next
case opStructFieldString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToString(ptr + code.offset)
if v != "" {
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
s := ptrToString(ptr + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldStringPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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 {
b = encodeEscapedString(b, ptrToString(p))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
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.escapedKey...)
b = encodeNoEscapedString(b, ptrToString(p))
b = encodeComma(b)
2021-01-18 16:35:10 +03:00
}
code = code.next
case opStructFieldStringTagStringPtr:
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
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 {
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
}
b = encodeComma(b)
2021-01-18 16:35:10 +03:00
code = code.next
case opStructFieldBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToBool(ptr + code.offset)
if v {
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldBoolPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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 {
b = encodeBool(b, ptrToBool(p))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyBoolPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p))
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagBoolPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToBytes(ptr + code.offset)
if len(v) > 0 {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToBytes(ptr + code.offset)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldBytesPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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-01-17 09:49:34 +03:00
} else {
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyBytesPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, ptrToBytes(p))
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagBytesPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeByteSlice(b, ptrToBytes(p))
}
b = encodeComma(b)
code = code.next
case opStructFieldMarshalJSON:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
p := ptr + code.offset
if code.typ.Kind() == reflect.Ptr {
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
v := ptrToInterface(code, p)
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
}
buf := bytes.NewBuffer(b)
if err := compact(buf, bb, true); err != nil {
return nil, err
}
b = buf.Bytes()
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalJSON:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 {
code = code.next
break
}
v := ptrToInterface(code, p)
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
}
b = append(b, code.escapedKey...)
buf := bytes.NewBuffer(b)
if err := compact(buf, bb, true); err != nil {
return nil, err
}
b = buf.Bytes()
b = encodeComma(b)
code = code.next
case opStructFieldStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
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, true); err != nil {
return nil, err
}
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
p := ptr + code.offset
v := ptrToInterface(code, p)
bytes, err := v.(encoding.TextMarshaler).MarshalText()
if err != nil {
return nil, errMarshaler(code, err)
}
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalText:
ptr := load(ctxptr, code.headIdx)
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)
2021-01-22 14:06:20 +03:00
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagMarshalText:
2021-01-10 23:16:37 +03:00
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.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldArray:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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 {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldSlice:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-01-10 23:16:37 +03:00
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptySlice:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
slice := ptrToSlice(p)
if p == 0 || uintptr(slice.data) == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
case opStructFieldMap:
b = append(b, code.escapedKey...)
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 {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
2021-01-22 14:06:20 +03:00
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
2021-01-22 14:06:20 +03:00
}
}
case opStructFieldMapLoad:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldStruct:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructEnd:
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
} else {
b = append(b, '}')
}
b = encodeComma(b)
code = code.next
case opStructAnonymousEnd:
code = code.next
case opStructEndInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-17 09:49:34 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, u64, code)
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
}
code = code.next
case opStructEndStringTagInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opStructEndIntPtr:
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +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 {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p), code)
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)
}
}
code = code.next
case opStructEndStringTagIntPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
case opStructEndIntNPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = appendStructEnd(b)
code = code.next
case opStructEndUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-10 23:16:37 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, u64, code)
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
}
code = code.next
case opStructEndStringTagUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opStructEndUintPtr:
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +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 {
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyUintPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(p), code)
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)
}
}
code = code.next
case opStructEndStringTagUintPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
case opStructEndUintNPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyFloat32:
2021-01-10 23:16:37 +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.escapedKey...)
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
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
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.escapedKey...)
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
}
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyFloat32Ptr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
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)
}
}
code = code.next
case opStructEndStringTagFloat32Ptr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
case opStructEndFloat32NPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
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)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyFloat64:
2021-01-10 23:16:37 +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.escapedKey...)
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
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagFloat64:
2021-01-10 23:16:37 +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)
2021-01-10 23:16:37 +03:00
}
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat64Ptr:
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +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
2021-01-10 23:16:37 +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)
2021-01-10 23:16:37 +03:00
}
2021-01-17 09:49:34 +03:00
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyFloat64Ptr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
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)
}
}
code = code.next
case opStructEndStringTagFloat64Ptr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
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.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
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:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyString:
2021-01-10 23:16:37 +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.escapedKey...)
2021-01-17 09:49:34 +03:00
b = encodeEscapedString(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
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
s := ptrToString(ptr + code.offset)
2021-01-17 09:49:34 +03:00
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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 = encodeEscapedString(b, ptrToString(p))
2021-01-17 09:49:34 +03:00
}
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
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.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(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.escapedKey...)
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 = encodeEscapedString(b, string(encodeEscapedString([]byte{}, v)))
}
b = appendStructEnd(b)
code = code.next
case opStructEndStringNPtr:
b = append(b, code.escapedKey...)
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 = encodeEscapedString(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:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
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)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyBool:
2021-01-10 23:16:37 +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.escapedKey...)
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
}
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndBoolPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
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)
code = code.next
case opStructEndOmitEmptyBoolPtr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
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.escapedKey...)
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:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
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)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyBytes:
2021-01-10 23:16:37 +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.escapedKey...)
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)
}
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToBytes(ptr + code.offset)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = encodeByteSlice(b, v)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
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)
}
buf := bytes.NewBuffer(b)
if err := compact(buf, bb, true); err != nil {
2021-01-17 09:49:34 +03:00
return nil, err
}
b = buf.Bytes()
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
p := ptr + code.offset
2021-02-01 12:43:28 +03:00
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 {
2021-01-22 14:06:20 +03:00
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-02-01 12:43:28 +03:00
code = code.next
break
}
v := ptrToInterface(code, p)
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
2021-01-17 09:49:34 +03:00
}
2021-02-01 12:43:28 +03:00
b = append(b, code.escapedKey...)
buf := bytes.NewBuffer(b)
if err := compact(buf, bb, true); err != nil {
return nil, err
}
b = buf.Bytes()
b = appendStructEnd(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-01-31 16:45:59 +03:00
v := ptrToInterface(code, p)
2021-01-10 23:16:37 +03:00
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
}
var buf bytes.Buffer
2021-01-31 16:45:59 +03:00
if err := compact(&buf, bb, true); err != nil {
2021-01-10 23:16:37 +03:00
return nil, err
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndMarshalText:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
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 = encodeEscapedString(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.escapedKey...)
b = encodeEscapedString(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-11 13:21:30 +03:00
case opStructEndStringTagMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-01-31 16:45:59 +03:00
v := ptrToInterface(code, p)
2021-01-10 23:16:37 +03:00
bytes, err := v.(encoding.TextMarshaler).MarshalText()
if err != nil {
return nil, errMarshaler(code, err)
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = appendStructEnd(b)
code = code.next
case opEnd:
goto END
}
}
END:
return b, nil
}