go-json/encode_vm_escaped.go

5920 lines
156 KiB
Go
Raw Normal View History

2021-01-10 23:16:37 +03:00
package json
import (
"bytes"
"encoding"
"fmt"
"math"
"reflect"
"sort"
"unsafe"
)
func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte, error) {
recursiveLevel := 0
var seenPtr map[uintptr]struct{}
ptrOffset := uintptr(0)
ctxptr := ctx.ptr()
for {
switch code.op {
default:
return nil, fmt.Errorf("failed to handle opcode. doesn't implement %s", code.op)
case opPtr:
ptr := load(ctxptr, code.idx)
code = code.next
store(ctxptr, code.idx, e.ptrToPtr(ptr))
case opInt:
b = appendInt(b, int64(e.ptrToInt(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opInt8:
b = appendInt(b, int64(e.ptrToInt8(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opInt16:
b = appendInt(b, int64(e.ptrToInt16(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opInt32:
b = appendInt(b, int64(e.ptrToInt32(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opInt64:
b = appendInt(b, e.ptrToInt64(load(ctxptr, code.idx)))
b = encodeComma(b)
code = code.next
case opUint:
b = appendUint(b, uint64(e.ptrToUint(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opUint8:
b = appendUint(b, uint64(e.ptrToUint8(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opUint16:
b = appendUint(b, uint64(e.ptrToUint16(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opUint32:
b = appendUint(b, uint64(e.ptrToUint32(load(ctxptr, code.idx))))
b = encodeComma(b)
code = code.next
case opUint64:
b = appendUint(b, e.ptrToUint64(load(ctxptr, code.idx)))
b = encodeComma(b)
code = code.next
case opIntString:
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opInt8String:
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt8(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opInt16String:
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt16(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opInt32String:
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt32(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opInt64String:
b = append(b, '"')
b = appendInt(b, e.ptrToInt64(load(ctxptr, code.idx)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUintString:
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUint8String:
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint8(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUint16String:
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint16(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUint32String:
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint32(load(ctxptr, code.idx))))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUint64String:
b = append(b, '"')
b = appendUint(b, e.ptrToUint64(load(ctxptr, code.idx)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opFloat32:
b = encodeFloat32(b, e.ptrToFloat32(load(ctxptr, code.idx)))
b = encodeComma(b)
code = code.next
case opFloat64:
v := e.ptrToFloat64(load(ctxptr, code.idx))
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
case opString:
b = encodeEscapedString(b, e.ptrToString(load(ctxptr, code.idx)))
b = encodeComma(b)
code = code.next
case opBool:
b = encodeBool(b, e.ptrToBool(load(ctxptr, code.idx)))
b = encodeComma(b)
code = code.next
case opBytes:
ptr := load(ctxptr, code.idx)
slice := e.ptrToSlice(ptr)
if ptr == 0 || uintptr(slice.data) == 0 {
b = encodeNull(b)
} else {
b = encodeByteSlice(b, e.ptrToBytes(ptr))
}
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
}
if seenPtr == nil {
seenPtr = map[uintptr]struct{}{}
}
if _, exists := seenPtr[ptr]; exists {
return nil, errUnsupportedValue(code, ptr)
}
seenPtr[ptr] = struct{}{}
v := e.ptrToInterface(code, ptr)
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(&v))
rv := reflect.ValueOf(v)
if rv.IsNil() {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
vv := rv.Interface()
header := (*interfaceHeader)(unsafe.Pointer(&vv))
if header.typ.Kind() == reflect.Ptr {
if rv.Elem().IsNil() {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
}
c, err := e.compileHead(&encodeCompileContext{
typ: header.typ,
root: code.root,
indent: code.indent,
structTypeToCompiledCode: map[uintptr]*compiledCode{},
})
if err != nil {
return nil, err
}
beforeLastCode := c.beforeLastCode()
lastCode := beforeLastCode.next
lastCode.idx = beforeLastCode.idx + uintptrSize
totalLength := uintptr(code.totalLength())
nextTotalLength := uintptr(c.totalLength())
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
oldOffset := ptrOffset
ptrOffset += totalLength * uintptrSize
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
}
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
store(ctxptr, 0, uintptr(header.ptr))
store(ctxptr, lastCode.idx, oldOffset)
// link lastCode ( opInterfaceEnd ) => code.next
lastCode.op = opInterfaceEnd
lastCode.next = code.next
code = c
recursiveLevel++
case opInterfaceEnd:
recursiveLevel--
// restore ctxptr
offset := load(ctxptr, code.idx)
ctxptr = ctx.ptr() + offset
ptrOffset = offset
code = code.next
case opMarshalJSON:
ptr := load(ctxptr, code.idx)
v := e.ptrToInterface(code, ptr)
bb, err := v.(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,
)
}
var buf bytes.Buffer
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(append(b, buf.Bytes()...), ',')
code = code.next
case opMarshalText:
ptr := load(ctxptr, code.idx)
isPtr := code.typ.Kind() == reflect.Ptr
p := e.ptrToUnsafePtr(ptr)
if p == nil || isPtr && *(*unsafe.Pointer)(p) == nil {
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)
slice := e.ptrToSlice(p)
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 {
uptr := e.ptrToUnsafePtr(ptr)
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))
if !e.unorderedMap {
pos := make([]int, 0, mlen)
pos = append(pos, len(b))
posPtr := unsafe.Pointer(&pos)
ctx.keepRefs = append(ctx.keepRefs, posPtr)
store(ctxptr, code.end.mapPos, uintptr(posPtr))
}
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
ptr = e.ptrToPtr(ptr)
uptr := e.ptrToUnsafePtr(ptr)
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))
if !e.unorderedMap {
pos := make([]int, 0, mlen)
pos = append(pos, len(b))
posPtr := unsafe.Pointer(&pos)
ctx.keepRefs = append(ctx.keepRefs, posPtr)
store(ctxptr, code.end.mapPos, uintptr(posPtr))
}
code = code.next
} else {
b = append(b, '{', '}', ',')
code = code.end.next
}
}
case opMapKey:
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
if e.unorderedMap {
if idx < length {
ptr := load(ctxptr, code.mapIter)
iter := e.ptrToUnsafePtr(ptr)
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)
posPtr := (*[]int)(*(*unsafe.Pointer)(unsafe.Pointer(&ptr)))
*posPtr = append(*posPtr, len(b))
if idx < length {
ptr := load(ctxptr, code.mapIter)
iter := e.ptrToUnsafePtr(ptr)
store(ctxptr, code.elemIdx, idx)
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
code = code.end
}
}
case opMapValue:
if e.unorderedMap {
last := len(b) - 1
b[last] = ':'
} else {
ptr := load(ctxptr, code.end.mapPos)
posPtr := (*[]int)(*(*unsafe.Pointer)(unsafe.Pointer(&ptr)))
*posPtr = append(*posPtr, len(b))
}
ptr := load(ctxptr, code.mapIter)
iter := e.ptrToUnsafePtr(ptr)
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))
type mapKV struct {
key string
value string
}
kvs := make([]mapKV, 0, length)
ptr := load(ctxptr, code.mapPos)
posPtr := e.ptrToUnsafePtr(ptr)
pos := *(*[]int)(posPtr)
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)
}
kvs = append(kvs, mapKV{
key: string(b[startKey:startValue]),
value: string(b[startValue:endValue]),
})
}
sort.Slice(kvs, func(i, j int) bool {
return kvs[i].key < kvs[j].key
})
buf := b[pos[0]:]
buf = buf[:0]
for _, kv := range kvs {
buf = append(buf, []byte(kv.key)...)
buf[len(buf)-1] = ':'
buf = append(buf, []byte(kv.value)...)
}
buf[len(buf)-1] = '}'
buf = append(buf, ',')
b = b[:pos[0]]
b = append(b, buf...)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadRecursive:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
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 {
if _, exists := seenPtr[ptr]; exists {
return nil, errUnsupportedValue(code, ptr)
}
}
}
if seenPtr == nil {
seenPtr = map[uintptr]struct{}{}
}
seenPtr[ptr] = struct{}{}
2021-01-11 13:21:30 +03:00
c := code.jmp.code
2021-01-10 23:16:37 +03:00
c.end.next = newEndOp(&encodeCompileContext{})
c.op = c.op.ptrHeadToHead()
beforeLastCode := c.end
lastCode := beforeLastCode.next
lastCode.idx = beforeLastCode.idx + uintptrSize
lastCode.elemIdx = lastCode.idx + uintptrSize
// extend length to alloc slot for elemIdx
totalLength := uintptr(code.totalLength() + 1)
nextTotalLength := uintptr(c.totalLength() + 1)
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
oldOffset := ptrOffset
ptrOffset += totalLength * uintptrSize
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
}
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
store(ctxptr, c.idx, ptr)
store(ctxptr, lastCode.idx, oldOffset)
store(ctxptr, lastCode.elemIdx, uintptr(unsafe.Pointer(code.next)))
// link lastCode ( opStructFieldRecursiveEnd ) => code.next
lastCode.op = opStructFieldRecursiveEnd
code = c
recursiveLevel++
case opStructFieldRecursiveEnd:
recursiveLevel--
// restore ctxptr
offset := load(ctxptr, code.idx)
ptr := load(ctxptr, code.elemIdx)
code = (*opcode)(e.ptrToUnsafePtr(ptr))
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
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 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
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 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
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-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
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, int64(e.ptrToInt(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.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, '{')
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrHeadStringTagInt:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.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, int64(e.ptrToInt(ptr+code.offset)))
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, int64(e.ptrToInt(p)))
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
v := int64(e.ptrToInt(p))
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, v)
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, int64(e.ptrToInt(p)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadIntPtr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyIntPtr:
store(ctxptr, code.idx, e.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 = e.ptrToPtr(p)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(p)))
b = encodeComma(b)
}
code = code.next
}
case opStructFieldPtrHeadStringTagIntPtr:
store(ctxptr, code.idx, e.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 = e.ptrToPtr(p)
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
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, int64(e.ptrToInt(p+code.offset)))
}
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyIntPtrOnly:
b = append(b, '{')
p := load(ctxptr, code.idx)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
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
}
store(ctxptr, code.idx, e.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, int64(e.ptrToInt(p+code.offset)))
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
}
p = e.ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
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, int64(e.ptrToInt(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagInt:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.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, int64(e.ptrToInt(ptr+code.offset)))
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, int64(e.ptrToInt(ptr+code.offset)))
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 {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
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, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadIntPtr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-13 18:02:58 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
p = e.ptrToPtr(p)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(p)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
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, int64(e.ptrToInt(p+code.offset)))
}
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
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, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt8:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt8:
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, int64(e.ptrToInt8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt8Only, opStructFieldHeadInt8Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt8(p)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt8Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt8Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt8(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt8PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt8PtrOnly:
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, int64(e.ptrToInt8(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt8:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt8:
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, int64(e.ptrToInt8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt8Only, opStructFieldAnonymousHeadInt8Only:
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, int64(e.ptrToInt8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt8Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt8Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt8(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt8PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt8PtrOnly:
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, int64(e.ptrToInt8(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt16:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt16:
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, int64(e.ptrToInt16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt16Only, opStructFieldHeadInt16Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt16(p)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt16Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt16Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt16(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt16PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt16PtrOnly:
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, int64(e.ptrToInt16(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt16:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt16:
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, int64(e.ptrToInt16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt16Only, opStructFieldAnonymousHeadInt16Only:
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, int64(e.ptrToInt16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt16Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt16Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt16(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt16PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt16PtrOnly:
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, int64(e.ptrToInt16(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt32:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt32:
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, int64(e.ptrToInt32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt32Only, opStructFieldHeadInt32Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt32(p)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt32Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt32Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt32(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt32PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt32PtrOnly:
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, int64(e.ptrToInt32(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt32:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt32:
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, int64(e.ptrToInt32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt32Only, opStructFieldAnonymousHeadInt32Only:
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, int64(e.ptrToInt32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt32Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt32Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt32(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt32PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt32PtrOnly:
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, int64(e.ptrToInt32(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt64:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt64:
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, e.ptrToInt64(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt64Only, opStructFieldHeadInt64Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendInt(b, e.ptrToInt64(p))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt64Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt64Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, e.ptrToInt64(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt64PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt64PtrOnly:
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, e.ptrToInt64(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt64:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt64:
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, e.ptrToInt64(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt64Only, opStructFieldAnonymousHeadInt64Only:
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, e.ptrToInt64(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt64Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt64Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, e.ptrToInt64(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadInt64PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadInt64PtrOnly:
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, e.ptrToInt64(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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, uint64(e.ptrToUint(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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, uint64(e.ptrToUint(p)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUintPtr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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, uint64(e.ptrToUint(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUintNPtr:
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
}
p = e.ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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, uint64(e.ptrToUint(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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, uint64(e.ptrToUint(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUintPtr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUintPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUintPtrOnly:
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 = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint8:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint8:
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, uint64(e.ptrToUint8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint8Only, opStructFieldHeadUint8Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint8(p)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint8Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint8Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint8(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint8PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint8PtrOnly:
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, uint64(e.ptrToUint8(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint8:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint8:
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, uint64(e.ptrToUint8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint8Only, opStructFieldAnonymousHeadUint8Only:
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, uint64(e.ptrToUint8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint8Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint8Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint8(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint8PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint8PtrOnly:
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 = appendUint(b, uint64(e.ptrToUint8(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint16:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint16:
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, uint64(e.ptrToUint16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint16Only, opStructFieldHeadUint16Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint16(p)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint16Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint16Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint16(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint16PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint16PtrOnly:
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, uint64(e.ptrToUint16(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint16:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint16:
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, uint64(e.ptrToUint16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint16Only, opStructFieldAnonymousHeadUint16Only:
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, uint64(e.ptrToUint16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint16Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint16Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint16(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint16PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint16PtrOnly:
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 = appendUint(b, uint64(e.ptrToUint16(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint32:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint32:
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, uint64(e.ptrToUint32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint32Only, opStructFieldHeadUint32Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint32(p)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint32Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint32Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint32(p+code.offset)))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint32PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint32PtrOnly:
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, uint64(e.ptrToUint32(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint32:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint32:
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, uint64(e.ptrToUint32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint32Only, opStructFieldAnonymousHeadUint32Only:
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, uint64(e.ptrToUint32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint32Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint32Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint32(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint32PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint32PtrOnly:
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 = appendUint(b, uint64(e.ptrToUint32(p+code.offset)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint64:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint64:
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, e.ptrToUint64(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint64Only, opStructFieldHeadUint64Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = appendUint(b, e.ptrToUint64(p))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint64Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint64Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, e.ptrToUint64(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadUint64PtrOnly:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadUint64PtrOnly:
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, e.ptrToUint64(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint64:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint64:
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, e.ptrToUint64(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint64Only, opStructFieldAnonymousHeadUint64Only:
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, e.ptrToUint64(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint64Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint64Ptr:
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 = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, e.ptrToUint64(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadUint64PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadUint64PtrOnly:
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 = appendUint(b, e.ptrToUint64(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadFloat32:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToFloat32(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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, e.ptrToFloat32(p))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadFloat32Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, e.ptrToFloat32(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToFloat32(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadFloat32:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToFloat32(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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, e.ptrToFloat32(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadFloat32Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, e.ptrToFloat32(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadFloat32PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToFloat32(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadFloat64:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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 := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, '{')
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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 := e.ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadFloat64Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
v := e.ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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 := e.ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadFloat64:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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 := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadFloat64Ptr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
v := e.ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadFloat64PtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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 := e.ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadString:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToString(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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, e.ptrToString(p+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringPtr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, e.ptrToString(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToString(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadString:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToString(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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, e.ptrToString(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringPtr:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, e.ptrToString(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringPtrOnly:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToString(p+code.offset))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadBool:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
2021-01-11 13:21:30 +03:00
if code.op == opStructFieldPtrHeadBool {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
} else {
b = append(b, '{', '}', ',')
}
code = code.end.next
} else {
b = append(b, '{')
b = append(b, code.escapedKey...)
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadBoolOnly:
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
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadBoolOnly:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.key...)
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadBool:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadBytes:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
2021-01-11 13:21:30 +03:00
if code.op == opStructFieldPtrHeadBytes {
2021-01-10 23:16:37 +03:00
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, e.ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadBytes:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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, e.ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadArray:
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadArray:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx) + code.offset
if ptr == 0 {
2021-01-11 13:21:30 +03:00
if code.op == opStructFieldPtrHeadArray {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
} else {
b = append(b, '[', ']', ',')
}
code = code.end.next
} else {
b = append(b, '{')
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
code = code.next
store(ctxptr, code.idx, ptr)
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadArray:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadArray:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx) + code.offset
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
store(ctxptr, code.idx, ptr)
code = code.next
}
2021-01-11 13:21:30 +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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadSlice:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
p := ptr + code.offset
if p == 0 {
2021-01-11 13:21:30 +03:00
if code.op == opStructFieldPtrHeadSlice {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
} else {
b = append(b, '[', ']', ',')
}
code = code.end.next
} else {
b = append(b, '{')
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
code = code.next
store(ctxptr, code.idx, p)
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadSlice:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadSlice:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
p := ptr + code.offset
if p == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
store(ctxptr, code.idx, p)
code = code.next
}
2021-01-11 13:21:30 +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)
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadMarshalJSON:
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...)
ptr += code.offset
v := e.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,
)
}
var buf bytes.Buffer
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, buf.Bytes()...)
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadMarshalJSON:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadMarshalJSON:
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 := e.ptrToInterface(code, ptr)
rv := reflect.ValueOf(v)
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
b = encodeNull(b)
code = code.end.next
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,
)
}
var buf bytes.Buffer
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, buf.Bytes()...)
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
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
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadMarshalText:
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...)
ptr += code.offset
v := e.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
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadMarshalText:
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
2021-01-11 13:21:30 +03:00
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 := e.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)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyInt8:
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, '{')
v := e.ptrToInt8(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt8(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyInt16:
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, '{')
v := e.ptrToInt16(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt16(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyInt32:
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, '{')
v := e.ptrToInt32(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt32(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyInt64:
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, '{')
v := e.ptrToInt64(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt64(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyUint:
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, '{')
v := e.ptrToUint(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToUint(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyUint8:
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, '{')
v := e.ptrToUint8(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToUint8(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyUint16:
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, '{')
v := e.ptrToUint16(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToUint16(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyUint32:
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, '{')
v := e.ptrToUint32(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToUint32(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyUint64:
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, '{')
v := e.ptrToUint64(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToUint64(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendUint(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyFloat32:
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, '{')
v := e.ptrToFloat32(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToFloat32(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyFloat64:
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, '{')
v := e.ptrToFloat64(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToFloat64(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyString:
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, '{')
v := e.ptrToString(ptr + code.offset)
if v == "" {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToString(ptr + code.offset)
if v == "" {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyBool:
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, '{')
v := e.ptrToBool(ptr + code.offset)
if !v {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToBool(ptr + code.offset)
if !v {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyBytes:
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, '{')
v := e.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
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.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
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyMarshalJSON:
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, '{')
ptr += code.offset
p := e.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 {
var buf bytes.Buffer
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = append(b, buf.Bytes()...)
b = encodeComma(b)
code = code.next
}
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
ptr += code.offset
p := e.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 {
var buf bytes.Buffer
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = append(b, buf.Bytes()...)
b = encodeComma(b)
code = code.next
}
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadOmitEmptyMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadOmitEmptyMarshalText:
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, '{')
ptr += code.offset
p := e.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
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadOmitEmptyMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
ptr += code.offset
p := e.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
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTag:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTag:
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, '{')
p := ptr + code.offset
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTag:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTag:
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...)
code = code.next
store(ctxptr, code.idx, ptr+code.offset)
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagInt8:
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 = append(b, '"')
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagInt8:
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 = append(b, '"')
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagInt16:
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 = append(b, '"')
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagInt16:
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 = append(b, '"')
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagInt32:
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 = append(b, '"')
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagInt32:
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 = append(b, '"')
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagInt64:
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 = append(b, '"')
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagInt64Only:
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
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagInt64Only:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, e.ptrToInt64(p+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagInt64PtrOnly:
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
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagInt64PtrOnly:
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 = append(b, '"')
b = appendInt(b, e.ptrToInt64(p+code.offset))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagInt64:
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 = append(b, '"')
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagUint:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagUint:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagUint8:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagUint8:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagUint16:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagUint16:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagUint32:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagUint32:
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 = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagUint64:
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 = append(b, '"')
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagUint64:
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 = append(b, '"')
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagFloat32:
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 = append(b, '"')
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagFloat32:
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 = append(b, '"')
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagFloat64:
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, '{')
v := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagString:
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...)
s := e.ptrToString(ptr + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagString:
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...)
s := string(encodeEscapedString([]byte{}, e.ptrToString(ptr+code.offset)))
b = encodeEscapedString(b, s)
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagBool:
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 = append(b, '"')
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagBoolOnly:
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
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagBoolOnly:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
b = append(b, '{')
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagBool:
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 = append(b, '"')
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagBytes:
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 = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagBytes:
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, e.ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagMarshalJSON:
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, '{')
ptr += code.offset
p := e.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, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
ptr += code.offset
p := e.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, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = encodeComma(b)
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadStringTagMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadStringTagMarshalText:
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, '{')
ptr += code.offset
p := e.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
}
2021-01-11 13:21:30 +03:00
case opStructFieldPtrAnonymousHeadStringTagMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldAnonymousHeadStringTagMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
ptr += code.offset
p := e.ptrToUnsafePtr(ptr)
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
bytes, err := v.(encoding.TextMarshaler).MarshalText()
if err != nil {
return nil, errMarshaler(code, err)
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b)
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructField:
2021-01-10 23:16:37 +03:00
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
ptr := load(ctxptr, code.headIdx) + code.offset
code = code.next
store(ctxptr, code.idx, ptr)
2021-01-11 13:21:30 +03:00
case opStructFieldIntPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldIntNPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = e.ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt8Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt8(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt16Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt16(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt32Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt32(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, e.ptrToInt64(p))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUintPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint8Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint8(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint16Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint16(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint32Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint32(p)))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, e.ptrToUint64(p))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldFloat32Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, e.ptrToFloat32(p))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldFloat64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
v := e.ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
v := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, e.ptrToString(p))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, e.ptrToString(ptr+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldBoolPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, e.ptrToBool(p))
}
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
p := ptr + code.offset
v := e.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, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, buf.Bytes()...)
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
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 := e.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
2021-01-11 13:21:30 +03:00
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)
2021-01-11 13:21:30 +03:00
case opStructFieldSlice:
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)
2021-01-11 13:21:30 +03:00
case opStructFieldMap:
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)
2021-01-11 13:21:30 +03:00
case opStructFieldMapLoad:
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)
2021-01-11 13:21:30 +03:00
case opStructFieldStruct:
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)
2021-01-11 13:21:30 +03:00
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 {
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 opStructFieldOmitEmptyInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt8(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt16(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt32(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt64(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, v)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint8(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint16(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint32(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint64(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, v)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToFloat32(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToFloat64(ptr + code.offset)
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToString(ptr + code.offset)
if v != "" {
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToBool(ptr + code.offset)
if v {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToBytes(ptr + code.offset)
if len(v) > 0 {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
v := e.ptrToInterface(code, p)
if v != nil {
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
}
var buf bytes.Buffer
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = append(b, buf.Bytes()...)
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
v := e.ptrToInterface(code, p)
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)))
b = encodeComma(b)
}
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyArray:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
array := e.ptrToSlice(p)
if p == 0 || uintptr(array.data) == 0 {
code = code.nextField
} else {
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptySlice:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
slice := e.ptrToSlice(p)
if p == 0 || uintptr(slice.data) == 0 {
code = code.nextField
} else {
code = code.next
}
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyMap:
2021-01-10 23:16:37 +03:00
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 {
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldOmitEmptyMapLoad:
2021-01-10 23:16:37 +03:00
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 {
code = code.next
}
}
2021-01-11 13:21:30 +03:00
case opStructFieldStringTag:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint64(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
s := e.ptrToString(ptr + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToBytes(ptr + code.offset)
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
v := e.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, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = encodeComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldStringTagMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
v := e.ptrToInterface(code, p)
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-11 13:21:30 +03:00
case opStructEnd:
2021-01-10 23:16:37 +03:00
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:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyInt:
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
}
b = appendStructEnd(b)
code = code.next
case opStructEndStringTagInt:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndIntPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt(p)))
}
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyIntPtr:
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(p)))
}
b = appendStructEnd(b)
code = code.next
case opStructEndStringTagIntPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p)))
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndIntNPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = e.ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt8Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt8(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt16Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt16(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt32Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, int64(e.ptrToInt32(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, e.ptrToInt64(p))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUintPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint8Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint8(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint16Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint16(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint32Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, uint64(e.ptrToUint32(p)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, e.ptrToUint64(p))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndFloat32Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, e.ptrToFloat32(p))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndFloat64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
b = appendStructEnd(b)
code = code.next
break
}
v := e.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-11 13:21:30 +03:00
case opStructEndFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
v := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, e.ptrToString(p))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, e.ptrToString(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndBoolPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, e.ptrToBool(p))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
p := ptr + code.offset
v := e.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, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, buf.Bytes()...)
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
p := ptr + code.offset
v := e.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 = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt8(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt16(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt32(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToInt64(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, v)
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint8(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint16(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint32(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, uint64(v))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToUint64(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = appendUint(b, v)
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToFloat32(ptr + code.offset)
if v != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, v)
}
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)
v := e.ptrToFloat64(ptr + code.offset)
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToString(ptr + code.offset)
if v != "" {
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, v)
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToBool(ptr + code.offset)
if v {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToBytes(ptr + code.offset)
if len(v) > 0 {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
v := e.ptrToInterface(code, p)
if v != nil {
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
}
var buf bytes.Buffer
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = append(b, buf.Bytes()...)
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyMarshalText:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
v := e.ptrToInterface(code, p)
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)))
}
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagInt8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagInt16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagInt32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagInt64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagUint8:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagUint16:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagUint32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagUint64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, uint64(e.ptrToUint64(ptr+code.offset)))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
s := e.ptrToString(ptr + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +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, '"')
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := e.ptrToBytes(ptr + code.offset)
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = appendStructEnd(b)
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
v := e.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, e.enabledHTMLEscape); err != nil {
return nil, err
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, buf.String())
b = appendStructEnd(b)
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
v := e.ptrToInterface(code, p)
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
}