2021-01-10 23:16:37 +03:00
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding"
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
"reflect"
|
2021-01-22 10:28:12 +03:00
|
|
|
"runtime"
|
2021-01-10 23:16:37 +03:00
|
|
|
"sort"
|
2021-01-29 19:14:22 +03:00
|
|
|
"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) {
|
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:
|
2021-02-19 09:03:52 +03:00
|
|
|
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:
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opIntString:
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opUintString:
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
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:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-31 16:45:59 +03:00
|
|
|
slice := ptrToSlice(ptr)
|
2021-01-10 23:16:37 +03:00
|
|
|
if ptr == 0 || uintptr(slice.data) == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
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-01-31 16:45:59 +03:00
|
|
|
iface := (*interfaceHeader)(ptrToUnsafePtr(ptr))
|
2021-01-24 17:27:23 +03:00
|
|
|
if iface == nil || iface.ptr == nil {
|
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:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-22 07:28:33 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, ptr)
|
2021-01-10 23:16:37 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-22 10:28:12 +03:00
|
|
|
runtime.KeepAlive(v)
|
2021-01-10 23:16:37 +03:00
|
|
|
if len(bb) == 0 {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
var compactBuf bytes.Buffer
|
|
|
|
if err := compact(&compactBuf, bb, true); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var indentBuf bytes.Buffer
|
2021-01-10 23:16:37 +03:00
|
|
|
if err := encodeWithIndent(
|
2021-01-29 19:14:22 +03:00
|
|
|
&indentBuf,
|
|
|
|
compactBuf.Bytes(),
|
2021-01-31 16:45:59 +03:00
|
|
|
string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent),
|
|
|
|
string(ctx.indentStr),
|
2021-01-10 23:16:37 +03:00
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
b = append(b, indentBuf.Bytes()...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-01-11 13:05:06 +03:00
|
|
|
case opMarshalText:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToUnsafePtr(ptr)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == nil {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
} else if isPtr && *(*unsafe.Pointer)(p) == nil {
|
|
|
|
b = append(b, '"', '"', ',', '\n')
|
|
|
|
} else {
|
|
|
|
if isPtr && code.typ.Elem().Implements(marshalTextType) {
|
|
|
|
p = *(*unsafe.Pointer)(p)
|
|
|
|
}
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
|
|
|
ptr: p,
|
|
|
|
}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-11 13:05:06 +03:00
|
|
|
case opSliceHead:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
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 = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
slice := ptrToSlice(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
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)
|
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 opRootSliceHead:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
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 = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-31 16:45:59 +03:00
|
|
|
slice := ptrToSlice(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
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)
|
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 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
|
|
|
|
}
|
2021-01-11 13:05:06 +03:00
|
|
|
case opRootSliceElem:
|
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)
|
|
|
|
code = code.next
|
|
|
|
data := load(ctxptr, code.headIdx)
|
|
|
|
store(ctxptr, code.idx, data+idx*code.size)
|
|
|
|
} else {
|
|
|
|
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, ']')
|
|
|
|
code = code.end.next
|
|
|
|
}
|
2021-01-11 13:05:06 +03:00
|
|
|
case opArrayHead:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
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 = 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-01-11 13:05:06 +03:00
|
|
|
case opMapHead:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-10 23:16:37 +03:00
|
|
|
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 {
|
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 opMapHeadLoad:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
// load pointer
|
2021-01-31 16:45:59 +03:00
|
|
|
ptr = ptrToPtr(ptr)
|
|
|
|
uptr := ptrToUnsafePtr(ptr)
|
2021-01-10 23:16:37 +03:00
|
|
|
if uintptr(uptr) == 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
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))
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
|
2021-01-31 16:45:59 +03:00
|
|
|
if (opt & EncodeOptionUnorderedMap) == 0 {
|
2021-01-25 07:10:07 +03:00
|
|
|
mapCtx := newMapContext(mlen)
|
|
|
|
mapCtx.pos = append(mapCtx.pos, len(b))
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
|
|
|
|
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
|
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
|
|
|
}
|
|
|
|
|
|
|
|
code = code.next
|
|
|
|
} 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 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
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldPtrHead:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldHead:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if ptr == 0 && code.indirect {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else if code.next == code.end {
|
|
|
|
// not exists fields
|
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
|
|
|
|
store(ctxptr, code.idx, ptr)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
if !code.anonymousKey {
|
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 := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-13 18:02:58 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if ptr == 0 && code.indirect {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, '{', '\n')
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrHeadStringTag:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTag:
|
2021-01-13 18:02:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if ptr == 0 && code.indirect {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
p := ptr + code.offset
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldPtrHeadInt:
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldHeadInt:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt:
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-11 20:40:12 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-11 20:40:12 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, u64, code)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt:
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-11 20:40:12 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ', '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrHeadIntPtr:
|
2021-01-11 20:40:12 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-02-28 17:22:46 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-11 20:40:12 +03:00
|
|
|
}
|
2021-02-28 17:22:46 +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 opStructFieldHeadIntPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if p == 0 && code.indirect {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
p = ptrToPtr(p + code.offset)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntPtr:
|
2021-02-28 17:22:46 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-11 20:40:12 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if p == 0 && code.indirect {
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
p = ptrToPtr(p + code.offset)
|
|
|
|
}
|
2021-01-11 20:40:12 +03:00
|
|
|
if p != 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagIntPtr:
|
2021-02-28 17:22:46 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-11 20:40:12 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if p == 0 && code.indirect {
|
2021-01-11 20:40:12 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
p = ptrToPtr(p + code.offset)
|
|
|
|
}
|
2021-01-11 20:40:12 +03:00
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-11 20:40:12 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-11 20:40:12 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldHeadIntNPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\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, ' ')
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadInt:
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldAnonymousHeadInt:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
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-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-13 18:02:58 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, u64, code)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt:
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, ' ')
|
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-11 13:21:30 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadIntPtr:
|
2021-01-13 18:02:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldAnonymousHeadIntPtr:
|
2021-01-13 18:02:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if p == 0 && code.indirect {
|
2021-01-13 18:02:58 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
p = ptrToPtr(p + code.offset)
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-13 18:02:58 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
|
2021-01-13 18:02:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if p == 0 && code.indirect {
|
2021-01-13 18:02:58 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
p = ptrToPtr(p + code.offset)
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
|
2021-01-13 18:02:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(p))
|
2021-01-13 18:02:58 +03:00
|
|
|
fallthrough
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagIntPtr:
|
2021-01-13 18:02:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-02-28 17:22:46 +03:00
|
|
|
if p == 0 && code.indirect {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-28 17:22:46 +03:00
|
|
|
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, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-13 18:02:58 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadUint:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadUint:
|
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 {
|
|
|
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-19 09:03:52 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-16 20:53:54 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, u64, code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
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, ' ', '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrHeadUintPtr:
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUintPtr:
|
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
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadUintNPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\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, ' ')
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadUint:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
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-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-16 20:53:54 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, u64, code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUint:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, ' ')
|
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadUintPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUintPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-16 20:53:54 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUintPtr:
|
2021-01-16 20:53:54 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat32:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat32:
|
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 {
|
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32:
|
2021-01-17 16:06:16 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-17 16:06:16 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32:
|
2021-01-17 16:06:16 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-17 16:06:16 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-17 16:06:16 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat32:
|
2021-01-17 16:06:16 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-17 16:06:16 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat32:
|
2021-01-17 16:06:16 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ', '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat32Ptr:
|
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
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 16:06:16 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32Ptr:
|
2021-01-17 16:06:16 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
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+1)
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-17 16:06:16 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 16:06:16 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat32Ptr:
|
2021-01-17 16:06:16 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 16:06:16 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat32NPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat32:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
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-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 16:06:16 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat32:
|
2021-01-17 16:06:16 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-17 16:06:16 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-17 16:06:16 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 16:06:16 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat32:
|
2021-01-17 16:06:16 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, ' ')
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32Ptr:
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadFloat32Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 16:06:16 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat32Ptr:
|
2021-01-17 16:06:16 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 16:06:16 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-17 16:06:16 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-17 16:06:16 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat32Ptr:
|
2021-01-17 16:06:16 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-17 16:06:16 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
|
2021-01-17 16:06:16 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat64:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat64:
|
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-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-10 23:16:37 +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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-18 15:50:52 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 15:50:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
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, ' ', '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat64Ptr:
|
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
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadFloat64NPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat64:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
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-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr)
|
|
|
|
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
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-18 15:50:52 +03:00
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat64:
|
2021-01-18 15:50:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, ' ')
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr)
|
|
|
|
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
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat64Ptr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64Ptr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 15:50:52 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat64Ptr:
|
2021-01-18 15:50:52 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 15:50:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadString:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadString:
|
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 {
|
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(ptr))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToString(ptr + code.offset)
|
|
|
|
if v == "" {
|
2021-01-18 16:35:10 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, v)
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
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...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, ' ')
|
|
|
|
v := ptrToString(ptr + code.offset)
|
|
|
|
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, v)))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringPtr:
|
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
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringNPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(p+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadString:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadString:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
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-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyString:
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToString(ptr + code.offset)
|
|
|
|
if v == "" {
|
2021-01-18 16:35:10 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, v)
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-28 17:22:46 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagString:
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagString:
|
2021-01-18 16:35:10 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(ptr+code.offset))))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(p+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagStringPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-18 16:35:10 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagStringPtr:
|
2021-01-18 16:35:10 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-18 16:35:10 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p+code.offset))))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBool:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBool:
|
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 {
|
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
} else {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ', '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBoolPtr:
|
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
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-02-28 17:22:46 +03:00
|
|
|
if code.indirect {
|
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBoolPtr:
|
2021-01-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 {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '{', '\n')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagBoolPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-10 23:16:37 +03:00
|
|
|
} else {
|
|
|
|
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, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBoolNPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\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, ' ')
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBool:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadBool:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
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-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBool:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
} else {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBool:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBool:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, ' ')
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBoolPtr:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBoolPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
p = ptrToPtr(p)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadBytes:
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-19 08:54:27 +03:00
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '{', '\n')
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
2021-01-31 16:45:59 +03:00
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBytes:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '{', '\n')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, v)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '\n')
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent+1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
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 || **(**uintptr)(unsafe.Pointer(&p)) == 0 {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case 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)
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, u64, code)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = appendIndent(ctx, b, code.indent)
|
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ', '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldIntPtr:
|
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyIntPtr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagIntPtr:
|
2021-02-15 05:31:49 +03:00
|
|
|
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 {
|
2021-02-15 06:57:16 +03:00
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-02-15 06:57:16 +03:00
|
|
|
b = append(b, '"')
|
2021-02-15 05:31:49 +03:00
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
|
2021-01-17 09:49:34 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyUint:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-19 09:03:52 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, u64, code)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +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, ' ', '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyUintPtr:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.indent)
|
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagUintPtr:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyFloat32:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat32(ptr + code.offset)
|
2021-01-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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ', '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-01-12 18:14:46 +03:00
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-12 18:14:46 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyFloat64:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
2021-01-16 20:53:54 +03:00
|
|
|
if v != 0 {
|
2021-02-18 21:06:21 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagFloat64:
|
2021-01-16 20:53:54 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-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, ' ', '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-16 20:53:54 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2021-01-16 20:53:54 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeFloat64(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-16 20:53:54 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-16 20:53:54 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-17 09:49:34 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyString:
|
2021-01-17 09:49:34 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
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...)
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, ptrToString(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeNoEscapedString(b, ptrToString(p))
|
2021-01-17 16:06:16 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
|
2021-01-17 16:06:16 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-17 16:06:16 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyBool:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ', '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
2021-01-17 09:49:34 +03:00
|
|
|
b = append(b, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-18 15:50:52 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-18 15:50:52 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, '"')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeBool(b, ptrToBool(p))
|
2021-01-18 15:50:52 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyBytes:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
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...)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, ' ')
|
|
|
|
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(p))
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeByteSlice(b, ptrToBytes(p))
|
2021-01-18 16:35:10 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
2021-01-18 16:35:10 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldMarshalJSON:
|
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-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
var compactBuf bytes.Buffer
|
|
|
|
if err := compact(&compactBuf, bb, true); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var indentBuf bytes.Buffer
|
|
|
|
if err := encodeWithIndent(
|
|
|
|
&indentBuf,
|
|
|
|
compactBuf.Bytes(),
|
|
|
|
string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent),
|
|
|
|
string(ctx.indentStr),
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, indentBuf.Bytes()...)
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagMarshalJSON:
|
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, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
var compactBuf bytes.Buffer
|
|
|
|
if err := compact(&compactBuf, bb, true); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var indentBuf bytes.Buffer
|
|
|
|
if err := encodeWithIndent(
|
|
|
|
&indentBuf,
|
|
|
|
compactBuf.Bytes(),
|
|
|
|
string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent),
|
|
|
|
string(ctx.indentStr),
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, indentBuf.Bytes()...)
|
|
|
|
b = encodeEscapedString(b, indentBuf.String())
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStringTagMarshalText:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := ptrToInterface(code, p)
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldArray:
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
array := ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(array.data) == 0 {
|
2021-01-19 08:54:27 +03:00
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyArray:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
array := ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(array.data) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.indent)
|
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldSlice:
|
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-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
slice := ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptySlice:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
slice := ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-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-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldMap:
|
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-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.nextField
|
2021-01-10 23:16:37 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
mlen := maplen(ptrToUnsafePtr(p))
|
|
|
|
if mlen == 0 {
|
|
|
|
b = append(b, '{', '}', ',', '\n')
|
|
|
|
mapCode := code.next
|
|
|
|
code = mapCode.end.next
|
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyMap:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
if mlen == 0 {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.next
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldMapLoad:
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
2021-01-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
mlen := maplen(ptrToUnsafePtr(p))
|
|
|
|
if mlen == 0 {
|
|
|
|
b = append(b, '{', '}', ',', '\n')
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyMapLoad:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
if mlen == 0 {
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.next
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldStruct:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-18 21:06:21 +03:00
|
|
|
b = append(b, '{', '}', ',', '\n')
|
|
|
|
code = code.nextField
|
2021-01-17 09:49:34 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
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
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructFieldOmitEmptyStruct:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-18 21:06:21 +03:00
|
|
|
headCode := code.next
|
|
|
|
if headCode.next == headCode.end {
|
|
|
|
// not exists fields
|
|
|
|
b = append(b, '{', '}', ',', '\n')
|
|
|
|
code = code.nextField
|
2021-01-19 08:54:27 +03:00
|
|
|
} else {
|
2021-02-18 21:06:21 +03:00
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructAnonymousEnd:
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEnd:
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last-1] == '{' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
code = code.next
|
|
|
|
break
|
2021-01-19 08:54:27 +03:00
|
|
|
}
|
2021-02-18 21:06:21 +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)
|
|
|
|
b = append(b, '}')
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-19 09:03:52 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyInt:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-18 21:06:21 +03:00
|
|
|
u64 := ptrToUint64(ptr + code.offset)
|
|
|
|
v := u64 & code.mask
|
2021-01-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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, u64, code)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '}')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ', '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-19 09:03:52 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyIntPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '}')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndStringTagIntPtr:
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +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-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +03:00
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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)
|
2021-02-19 09:03:52 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyUint:
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-02-19 09:03:52 +03:00
|
|
|
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, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, u64, code)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '}')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
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, ' ', '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
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 {
|
2021-02-19 09:03:52 +03:00
|
|
|
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
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndOmitEmptyUintPtr:
|
2021-01-19 08:54:27 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 08:54:27 +03:00
|
|
|
if p != 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '}')
|
|
|
|
}
|
|
|
|
b = encodeIndentComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
2021-02-18 21:06:21 +03:00
|
|
|
case opStructEndStringTagUintPtr:
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 08:54:27 +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-19 08:54:27 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-02-19 09:03:52 +03:00
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
2021-01-19 08:54:27 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 08:54:27 +03:00
|
|
|
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)
|
2021-01-19 14:41:14 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 14:41:14 +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 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
|
2021-01-19 14:41:14 +03:00
|
|
|
case opStructEndOmitEmptyFloat32Ptr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
if p != 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 14:41:14 +03:00
|
|
|
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)
|
2021-01-19 14:41:14 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 14:41:14 +03:00
|
|
|
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)
|
2021-01-19 14:41:14 +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-19 14:41:14 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-01-31 16:45:59 +03:00
|
|
|
b = encodeFloat32(b, ptrToFloat32(p))
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 14:41:14 +03:00
|
|
|
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, ' ')
|
2021-01-19 14:41:14 +03:00
|
|
|
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)
|
2021-01-19 14:41:14 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 14:41:14 +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 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
|
2021-01-19 14:41:14 +03:00
|
|
|
case opStructEndOmitEmptyFloat64Ptr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-31 16:45:59 +03:00
|
|
|
p := ptrToPtr(ptr + code.offset)
|
2021-01-19 14:41:14 +03:00
|
|
|
if p != 0 {
|
2021-02-01 05:36:41 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent)
|
2021-01-19 14:41:14 +03:00
|
|
|
b = append(b, code.escapedKey...)
|
|
|
|
b = append(b, ' ')
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(p)
|
2021-01-19 14:41:14 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 14:41:14 +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')
|
2021-02-15 06:57:16 +03:00
|
|
|
b = appendIndent(ctx, b, code.indent-1)
|
2021-01-19 14:41:14 +03:00
|
|
|
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)
|
2021-01-19 14:41:14 +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-19 14:41:14 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToFloat64(p)
|
2021-01-19 14:41:14 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
2021-01-31 16:45:59 +03:00
|
|
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
2021-01-19 14:41:14 +03:00
|
|
|
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')
|
2021-02-15 06:57:16 +03:00
|
|
|
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')
|
2021-02-15 06:57:16 +03:00
|
|
|
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')
|
2021-02-15 06:57:16 +03:00
|
|
|
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
|
2021-02-15 06:57:16 +03:00
|
|
|
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')
|
2021-02-15 06:57:16 +03:00
|
|
|
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-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 = 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 opStructEndMarshalJSON:
|
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
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2021-01-17 09:49:34 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
var compactBuf bytes.Buffer
|
|
|
|
if err := compact(&compactBuf, bb, true); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var indentBuf bytes.Buffer
|
|
|
|
if err := encodeWithIndent(
|
|
|
|
&indentBuf,
|
|
|
|
compactBuf.Bytes(),
|
2021-01-31 16:45:59 +03:00
|
|
|
string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent),
|
|
|
|
string(ctx.indentStr),
|
2021-01-29 19:14:22 +03:00
|
|
|
); err != nil {
|
2021-01-17 09:49:34 +03:00
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
b = append(b, indentBuf.Bytes()...)
|
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-11 13:21:30 +03:00
|
|
|
case opStructEndStringTagMarshalJSON:
|
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, ' ')
|
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2021-01-10 23:16:37 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
var compactBuf bytes.Buffer
|
|
|
|
if err := compact(&compactBuf, bb, true); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var indentBuf bytes.Buffer
|
|
|
|
if err := encodeWithIndent(
|
|
|
|
&indentBuf,
|
|
|
|
compactBuf.Bytes(),
|
2021-01-31 16:45:59 +03:00
|
|
|
string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent),
|
|
|
|
string(ctx.indentStr),
|
2021-01-29 19:14:22 +03:00
|
|
|
); err != nil {
|
2021-01-10 23:16:37 +03:00
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-29 19:14:22 +03:00
|
|
|
b = encodeEscapedString(b, indentBuf.String())
|
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-11 13:21:30 +03:00
|
|
|
case opStructEndStringTagMarshalText:
|
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, ' ')
|
|
|
|
p := ptr + code.offset
|
2021-01-31 16:45:59 +03:00
|
|
|
v := ptrToInterface(code, p)
|
2021-01-10 23:16:37 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
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
|
|
|
|
}
|