go-json/encode_vm_escaped_indent.go

4532 lines
115 KiB
Go
Raw Normal View History

2021-01-10 23:16:37 +03:00
package json
import (
"bytes"
"fmt"
"math"
"reflect"
"sort"
"strings"
2021-01-10 23:16:37 +03:00
"unsafe"
)
2021-01-31 16:45:59 +03:00
func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) {
recursiveLevel := 0
2021-01-10 23:16:37 +03:00
ptrOffset := uintptr(0)
ctxptr := ctx.ptr()
2021-01-24 09:17:39 +03:00
code := codeSet.code
2021-01-10 23:16:37 +03:00
for {
switch code.op {
default:
2021-02-01 06:01:56 +03:00
return nil, fmt.Errorf("encoder (escaped+indent): opcode %s has not been implemented", code.op)
2021-01-11 13:05:06 +03:00
case opPtr:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
code = code.next
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
2021-01-11 13:05:06 +03:00
case opInt:
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:05:06 +03:00
case opUint:
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:05:06 +03:00
case opIntString:
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:05:06 +03:00
case opUintString:
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:05:06 +03:00
case opFloat32:
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:05:06 +03:00
case opFloat64:
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(load(ctxptr, code.idx))
2021-01-10 23:16:37 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opString:
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:05:06 +03:00
case opBool:
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:05:06 +03:00
case opBytes:
p := load(ctxptr, code.idx)
slice := ptrToSlice(p)
if p == 0 || slice.data == nil {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
} else {
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opNumber:
bb, err := encodeNumber(b, ptrToNumber(load(ctxptr, code.idx)))
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
code = code.next
2021-01-11 13:05:06 +03:00
case opInterface:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.next
break
}
2021-01-24 17:27:23 +03:00
for _, seen := range ctx.seenPtr {
if ptr == seen {
return nil, errUnsupportedValue(code, ptr)
}
2021-01-10 23:16:37 +03:00
}
2021-01-24 17:27:23 +03:00
ctx.seenPtr = append(ctx.seenPtr, ptr)
2021-03-13 08:12:31 +03:00
iface := (*emptyInterface)(ptrToUnsafePtr(ptr))
2021-01-24 17:27:23 +03:00
if iface == nil || iface.ptr == nil {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.next
break
}
2021-01-24 17:27:23 +03:00
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(iface))
2021-01-31 16:45:59 +03:00
ifaceCodeSet, err := encodeCompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ)))
2021-01-24 17:27:23 +03:00
if err != nil {
return nil, err
2021-01-10 23:16:37 +03:00
}
2021-01-24 17:27:23 +03:00
totalLength := uintptr(codeSet.codeLength)
nextTotalLength := uintptr(ifaceCodeSet.codeLength)
2021-01-10 23:16:37 +03:00
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
}
2021-01-24 17:27:23 +03:00
oldPtrs := ctx.ptrs
newPtrs := ctx.ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:]
newPtrs[0] = uintptr(iface.ptr)
2021-01-10 23:16:37 +03:00
2021-01-24 17:27:23 +03:00
ctx.ptrs = newPtrs
2021-01-31 16:45:59 +03:00
oldBaseIndent := ctx.baseIndent
ctx.baseIndent = code.indent
bb, err := encodeRunEscapedIndent(ctx, b, ifaceCodeSet, opt)
2021-01-24 17:27:23 +03:00
if err != nil {
return nil, err
}
2021-01-31 16:45:59 +03:00
ctx.baseIndent = oldBaseIndent
2021-01-10 23:16:37 +03:00
2021-01-24 17:27:23 +03:00
ctx.ptrs = oldPtrs
ctxptr = ctx.ptr()
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
2021-01-10 23:16:37 +03:00
2021-01-24 17:27:23 +03:00
b = bb
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-11 13:05:06 +03:00
case opMarshalJSON:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.next
break
}
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
2021-01-10 23:16:37 +03:00
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-11 13:05:06 +03:00
case opMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
b = append(b, `""`...)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
break
2021-01-10 23:16:37 +03:00
}
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
2021-01-10 23:16:37 +03:00
code = code.next
case opSlice:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
slice := ptrToSlice(p)
if p == 0 || slice.data == nil {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeIndentComma(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, '[', '\n')
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
code = code.next
store(ctxptr, code.idx, uintptr(slice.data))
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, '[', ']', ',', '\n')
2021-01-10 23:16:37 +03:00
code = code.end.next
}
}
2021-01-11 13:05:06 +03:00
case opSliceElem:
2021-01-10 23:16:37 +03:00
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
if idx < length {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, idx)
data := load(ctxptr, code.headIdx)
size := code.size
code = code.next
store(ctxptr, code.idx, data+idx*size)
} else {
b = b[:len(b)-2]
b = append(b, '\n')
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, ']', ',', '\n')
code = code.end.next
}
case opArray:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
} else {
if code.length > 0 {
b = append(b, '[', '\n')
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, 0)
code = code.next
store(ctxptr, code.idx, p)
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, '[', ']', ',', '\n')
code = code.end.next
}
}
2021-01-11 13:05:06 +03:00
case opArrayElem:
2021-01-10 23:16:37 +03:00
idx := load(ctxptr, code.elemIdx)
idx++
if idx < code.length {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, idx)
p := load(ctxptr, code.headIdx)
size := code.size
code = code.next
store(ctxptr, code.idx, p+idx*size)
} else {
b = b[:len(b)-2]
b = append(b, '\n')
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, ']', ',', '\n')
code = code.end.next
}
2021-03-15 07:29:08 +03:00
case opMapPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opMap:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
} else {
2021-01-31 16:45:59 +03:00
uptr := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{', '\n')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) == 0 {
2021-01-25 07:10:07 +03:00
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
2021-01-10 23:16:37 +03:00
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.next.indent)
2021-01-10 23:16:37 +03:00
}
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
b = append(b, '{', '}', ',', '\n')
code = code.end.next
}
}
2021-01-11 13:05:06 +03:00
case opMapKey:
2021-01-10 23:16:37 +03:00
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) != 0 {
2021-01-10 23:16:37 +03:00
if idx < length {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, idx)
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
last := len(b) - 1
b[last] = '\n'
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
b = append(b, '}', ',', '\n')
code = code.end.next
}
} else {
ptr := load(ctxptr, code.end.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
2021-01-25 07:10:07 +03:00
mapCtx.pos = append(mapCtx.pos, len(b))
2021-01-10 23:16:37 +03:00
if idx < length {
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, idx)
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
code = code.end
}
}
2021-01-11 13:05:06 +03:00
case opMapValue:
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) != 0 {
2021-01-10 23:16:37 +03:00
b = append(b, ':', ' ')
} else {
ptr := load(ctxptr, code.end.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
2021-01-25 07:10:07 +03:00
mapCtx.pos = append(mapCtx.pos, len(b))
2021-01-10 23:16:37 +03:00
}
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
value := mapitervalue(iter)
store(ctxptr, code.next.idx, uintptr(value))
mapiternext(iter)
code = code.next
2021-01-11 13:05:06 +03:00
case opMapEnd:
2021-01-10 23:16:37 +03:00
// this operation only used by sorted map
length := int(load(ctxptr, code.length))
ptr := load(ctxptr, code.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
2021-01-25 07:10:07 +03:00
pos := mapCtx.pos
2021-01-10 23:16:37 +03:00
for i := 0; i < length; i++ {
startKey := pos[i*2]
startValue := pos[i*2+1]
var endValue int
if i+1 < length {
endValue = pos[i*2+2]
} else {
endValue = len(b)
}
2021-01-25 07:10:07 +03:00
mapCtx.slice.items = append(mapCtx.slice.items, mapItem{
key: b[startKey:startValue],
value: b[startValue:endValue],
2021-01-10 23:16:37 +03:00
})
}
2021-01-25 07:10:07 +03:00
sort.Sort(mapCtx.slice)
buf := mapCtx.buf
for _, item := range mapCtx.slice.items {
2021-01-31 16:45:59 +03:00
buf = append(buf, ctx.prefix...)
buf = append(buf, bytes.Repeat(ctx.indentStr, ctx.baseIndent+code.indent+1)...)
2021-01-25 07:10:07 +03:00
buf = append(buf, item.key...)
2021-01-10 23:16:37 +03:00
buf[len(buf)-2] = ':'
buf[len(buf)-1] = ' '
2021-01-25 07:10:07 +03:00
buf = append(buf, item.value...)
2021-01-10 23:16:37 +03:00
}
buf = buf[:len(buf)-2]
buf = append(buf, '\n')
2021-01-31 16:45:59 +03:00
buf = append(buf, ctx.prefix...)
buf = append(buf, bytes.Repeat(ctx.indentStr, ctx.baseIndent+code.indent)...)
2021-01-10 23:16:37 +03:00
buf = append(buf, '}', ',', '\n')
2021-01-25 07:10:07 +03:00
2021-01-10 23:16:37 +03:00
b = b[:pos[0]]
b = append(b, buf...)
2021-01-25 07:10:07 +03:00
mapCtx.buf = buf
releaseMapContext(mapCtx)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldPtrHeadRecursive:
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
case opStructFieldRecursive:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
if recursiveLevel > startDetectingCyclesAfter {
for _, seen := range ctx.seenPtr {
if ptr == seen {
return nil, errUnsupportedValue(code, ptr)
}
}
}
}
ctx.seenPtr = append(ctx.seenPtr, ptr)
c := code.jmp.code
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
oldOffset := ptrOffset
ptrOffset += code.jmp.curLen * uintptrSize
newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen
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, c.end.next.idx, oldOffset)
store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next)))
code = c
recursiveLevel++
case opStructFieldRecursiveEnd:
recursiveLevel--
// restore ctxptr
offset := load(ctxptr, code.idx)
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
codePtr := load(ctxptr, code.elemIdx)
code = (*opcode)(ptrToUnsafePtr(codePtr))
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 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHead:
p := load(ctxptr, code.idx)
if p == 0 && (code.indirect || code.next.op == opStructEnd) {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-13 18:02:58 +03:00
b = append(b, '{', '\n')
}
if !code.anonymousKey && len(code.escapedKey) > 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
}
p += code.offset
2021-01-10 23:16:37 +03:00
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmpty:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
2021-01-13 18:02:58 +03:00
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadOmitEmpty:
p := load(ctxptr, code.idx)
if p == 0 && (code.indirect || code.next.op == opStructEnd) {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{', '\n')
}
p += code.offset
if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadStringTag:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadStringTag:
p := load(ctxptr, code.idx)
if p == 0 && (code.indirect || code.next.op == opStructEnd) {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
p += code.offset
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadInt:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadInt:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, ptrToUint64(p+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyInt:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadOmitEmptyInt:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
u64 := ptrToUint64(p + code.offset)
v := u64 & code.mask
if v == 0 {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, u64, code)
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagInt:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadStringTagInt:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = appendInt(b, ptrToUint64(p+code.offset), code)
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadIntPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadIntPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-10 23:16:37 +03:00
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, ptrToUint64(p), code)
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadUint:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
2021-01-13 18:02:58 +03:00
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-13 18:02:58 +03:00
fallthrough
case opStructFieldHeadOmitEmptyUint:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
u64 := ptrToUint64(p + code.offset)
v := u64 & code.mask
if v == 0 {
2021-01-13 18:02:58 +03:00
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent+1)
2021-01-13 18:02:58 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendUint(b, u64, code)
2021-01-13 18:02:58 +03:00
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-13 18:02:58 +03:00
fallthrough
case opStructFieldHeadStringTagUint:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-13 18:02:58 +03:00
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = appendUint(b, ptrToUint64(p+code.offset), code)
b = append(b, '"')
2021-01-13 18:02:58 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadUintPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadUintPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-13 18:02:58 +03:00
fallthrough
case opStructFieldHeadOmitEmptyUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
b = appendIndent(ctx, b, code.indent+1)
2021-01-13 18:02:58 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendUint(b, ptrToUint64(p), code)
2021-01-13 18:02:58 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-13 18:02:58 +03:00
fallthrough
case opStructFieldHeadStringTagUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-13 18:02:58 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-13 18:02:58 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
2021-01-13 18:02:58 +03:00
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat32:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-16 20:53:54 +03:00
}
fallthrough
case opStructFieldHeadFloat32:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-16 20:53:54 +03:00
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-16 20:53:54 +03:00
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat32:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-16 20:53:54 +03:00
}
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{', '\n')
}
v := ptrToFloat32(p + code.offset)
if v == 0 {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat32(b, v)
2021-01-16 20:53:54 +03:00
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagFloat32:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-16 20:53:54 +03:00
fallthrough
case opStructFieldHeadStringTagFloat32:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-16 20:53:54 +03:00
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
b = append(b, '"')
2021-01-16 20:53:54 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat32Ptr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadFloat32Ptr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-16 20:53:54 +03:00
fallthrough
case opStructFieldHeadOmitEmptyFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-16 20:53:54 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-16 20:53:54 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-16 20:53:54 +03:00
fallthrough
case opStructFieldHeadStringTagFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat64:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadFloat64:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.end.next
break
}
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-10 23:16:37 +03:00
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat64:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-17 16:06:16 +03:00
}
fallthrough
case opStructFieldHeadOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-10 23:16:37 +03:00
}
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-17 16:06:16 +03:00
}
if v == 0 {
2021-01-17 16:06:16 +03:00
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagFloat64:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 15:50:52 +03:00
}
fallthrough
case opStructFieldHeadStringTagFloat64:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-18 15:50:52 +03:00
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat64Ptr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
}
code = code.end.next
break
2021-01-18 15:50:52 +03:00
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadFloat64Ptr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
2021-01-18 15:50:52 +03:00
b = encodeNull(b)
b = encodeIndentComma(b)
2021-01-18 15:50:52 +03:00
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat64Ptr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadOmitEmptyFloat64Ptr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 15:50:52 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagFloat64Ptr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadStringTagFloat64Ptr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadString:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadString:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-10 23:16:37 +03:00
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeEscapedString(b, ptrToString(p+code.offset))
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyString:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadOmitEmptyString:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
v := ptrToString(p + code.offset)
if v == "" {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeEscapedString(b, v)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagString:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadStringTagString:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
v := ptrToString(p + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, v)))
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadStringPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
}
code = code.end.next
break
2021-01-18 15:50:52 +03:00
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadStringPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
2021-01-10 23:16:37 +03:00
} else {
b = encodeEscapedString(b, ptrToString(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyStringPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyStringPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
2021-01-18 15:50:52 +03:00
}
if p != 0 {
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeEscapedString(b, ptrToString(p))
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagStringPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadStringTagStringPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBool:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadBool:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeBool(b, ptrToBool(p+code.offset))
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBool:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadOmitEmptyBool:
p := load(ctxptr, code.idx)
2021-01-18 15:50:52 +03:00
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
v := ptrToBool(p + code.offset)
if v {
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeBool(b, v)
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
code = code.next
} else {
code = code.nextField
}
case opStructFieldPtrHeadStringTagBool:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 15:50:52 +03:00
}
fallthrough
case opStructFieldHeadStringTagBool:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-18 15:50:52 +03:00
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = encodeBool(b, ptrToBool(p+code.offset))
b = append(b, '"')
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBoolPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadBoolPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p+code.offset))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBoolPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadOmitEmptyBoolPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeBool(b, ptrToBool(p))
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagBoolPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
case opStructFieldHeadStringTagBoolPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p))
2021-01-18 15:50:52 +03:00
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBytes:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 16:35:10 +03:00
}
fallthrough
case opStructFieldHeadBytes:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
}
code = code.end.next
break
2021-01-18 16:35:10 +03:00
}
if !code.anonymousHead {
b = append(b, '{', '\n')
2021-01-18 16:35:10 +03:00
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, ptrToBytes(p+code.offset))
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBytes:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{', '\n')
}
v := ptrToBytes(p + code.offset)
if len(v) == 0 {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, v)
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagBytes:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadStringTagBytes:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-18 16:35:10 +03:00
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, ptrToBytes(p+code.offset))
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBytesPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadBytesPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBytesPtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadOmitEmptyBytesPtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 16:35:10 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagBytesPtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadStringTagBytesPtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 16:35:10 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeByteSlice(b, ptrToBytes(p))
b = append(b, '"')
2021-01-18 16:35:10 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldHeadNumber:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.end.next
break
2021-01-10 23:16:37 +03:00
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeNumber(b, ptrToNumber(p+code.offset))
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldPtrHeadOmitEmptyNumber:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadOmitEmptyNumber:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
v := ptrToNumber(p + code.offset)
if v == "" {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeNumber(b, v)
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
2021-01-10 23:16:37 +03:00
code = code.next
}
case opStructFieldPtrHeadStringTagNumber:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadStringTagNumber:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = append(b, '"')
bb, err := encodeNumber(b, ptrToNumber(p+code.offset))
if err != nil {
return nil, err
}
b = append(bb, '"')
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadNumberPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
}
code = code.end.next
break
2021-01-18 16:35:10 +03:00
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadNumberPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
2021-01-18 16:35:10 +03:00
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
2021-01-10 23:16:37 +03:00
} else {
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = bb
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyNumberPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyNumberPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
b = append(b, code.escapedKey...)
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
2021-01-18 16:35:10 +03:00
}
code = code.next
case opStructFieldPtrHeadStringTagNumberPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
2021-01-18 16:35:10 +03:00
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadStringTagNumberPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = append(bb, '"')
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray,
opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadArray, opStructFieldHeadStringTagArray,
opStructFieldHeadSlice, opStructFieldHeadStringTagSlice:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p += code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptyArray:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 16:35:10 +03:00
}
fallthrough
case opStructFieldHeadOmitEmptyArray:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
p += code.offset
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptySlice:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadOmitEmptySlice:
p := load(ctxptr, code.idx)
2021-01-18 16:35:10 +03:00
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
p += code.offset
slice := ptrToSlice(p)
if slice.data == nil {
code = code.nextField
2021-01-18 16:35:10 +03:00
} else {
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
2021-01-18 16:35:10 +03:00
}
case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr,
opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr,
opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 16:35:10 +03:00
if p == 0 {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
2021-01-18 16:35:10 +03:00
}
case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
case opStructFieldHeadMap, opStructFieldHeadStringTagMap:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if p != 0 && code.indirect {
p = ptrToPtr(p + code.offset)
2021-01-18 16:35:10 +03:00
}
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptyMap:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadOmitEmptyMap:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{', '\n')
}
if p != 0 && code.indirect {
p = ptrToPtr(p + code.offset)
}
if maplen(ptrToUnsafePtr(p)) == 0 {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.nextField
2021-01-10 23:16:37 +03:00
break
}
p = ptrToPtr(p + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
if code.indirect {
p = ptrToPtr(p)
}
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadOmitEmptyMapPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyMapPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{', '\n')
}
if p == 0 {
code = code.nextField
break
}
p = ptrToPtr(p + code.offset)
if p == 0 {
code = code.nextField
} else {
if code.indirect {
p = ptrToPtr(p)
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldPtrHeadMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
2021-01-10 23:16:37 +03:00
fallthrough
case opStructFieldHeadMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON {
p = ptrToPtr(p + code.offset)
}
}
if code.nilcheck && p == 0 {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
} else {
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = bb
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
}
fallthrough
case opStructFieldHeadStringTagMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON {
p = ptrToPtr(p + code.offset)
}
}
if code.nilcheck && p == 0 {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
} else {
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = bb
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
}
fallthrough
case opStructFieldHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
2021-01-10 23:16:37 +03:00
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON {
p = ptrToPtr(p + code.offset)
}
}
if p == 0 && code.nilcheck {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = bb
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if p == 0 {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = bb
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
case opStructFieldHeadMarshalText:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadMarshalText {
p = ptrToPtr(p + code.offset)
}
}
if code.nilcheck && p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadStringTagMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
case opStructFieldHeadStringTagMarshalText:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText {
p = ptrToPtr(p + code.offset)
}
}
if code.nilcheck && p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
case opStructFieldHeadOmitEmptyMarshalText:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText {
p = ptrToPtr(p + code.offset)
}
}
if p == 0 && code.nilcheck {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeIndentComma(b)
}
code = code.end.next
break
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
if p == 0 {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
b = encodeIndentComma(b)
code = code.next
}
case opStructField:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmpty:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
}
case opStructFieldStringTag:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldInt:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyInt:
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
if v != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, u64, code)
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagInt:
ptr := load(ctxptr, code.headIdx)
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
case opStructFieldIntPtr:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyIntPtr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, ptrToUint64(p), code)
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagIntPtr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldUint:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyUint:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
if v != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendUint(b, u64, code)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
}
code = code.next
case opStructFieldStringTagUint:
ptr := load(ctxptr, code.headIdx)
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
case opStructFieldUintPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyUintPtr:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendUint(b, ptrToUint64(p), code)
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
}
code = code.next
case opStructFieldStringTagUintPtr:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if p == 0 {
b = encodeNull(b)
2021-01-10 23:16:37 +03:00
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
b = append(b, '"')
2021-01-10 23:16:37 +03:00
}
2021-01-17 09:49:34 +03:00
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldFloat32:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
case opStructFieldOmitEmptyFloat32:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat32(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if v != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat32(b, v)
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldFloat32Ptr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyFloat32Ptr:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-10 23:16:37 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagFloat32Ptr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldFloat64:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyFloat64:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat64(ptr + code.offset)
2021-01-16 20:53:54 +03:00
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat64(b, v)
2021-01-16 20:53:54 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagFloat64:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = encodeFloat64(b, v)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = encodeIndentComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
case opStructFieldFloat64Ptr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyFloat64Ptr:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-16 20:53:54 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-16 20:53:54 +03:00
}
b = encodeFloat64(b, v)
2021-01-16 20:53:54 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagFloat64Ptr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
b = encodeIndentComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
case opStructFieldString:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
case opStructFieldOmitEmptyString:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToString(ptr + code.offset)
if v != "" {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeEscapedString(b, v)
2021-01-17 16:06:16 +03:00
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
}
code = code.next
case opStructFieldStringTagString:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
s := ptrToString(ptr + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldStringPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyStringPtr:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 16:06:16 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 16:06:16 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeEscapedString(b, ptrToString(p))
2021-01-17 16:06:16 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagStringPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 16:06:16 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-17 16:06:16 +03:00
}
b = encodeIndentComma(b)
2021-01-17 16:06:16 +03:00
code = code.next
case opStructFieldBool:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToBool(ptr + code.offset)
if v {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeBool(b, v)
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagBool:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, ' ', '"')
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldBoolPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
2021-01-18 15:50:52 +03:00
code = code.next
case opStructFieldOmitEmptyBoolPtr:
2021-01-18 15:50:52 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-18 15:50:52 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeBool(b, ptrToBool(p))
2021-01-18 15:50:52 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagBoolPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p))
2021-01-18 15:50:52 +03:00
b = append(b, '"')
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldBytes:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToBytes(ptr + code.offset)
if len(v) > 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, v)
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagBytes:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldBytesPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyBytesPtr:
2021-01-18 16:35:10 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-18 16:35:10 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-18 16:35:10 +03:00
b = encodeIndentComma(b)
}
code = code.next
case opStructFieldStringTagBytesPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-18 16:35:10 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-18 16:35:10 +03:00
}
b = encodeIndentComma(b)
2021-01-18 16:35:10 +03:00
code = code.next
case opStructFieldNumber:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
bb, err := encodeNumber(b, ptrToNumber(p+code.offset))
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
code = code.next
case opStructFieldOmitEmptyNumber:
p := load(ctxptr, code.headIdx)
v := ptrToNumber(p + code.offset)
if v != "" {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeNumber(b, v)
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
}
code = code.next
case opStructFieldStringTagNumber:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = append(b, '"')
p := load(ctxptr, code.headIdx)
bb, err := encodeNumber(b, ptrToNumber(p+code.offset))
if err != nil {
return nil, err
}
b = append(bb, '"')
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldNumberPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = bb
2021-01-10 23:16:37 +03:00
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyNumberPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
}
code = code.next
case opStructFieldStringTagNumberPtr:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = append(bb, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p += code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 && code.nilcheck {
b = encodeNull(b)
} else {
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalJSON:
p := load(ctxptr, code.headIdx)
p += code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 && code.nilcheck {
code = code.nextField
break
}
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
code = code.next
case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr:
p := load(ctxptr, code.headIdx)
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true)
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
}
code = code.next
case opStructFieldMarshalText, opStructFieldStringTagMarshalText:
p := load(ctxptr, code.headIdx)
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p += code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 && code.nilcheck {
b = encodeNull(b)
} else {
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldOmitEmptyMarshalText:
p := load(ctxptr, code.headIdx)
p += code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 && code.nilcheck {
code = code.nextField
break
}
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
code = code.next
case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr:
p := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = encodeIndentComma(bb)
}
code = code.next
case opStructFieldArray, opStructFieldStringTagArray:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p += code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyArray:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p += code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyArrayPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
case opStructFieldSlice, opStructFieldStringTagSlice:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p += code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptySlice:
p := load(ctxptr, code.headIdx)
p += code.offset
slice := ptrToSlice(p)
if slice.data == nil {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptySlicePtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
} else {
code = code.nextField
2021-01-10 23:16:37 +03:00
}
case opStructFieldMap, opStructFieldStringTagMap:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMap:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
}
case opStructFieldMapPtr, opStructFieldStringTagMapPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
p = ptrToPtr(p)
}
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMapPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
p = ptrToPtr(p)
}
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
2021-01-10 23:16:37 +03:00
}
case opStructFieldStruct:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-17 09:49:34 +03:00
if p == 0 {
b = append(b, '{', '}', ',', '\n')
code = code.nextField
2021-01-17 09:49:34 +03:00
} else {
headCode := code.next
if headCode.next == headCode.end {
// not exists fields
b = append(b, '{', '}', ',', '\n')
code = code.nextField
} else {
code = code.next
store(ctxptr, code.idx, p)
}
2021-01-17 09:49:34 +03:00
}
case opStructFieldOmitEmptyStruct:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
headCode := code.next
if headCode.next == headCode.end {
// not exists fields
b = append(b, '{', '}', ',', '\n')
code = code.nextField
} else {
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructAnonymousEnd:
code = code.next
case opStructEnd:
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
b = encodeIndentComma(b)
code = code.next
break
}
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent)
b = append(b, '}')
b = encodeIndentComma(b)
code = code.next
case opStructEndInt:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndOmitEmptyInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-10 23:16:37 +03:00
if v != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, u64, code)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructEndStringTagInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndIntPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndOmitEmptyIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, ptrToUint64(p), code)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
}
code = code.next
case opStructEndStringTagIntPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
code = code.next
case opStructEndUint:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-10 23:16:37 +03:00
if v != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendUint(b, u64, code)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructEndStringTagUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndUintPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndOmitEmptyUintPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendUint(b, ptrToUint64(p), code)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
}
code = code.next
case opStructEndStringTagUintPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
b = append(b, '"')
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat32:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-17 09:49:34 +03:00
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)
2021-01-31 16:45:59 +03:00
v := ptrToFloat32(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if v != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeFloat32(b, v)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat32Ptr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-10 23:16:37 +03:00
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndOmitEmptyFloat32Ptr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
}
code = code.next
case opStructEndStringTagFloat32Ptr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat64:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-10 23:16:37 +03:00
}
2021-01-17 09:49:34 +03:00
b = encodeFloat64(b, v)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-01-17 09:49:34 +03:00
b = encodeFloat64(b, v)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
2021-01-17 09:49:34 +03:00
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat64Ptr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
2021-01-17 09:49:34 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndOmitEmptyFloat64Ptr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
}
code = code.next
case opStructEndStringTagFloat64Ptr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = append(b, '"')
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndString:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToString(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != "" {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeEscapedString(b, v)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-20 18:22:20 +03:00
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
2021-01-20 18:22:20 +03:00
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
}
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, ' ')
2021-01-31 16:45:59 +03:00
s := ptrToString(ptr + code.offset)
2021-01-17 09:49:34 +03:00
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-20 18:22:20 +03:00
case opStructEndStringPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-20 18:22:20 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-20 18:22:20 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(p))
2021-01-20 18:22:20 +03:00
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-20 18:22:20 +03:00
code = code.next
case opStructEndOmitEmptyStringPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-20 18:22:20 +03:00
if p != 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-20 18:22:20 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(p))
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-20 18:22:20 +03:00
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
2021-01-22 14:06:20 +03:00
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
2021-01-20 18:22:20 +03:00
b = append(b, '}')
}
b = encodeIndentComma(b)
}
code = code.next
case opStructEndStringTagStringPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-20 18:22:20 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-20 18:22:20 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-20 18:22:20 +03:00
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-20 18:22:20 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndBool:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToBool(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeBool(b, v)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-22 14:06:20 +03:00
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
2021-01-22 14:06:20 +03:00
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
}
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ', '"')
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndBoolPtr:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = appendStructEndIndent(ctx, b, code.indent-1)
code = code.next
case opStructEndOmitEmptyBoolPtr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeBool(b, ptrToBool(p))
b = appendStructEndIndent(ctx, b, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
}
code = code.next
case opStructEndStringTagBoolPtr:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p))
b = append(b, '"')
}
b = appendStructEndIndent(ctx, b, code.indent-1)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndBytes:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToBytes(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if len(v) > 0 {
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = encodeByteSlice(b, v)
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-22 14:06:20 +03:00
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
2021-01-22 14:06:20 +03:00
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBytes:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
b = encodeByteSlice(b, ptrToBytes(p+code.offset))
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndNumber:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
bb, err := encodeNumber(b, ptrToNumber(p+code.offset))
2021-01-17 09:49:34 +03:00
if err != nil {
return nil, err
}
b = appendStructEndIndent(ctx, bb, code.indent-1)
code = code.next
case opStructEndOmitEmptyNumber:
p := load(ctxptr, code.headIdx)
v := ptrToNumber(p + code.offset)
if v != "" {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeNumber(b, v)
if err != nil {
return nil, err
}
b = appendStructEndIndent(ctx, bb, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
2021-01-17 09:49:34 +03:00
}
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndStringTagNumber:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = append(b, '"')
p := load(ctxptr, code.headIdx)
bb, err := encodeNumber(b, ptrToNumber(p+code.offset))
2021-01-10 23:16:37 +03:00
if err != nil {
return nil, err
}
b = append(bb, '"')
b = appendStructEndIndent(ctx, b, code.indent-1)
code = code.next
case opStructEndNumberPtr:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = bb
2021-01-10 23:16:37 +03:00
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructEndOmitEmptyNumberPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = appendStructEndIndent(ctx, bb, code.indent-1)
} else {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.indent-1)
b = append(b, '}')
}
b = encodeIndentComma(b)
}
code = code.next
case opStructEndStringTagNumberPtr:
2021-02-01 05:36:41 +03:00
b = appendIndent(ctx, b, code.indent)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
bb, err := encodeNumber(b, ptrToNumber(p))
if err != nil {
return nil, err
}
b = append(bb, '"')
2021-01-10 23:16:37 +03:00
}
2021-01-31 16:45:59 +03:00
b = appendStructEndIndent(ctx, b, code.indent-1)
2021-01-10 23:16:37 +03:00
code = code.next
case opEnd:
goto END
}
}
END:
return b, nil
}