From 9cbe7b39917dd844cf6a0f78d21a93daf2529d3d Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Thu, 18 Mar 2021 15:46:55 +0900 Subject: [PATCH] Move encoder source to internal package --- encode.go | 299 +- encode_vm_escaped_indent.go | 4531 -------------------- encode_vm_indent.go | 4532 -------------------- internal/encoder/encoder.go | 79 + internal/encoder/indent.go | 112 + internal/encoder/vm/vm.go | 8 +- internal/encoder/vm_escaped/vm.go | 6 +- internal/encoder/vm_escaped_indent/vm.go | 4993 ++++++++++++++++++++++ internal/encoder/vm_indent/vm.go | 4993 ++++++++++++++++++++++ 9 files changed, 10213 insertions(+), 9340 deletions(-) delete mode 100644 encode_vm_escaped_indent.go delete mode 100644 encode_vm_indent.go create mode 100644 internal/encoder/indent.go create mode 100644 internal/encoder/vm_escaped_indent/vm.go create mode 100644 internal/encoder/vm_indent/vm.go diff --git a/encode.go b/encode.go index 9aee645..4dfdd2c 100644 --- a/encode.go +++ b/encode.go @@ -1,21 +1,15 @@ package json import ( - "bytes" - "encoding" - "encoding/base64" - "fmt" "io" - "math" - "reflect" - "strconv" - "strings" "sync" "unsafe" "github.com/goccy/go-json/internal/encoder" "github.com/goccy/go-json/internal/encoder/vm" "github.com/goccy/go-json/internal/encoder/vm_escaped" + "github.com/goccy/go-json/internal/encoder/vm_escaped_indent" + "github.com/goccy/go-json/internal/encoder/vm_indent" ) // An Encoder writes JSON values to an output stream. @@ -41,15 +35,6 @@ const ( var ( encRuntimeContextPool = sync.Pool{ - New: func() interface{} { - return &encodeRuntimeContext{ - buf: make([]byte, 0, bufSize), - ptrs: make([]uintptr, 128), - keepRefs: make([]unsafe.Pointer, 0, 8), - } - }, - } - encRuntimeContextPool2 = sync.Pool{ New: func() interface{} { return &encoder.RuntimeContext{ Buf: make([]byte, 0, bufSize), @@ -60,22 +45,14 @@ var ( } ) -func takeEncodeRuntimeContext() *encodeRuntimeContext { - return encRuntimeContextPool.Get().(*encodeRuntimeContext) +func takeEncodeRuntimeContext() *encoder.RuntimeContext { + return encRuntimeContextPool.Get().(*encoder.RuntimeContext) } -func releaseEncodeRuntimeContext(ctx *encodeRuntimeContext) { +func releaseEncodeRuntimeContext(ctx *encoder.RuntimeContext) { encRuntimeContextPool.Put(ctx) } -func takeEncodeRuntimeContext2() *encoder.RuntimeContext { - return encRuntimeContextPool2.Get().(*encoder.RuntimeContext) -} - -func releaseEncodeRuntimeContext2(ctx *encoder.RuntimeContext) { - encRuntimeContextPool2.Put(ctx) -} - // NewEncoder returns a new encoder that writes to w. func NewEncoder(w io.Writer) *Encoder { return &Encoder{w: w, enabledHTMLEscape: true} @@ -98,7 +75,7 @@ func (e *Encoder) EncodeWithOption(v interface{}, optFuncs ...EncodeOptionFunc) return err } -func (e *Encoder) encodeWithOption(ctx *encodeRuntimeContext, v interface{}, optFuncs ...EncodeOptionFunc) error { +func (e *Encoder) encodeWithOption(ctx *encoder.RuntimeContext, v interface{}, optFuncs ...EncodeOptionFunc) error { var opt EncodeOption if e.enabledHTMLEscape { opt |= EncodeOptionHTMLEscape @@ -113,9 +90,7 @@ func (e *Encoder) encodeWithOption(ctx *encodeRuntimeContext, v interface{}, opt if e.enabledIndent { buf, err = encodeIndent(ctx, v, e.prefix, e.indentStr, opt) } else { - ctx := takeEncodeRuntimeContext2() buf, err = encode(ctx, v, opt) - releaseEncodeRuntimeContext2(ctx) } if err != nil { return err @@ -153,11 +128,11 @@ func (e *Encoder) SetIndent(prefix, indent string) { } func marshal(v interface{}, opt EncodeOption) ([]byte, error) { - ctx := takeEncodeRuntimeContext2() + ctx := takeEncodeRuntimeContext() buf, err := encode(ctx, v, opt|EncodeOptionHTMLEscape) if err != nil { - releaseEncodeRuntimeContext2(ctx) + releaseEncodeRuntimeContext(ctx) return nil, err } @@ -169,16 +144,16 @@ func marshal(v interface{}, opt EncodeOption) ([]byte, error) { copied := make([]byte, len(buf)) copy(copied, buf) - releaseEncodeRuntimeContext2(ctx) + releaseEncodeRuntimeContext(ctx) return copied, nil } func marshalNoEscape(v interface{}, opt EncodeOption) ([]byte, error) { - ctx := takeEncodeRuntimeContext2() + ctx := takeEncodeRuntimeContext() buf, err := encodeNoEscape(ctx, v, opt|EncodeOptionHTMLEscape) if err != nil { - releaseEncodeRuntimeContext2(ctx) + releaseEncodeRuntimeContext(ctx) return nil, err } @@ -190,7 +165,7 @@ func marshalNoEscape(v interface{}, opt EncodeOption) ([]byte, error) { copied := make([]byte, len(buf)) copy(copied, buf) - releaseEncodeRuntimeContext2(ctx) + releaseEncodeRuntimeContext(ctx) return copied, nil } @@ -214,8 +189,8 @@ func marshalIndent(v interface{}, prefix, indent string, opt EncodeOption) ([]by func encode(ctx *encoder.RuntimeContext, v interface{}, opt EncodeOption) ([]byte, error) { b := ctx.Buf[:0] if v == nil { - b = encodeNull(b) - b = encodeComma(b) + b = encoder.AppendNull(b) + b = encoder.AppendComma(b) return b, nil } header := (*emptyInterface)(unsafe.Pointer(&v)) @@ -242,8 +217,8 @@ func encode(ctx *encoder.RuntimeContext, v interface{}, opt EncodeOption) ([]byt func encodeNoEscape(ctx *encoder.RuntimeContext, v interface{}, opt EncodeOption) ([]byte, error) { b := ctx.Buf[:0] if v == nil { - b = encodeNull(b) - b = encodeComma(b) + b = encoder.AppendNull(b) + b = encoder.AppendComma(b) return b, nil } header := (*emptyInterface)(unsafe.Pointer(&v)) @@ -266,33 +241,33 @@ func encodeNoEscape(ctx *encoder.RuntimeContext, v interface{}, opt EncodeOption return buf, nil } -func encodeIndent(ctx *encodeRuntimeContext, v interface{}, prefix, indent string, opt EncodeOption) ([]byte, error) { - b := ctx.buf[:0] +func encodeIndent(ctx *encoder.RuntimeContext, v interface{}, prefix, indent string, opt EncodeOption) ([]byte, error) { + b := ctx.Buf[:0] if v == nil { - b = encodeNull(b) - b = encodeIndentComma(b) + b = encoder.AppendNull(b) + b = encoder.AppendCommaIndent(b) return b, nil } header := (*emptyInterface)(unsafe.Pointer(&v)) typ := header.typ typeptr := uintptr(unsafe.Pointer(typ)) - codeSet, err := encodeCompileToGetCodeSet(typeptr) + codeSet, err := encoder.CompileToGetCodeSet(typeptr) if err != nil { return nil, err } p := uintptr(header.ptr) - ctx.init(p, codeSet.codeLength) + ctx.Init(p, codeSet.CodeLength) buf, err := encodeRunIndentCode(ctx, b, codeSet, prefix, indent, opt) - ctx.keepRefs = append(ctx.keepRefs, header.ptr) + ctx.KeepRefs = append(ctx.KeepRefs, header.ptr) if err != nil { return nil, err } - ctx.buf = buf + ctx.Buf = buf return buf, nil } @@ -303,227 +278,11 @@ func encodeRunCode(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.Opcod return vm.Run(ctx, b, codeSet, encoder.Option(opt)) } -func encodeRunIndentCode(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, prefix, indent string, opt EncodeOption) ([]byte, error) { - ctx.prefix = []byte(prefix) - ctx.indentStr = []byte(indent) +func encodeRunIndentCode(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, prefix, indent string, opt EncodeOption) ([]byte, error) { + ctx.Prefix = []byte(prefix) + ctx.IndentStr = []byte(indent) if (opt & EncodeOptionHTMLEscape) != 0 { - return encodeRunEscapedIndent(ctx, b, codeSet, opt) + return vm_escaped_indent.Run(ctx, b, codeSet, encoder.Option(opt)) } - return encodeRunIndent(ctx, b, codeSet, opt) -} - -func encodeFloat32(b []byte, v float32) []byte { - f64 := float64(v) - abs := math.Abs(f64) - fmt := byte('f') - // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right. - if abs != 0 { - f32 := float32(abs) - if f32 < 1e-6 || f32 >= 1e21 { - fmt = 'e' - } - } - return strconv.AppendFloat(b, f64, fmt, -1, 32) -} - -func encodeFloat64(b []byte, v float64) []byte { - abs := math.Abs(v) - fmt := byte('f') - // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right. - if abs != 0 { - if abs < 1e-6 || abs >= 1e21 { - fmt = 'e' - } - } - return strconv.AppendFloat(b, v, fmt, -1, 64) -} - -func encodeBool(b []byte, v bool) []byte { - if v { - return append(b, "true"...) - } - return append(b, "false"...) -} - -func encodeNull(b []byte) []byte { - return append(b, "null"...) -} - -func encodeComma(b []byte) []byte { - return append(b, ',') -} - -func encodeIndentComma(b []byte) []byte { - return append(b, ',', '\n') -} - -func appendStructEnd(b []byte) []byte { - return append(b, '}', ',') -} - -func appendStructEndIndent(ctx *encodeRuntimeContext, b []byte, indent int) []byte { - b = append(b, '\n') - b = append(b, ctx.prefix...) - b = append(b, bytes.Repeat(ctx.indentStr, ctx.baseIndent+indent)...) - return append(b, '}', ',', '\n') -} - -func encodeByteSlice(b []byte, src []byte) []byte { - encodedLen := base64.StdEncoding.EncodedLen(len(src)) - b = append(b, '"') - pos := len(b) - remainLen := cap(b[pos:]) - var buf []byte - if remainLen > encodedLen { - buf = b[pos : pos+encodedLen] - } else { - buf = make([]byte, encodedLen) - } - base64.StdEncoding.Encode(buf, src) - return append(append(b, buf...), '"') -} - -func encodeNumber(b []byte, n Number) ([]byte, error) { - if len(n) == 0 { - return append(b, '0'), nil - } - for i := 0; i < len(n); i++ { - if !floatTable[n[i]] { - return nil, fmt.Errorf("json: invalid number literal %q", n) - } - } - b = append(b, n...) - return b, nil -} - -func appendIndent(ctx *encodeRuntimeContext, b []byte, indent int) []byte { - b = append(b, ctx.prefix...) - return append(b, bytes.Repeat(ctx.indentStr, ctx.baseIndent+indent)...) -} - -func encodeIsNilForMarshaler(v interface{}) bool { - rv := reflect.ValueOf(v) - switch rv.Kind() { - case reflect.Interface, reflect.Map, reflect.Ptr: - return rv.IsNil() - case reflect.Slice: - return rv.IsNil() || rv.Len() == 0 - } - return false -} - -func encodeMarshalJSON(code *opcode, b []byte, v interface{}, escape bool) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if code.addrForMarshaler { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(Marshaler) - if !ok { - return encodeNull(b), nil - } - bb, err := marshaler.MarshalJSON() - if err != nil { - return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, escape); err != nil { - return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - return buf.Bytes(), nil -} - -func encodeMarshalJSONIndent(ctx *encodeRuntimeContext, code *opcode, b []byte, v interface{}, indent int, escape bool) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if code.addrForMarshaler { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(Marshaler) - if !ok { - return encodeNull(b), nil - } - bb, err := marshaler.MarshalJSON() - if err != nil { - return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, escape); err != nil { - return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+indent+1), - string(ctx.indentStr), - ); err != nil { - return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - return append(b, indentBuf.Bytes()...), nil -} - -func encodeMarshalText(code *opcode, b []byte, v interface{}, escape bool) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if code.addrForMarshaler { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(encoding.TextMarshaler) - if !ok { - return encodeNull(b), nil - } - bytes, err := marshaler.MarshalText() - if err != nil { - return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - if escape { - return encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil - } - return encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil -} - -func encodeMarshalTextIndent(code *opcode, b []byte, v interface{}, escape bool) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if code.addrForMarshaler { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(encoding.TextMarshaler) - if !ok { - return encodeNull(b), nil - } - bytes, err := marshaler.MarshalText() - if err != nil { - return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - if escape { - return encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil - } - return encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil + return vm_indent.Run(ctx, b, codeSet, encoder.Option(opt)) } diff --git a/encode_vm_escaped_indent.go b/encode_vm_escaped_indent.go deleted file mode 100644 index 3e31da6..0000000 --- a/encode_vm_escaped_indent.go +++ /dev/null @@ -1,4531 +0,0 @@ -package json - -import ( - "bytes" - "fmt" - "math" - "reflect" - "sort" - "strings" - "unsafe" -) - -func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.ptr() - code := codeSet.code - - for { - switch code.op { - default: - return nil, fmt.Errorf("encoder (escaped+indent): opcode %s has not been implemented", code.op) - case opPtr: - ptr := load(ctxptr, code.idx) - code = code.next - store(ctxptr, code.idx, ptrToPtr(ptr)) - case opInt: - b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) - b = encodeIndentComma(b) - code = code.next - case opUint: - 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, '"') - b = encodeIndentComma(b) - code = code.next - case opFloat32: - b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx))) - b = encodeIndentComma(b) - code = code.next - case opFloat64: - v := ptrToFloat64(load(ctxptr, code.idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opString: - b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx))) - b = encodeIndentComma(b) - code = code.next - case opBool: - b = encodeBool(b, ptrToBool(load(ctxptr, code.idx))) - b = encodeIndentComma(b) - code = code.next - case opBytes: - p := load(ctxptr, code.idx) - slice := ptrToSlice(p) - if p == 0 || slice.data == nil { - b = encodeNull(b) - } else { - b = encodeByteSlice(b, ptrToBytes(p)) - } - b = encodeIndentComma(b) - code = code.next - case opNumber: - bb, err := encodeNumber(b, ptrToNumber(load(ctxptr, code.idx))) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opInterface: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.next - break - } - for _, seen := range ctx.seenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - ctx.seenPtr = append(ctx.seenPtr, ptr) - iface := (*emptyInterface)(ptrToUnsafePtr(ptr)) - if iface == nil || iface.ptr == nil { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.next - break - } - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(iface)) - ifaceCodeSet, err := encodeCompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(codeSet.codeLength) - nextTotalLength := uintptr(ifaceCodeSet.codeLength) - - curlen := uintptr(len(ctx.ptrs)) - offsetNum := ptrOffset / uintptrSize - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...) - } - oldPtrs := ctx.ptrs - - newPtrs := ctx.ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:] - newPtrs[0] = uintptr(iface.ptr) - - ctx.ptrs = newPtrs - - oldBaseIndent := ctx.baseIndent - ctx.baseIndent = code.indent - bb, err := encodeRunEscapedIndent(ctx, b, ifaceCodeSet, opt) - if err != nil { - return nil, err - } - ctx.baseIndent = oldBaseIndent - - ctx.ptrs = oldPtrs - ctxptr = ctx.ptr() - ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1] - - b = bb - code = code.next - case opMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.next - break - } - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - b = append(b, `""`...) - b = encodeIndentComma(b) - code = code.next - break - } - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opSlice: - p := load(ctxptr, code.idx) - slice := ptrToSlice(p) - if p == 0 || slice.data == nil { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(slice.len)) - store(ctxptr, code.idx, uintptr(slice.data)) - if slice.len > 0 { - b = append(b, '[', '\n') - b = appendIndent(ctx, b, code.indent+1) - code = code.next - store(ctxptr, code.idx, uintptr(slice.data)) - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '[', ']', ',', '\n') - code = code.end.next - } - } - case opSliceElem: - idx := load(ctxptr, code.elemIdx) - length := load(ctxptr, code.length) - idx++ - if idx < length { - b = appendIndent(ctx, b, code.indent+1) - 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') - b = appendIndent(ctx, b, code.indent) - b = append(b, ']', ',', '\n') - code = code.end.next - } - case opArray: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - if code.length > 0 { - b = append(b, '[', '\n') - b = appendIndent(ctx, b, code.indent+1) - store(ctxptr, code.elemIdx, 0) - code = code.next - store(ctxptr, code.idx, p) - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '[', ']', ',', '\n') - code = code.end.next - } - } - case opArrayElem: - idx := load(ctxptr, code.elemIdx) - idx++ - if idx < code.length { - b = appendIndent(ctx, b, code.indent+1) - 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') - b = appendIndent(ctx, b, code.indent) - b = append(b, ']', ',', '\n') - code = code.end.next - } - case opMapPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opMap: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - uptr := ptrToUnsafePtr(ptr) - 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)) - - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } else { - b = appendIndent(ctx, b, code.next.indent) - } - - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - b = append(b, '{', '}', ',', '\n') - code = code.end.next - } - } - case opMapKey: - idx := load(ctxptr, code.elemIdx) - length := load(ctxptr, code.length) - idx++ - if (opt & EncodeOptionUnorderedMap) != 0 { - if idx < length { - b = appendIndent(ctx, b, code.indent) - store(ctxptr, code.elemIdx, idx) - ptr := load(ctxptr, code.mapIter) - iter := ptrToUnsafePtr(ptr) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - last := len(b) - 1 - b[last] = '\n' - b = appendIndent(ctx, b, code.indent-1) - b = append(b, '}', ',', '\n') - code = code.end.next - } - } else { - ptr := load(ctxptr, code.end.mapPos) - mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr)) - mapCtx.pos = append(mapCtx.pos, len(b)) - if idx < length { - ptr := load(ctxptr, code.mapIter) - iter := ptrToUnsafePtr(ptr) - store(ctxptr, code.elemIdx, idx) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - code = code.end - } - } - case opMapValue: - if (opt & EncodeOptionUnorderedMap) != 0 { - b = append(b, ':', ' ') - } else { - ptr := load(ctxptr, code.end.mapPos) - mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr)) - mapCtx.pos = append(mapCtx.pos, len(b)) - } - ptr := load(ctxptr, code.mapIter) - iter := ptrToUnsafePtr(ptr) - value := mapitervalue(iter) - store(ctxptr, code.next.idx, uintptr(value)) - mapiternext(iter) - code = code.next - case opMapEnd: - // this operation only used by sorted map - length := int(load(ctxptr, code.length)) - ptr := load(ctxptr, code.mapPos) - mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr)) - pos := mapCtx.pos - for i := 0; i < length; i++ { - startKey := pos[i*2] - startValue := pos[i*2+1] - var endValue int - if i+1 < length { - endValue = pos[i*2+2] - } else { - endValue = len(b) - } - mapCtx.slice.items = append(mapCtx.slice.items, mapItem{ - key: b[startKey:startValue], - value: b[startValue:endValue], - }) - } - sort.Sort(mapCtx.slice) - buf := mapCtx.buf - for _, item := range mapCtx.slice.items { - buf = append(buf, ctx.prefix...) - buf = append(buf, bytes.Repeat(ctx.indentStr, ctx.baseIndent+code.indent+1)...) - buf = append(buf, item.key...) - buf[len(buf)-2] = ':' - buf[len(buf)-1] = ' ' - buf = append(buf, item.value...) - } - buf = buf[:len(buf)-2] - buf = append(buf, '\n') - buf = append(buf, ctx.prefix...) - buf = append(buf, bytes.Repeat(ctx.indentStr, ctx.baseIndent+code.indent)...) - buf = append(buf, '}', ',', '\n') - - b = b[:pos[0]] - b = append(b, buf...) - mapCtx.buf = buf - releaseMapContext(mapCtx) - code = code.next - case opStructFieldPtrHeadRecursive: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - case opStructFieldRecursive: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - if recursiveLevel > startDetectingCyclesAfter { - for _, seen := range ctx.seenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.seenPtr = append(ctx.seenPtr, ptr) - c := code.jmp.code - curlen := uintptr(len(ctx.ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.jmp.curLen * uintptrSize - - newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen - if curlen < newLen { - ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.idx, ptr) - store(ctxptr, c.end.next.idx, oldOffset) - store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next))) - code = c - recursiveLevel++ - case opStructFieldRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.idx) - ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1] - - codePtr := load(ctxptr, code.elemIdx) - code = (*opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.ptr() + offset - ptrOffset = offset - case opStructFieldPtrHead: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHead: - p := load(ctxptr, code.idx) - if p == 0 && (code.indirect || code.next.op == opStructEnd) { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if !code.anonymousKey && len(code.escapedKey) > 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - } - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmpty: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmpty: - p := load(ctxptr, code.idx) - if p == 0 && (code.indirect || code.next.op == opStructEnd) { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadStringTag: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTag: - p := load(ctxptr, code.idx) - if p == 0 && (code.indirect || code.next.op == opStructEnd) { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadInt: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadInt: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyInt: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyInt: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - u64 := ptrToUint64(p + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagInt: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagInt: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadIntPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyIntPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadUint: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadUint: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUint: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyUint: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - u64 := ptrToUint64(p + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagUint: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagUint: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat32: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadFloat32: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat32: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToFloat32(p + code.offset) - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagFloat32: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagFloat32: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat64: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadFloat64: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat64: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagFloat64: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagFloat64: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadString: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadString: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyString: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyString: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToString(p + code.offset) - if v == "" { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagString: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagString: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToString(p + code.offset) - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, v))) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBool: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadBool: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBool: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToBool(p + code.offset) - if v { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - code = code.next - } else { - code = code.nextField - } - case opStructFieldPtrHeadStringTagBool: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagBool: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBytes: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadBytes: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBytes: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyBytes: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToBytes(p + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagBytes: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagBytes: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeByteSlice(b, ptrToBytes(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeByteSlice(b, ptrToBytes(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldHeadNumber: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldPtrHeadOmitEmptyNumber: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyNumber: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToNumber(p + code.offset) - if v == "" { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeNumber(b, v) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - } - case opStructFieldPtrHeadStringTagNumber: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagNumber: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = append(b, code.escapedKey...) - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldPtrHeadStringTagNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray, - opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadArray, opStructFieldHeadStringTagArray, - opStructFieldHeadSlice, opStructFieldHeadStringTagSlice: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmptyArray: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyArray: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmptySlice: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptySlice: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - slice := ptrToSlice(p) - if slice.data == nil { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr, - opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr, - opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - } else { - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMap, opStructFieldHeadStringTagMap: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p != 0 && code.indirect { - p = ptrToPtr(p + code.offset) - } - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmptyMap: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMap: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p != 0 && code.indirect { - p = ptrToPtr(p + code.offset) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - break - } - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - } else { - if code.indirect { - p = ptrToPtr(p) - } - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMapPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p == 0 { - code = code.nextField - break - } - p = ptrToPtr(p + code.offset) - if p == 0 { - code = code.nextField - } else { - if code.indirect { - p = ptrToPtr(p) - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadStringTagMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadStringTagMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON { - p = ptrToPtr(p + code.offset) - } - } - if p == 0 && code.nilcheck { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadMarshalText: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadMarshalText { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadStringTagMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadStringTagMarshalText: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalText: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText { - p = ptrToPtr(p + code.offset) - } - } - if p == 0 && code.nilcheck { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructField: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmpty: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldStringTag: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldInt: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyInt: - ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagInt: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldIntPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyIntPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagIntPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldUint: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyUint: - ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagUint: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldUintPtr: - 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 = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyUintPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagUintPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat32: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat32: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat32(ptr + code.offset) - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat32: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat32Ptr: - 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 = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat32Ptr: - 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 = encodeFloat32(b, ptrToFloat32(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat32Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat64: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat64Ptr: - 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 { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat64Ptr: - 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, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat64Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldString: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyString: - ptr := load(ctxptr, code.headIdx) - v := ptrToString(ptr + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagString: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - s := ptrToString(ptr + code.offset) - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s))) - b = encodeIndentComma(b) - code = code.next - case opStructFieldStringPtr: - 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 = encodeEscapedString(b, ptrToString(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyStringPtr: - 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 = encodeEscapedString(b, ptrToString(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagStringPtr: - 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 = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldBool: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBool: - ptr := load(ctxptr, code.headIdx) - v := ptrToBool(ptr + code.offset) - if v { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBool: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldBoolPtr: - 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 = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBoolPtr: - 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 = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBoolPtr: - 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 = encodeIndentComma(b) - code = code.next - case opStructFieldBytes: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBytes: - ptr := load(ctxptr, code.headIdx) - v := ptrToBytes(ptr + code.offset) - if len(v) > 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBytes: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldBytesPtr: - 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 = encodeByteSlice(b, ptrToBytes(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBytesPtr: - 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 = encodeByteSlice(b, ptrToBytes(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBytesPtr: - 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 = encodeByteSlice(b, ptrToBytes(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldOmitEmptyNumber: - p := load(ctxptr, code.headIdx) - v := ptrToNumber(p + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeNumber(b, v) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldStringTagNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldStringTagNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.headIdx) - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - code = code.nextField - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr: - p := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldMarshalText, opStructFieldStringTagMarshalText: - p := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.headIdx) - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - code = code.nextField - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr: - p := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldArray, opStructFieldStringTagArray: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyArray: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } - case opStructFieldSlice, opStructFieldStringTagSlice: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptySlice: - p := load(ctxptr, code.headIdx) - p += code.offset - slice := ptrToSlice(p) - if slice.data == nil { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } - case opStructFieldMap, opStructFieldStringTagMap: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyMap: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldMapPtr, opStructFieldStringTagMapPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - p = ptrToPtr(p) - } - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - p = ptrToPtr(p) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } - case opStructFieldStruct: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - headCode := code.next - if headCode.next == headCode.end { - // not exists fields - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - code = code.next - store(ctxptr, code.idx, p) - } - } - case opStructFieldOmitEmptyStruct: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - headCode := code.next - if headCode.next == headCode.end { - // not exists fields - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - code = code.next - store(ctxptr, code.idx, p) - } - } - case opStructAnonymousEnd: - code = code.next - case opStructEnd: - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - b = encodeIndentComma(b) - code = code.next - break - } - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) - b = append(b, '}') - b = encodeIndentComma(b) - code = code.next - case opStructEndInt: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyInt: - ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = 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 opStructEndStringTagInt: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndIntPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyIntPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = 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 opStructEndStringTagIntPtr: - 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 = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndUint: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyUint: - ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, u64, code) - 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 opStructEndStringTagUint: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndUintPtr: - 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 = appendUint(b, ptrToUint64(p), code) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyUintPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = 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 opStructEndStringTagUintPtr: - 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 = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat32: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat32: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat32(ptr + code.offset) - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, v) - 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 opStructEndStringTagFloat32: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat32Ptr: - 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 = encodeFloat32(b, ptrToFloat32(p)) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat32Ptr: - 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 = encodeFloat32(b, ptrToFloat32(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 opStructEndStringTagFloat32Ptr: - 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 = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat64: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - 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 opStructEndStringTagFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeFloat64(b, v) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat64Ptr: - 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 { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat64Ptr: - 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, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - 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 opStructEndStringTagFloat64Ptr: - 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, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndString: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeEscapedString(b, ptrToString(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyString: - ptr := load(ctxptr, code.headIdx) - v := ptrToString(ptr + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, v) - 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 opStructEndStringTagString: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - s := ptrToString(ptr + code.offset) - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s))) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndStringPtr: - 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 = encodeEscapedString(b, ptrToString(p)) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyStringPtr: - 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 = encodeEscapedString(b, ptrToString(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 opStructEndStringTagStringPtr: - 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 = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndBool: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyBool: - ptr := load(ctxptr, code.headIdx) - v := ptrToBool(ptr + code.offset) - if v { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, v) - 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 opStructEndStringTagBool: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndBoolPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p)) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyBoolPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) - b = appendStructEndIndent(ctx, b, code.indent-1) - } else { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.indent-1) - b = append(b, '}') - } - b = encodeIndentComma(b) - } - code = code.next - case opStructEndStringTagBoolPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndBytes: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyBytes: - ptr := load(ctxptr, code.headIdx) - v := ptrToBytes(ptr + code.offset) - if len(v) > 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, v) - 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 opStructEndStringTagBytes: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - b = encodeByteSlice(b, ptrToBytes(p+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = appendStructEndIndent(ctx, bb, code.indent-1) - code = code.next - case opStructEndOmitEmptyNumber: - p := load(ctxptr, code.headIdx) - v := ptrToNumber(p + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeNumber(b, v) - if err != nil { - return nil, err - } - b = appendStructEndIndent(ctx, bb, code.indent-1) - } else { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.indent-1) - b = append(b, '}') - } - b = encodeIndentComma(b) - } - code = code.next - case opStructEndStringTagNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEndIndent(ctx, bb, code.indent-1) - } else { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.indent-1) - b = append(b, '}') - } - b = encodeIndentComma(b) - } - code = code.next - case opStructEndStringTagNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opEnd: - goto END - } - } -END: - return b, nil -} diff --git a/encode_vm_indent.go b/encode_vm_indent.go deleted file mode 100644 index 3612dc8..0000000 --- a/encode_vm_indent.go +++ /dev/null @@ -1,4532 +0,0 @@ -package json - -import ( - "bytes" - "fmt" - "math" - "reflect" - "sort" - "strings" - "unsafe" -) - -func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.ptr() - code := codeSet.code - - for { - switch code.op { - default: - return nil, fmt.Errorf("encoder (indent): opcode %s has not been implemented", code.op) - case opPtr: - ptr := load(ctxptr, code.idx) - code = code.next - store(ctxptr, code.idx, ptrToPtr(ptr)) - case opInt: - b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) - b = encodeIndentComma(b) - code = code.next - case opUint: - 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, '"') - b = encodeIndentComma(b) - code = code.next - case opFloat32: - b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx))) - b = encodeIndentComma(b) - code = code.next - case opFloat64: - v := ptrToFloat64(load(ctxptr, code.idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opString: - b = encodeNoEscapedString(b, ptrToString(load(ctxptr, code.idx))) - b = encodeIndentComma(b) - code = code.next - case opBool: - b = encodeBool(b, ptrToBool(load(ctxptr, code.idx))) - b = encodeIndentComma(b) - code = code.next - case opBytes: - ptr := load(ctxptr, code.idx) - slice := ptrToSlice(ptr) - if ptr == 0 || uintptr(slice.data) == 0 { - b = encodeNull(b) - } else { - b = encodeByteSlice(b, ptrToBytes(ptr)) - } - b = encodeIndentComma(b) - code = code.next - case opNumber: - bb, err := encodeNumber(b, ptrToNumber(load(ctxptr, code.idx))) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opInterface: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.next - break - } - for _, seen := range ctx.seenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - ctx.seenPtr = append(ctx.seenPtr, ptr) - iface := (*emptyInterface)(ptrToUnsafePtr(ptr)) - if iface == nil || iface.ptr == nil { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.next - break - } - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(iface)) - ifaceCodeSet, err := encodeCompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(codeSet.codeLength) - nextTotalLength := uintptr(ifaceCodeSet.codeLength) - - curlen := uintptr(len(ctx.ptrs)) - offsetNum := ptrOffset / uintptrSize - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...) - } - oldPtrs := ctx.ptrs - - newPtrs := ctx.ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:] - newPtrs[0] = uintptr(iface.ptr) - - ctx.ptrs = newPtrs - - oldBaseIndent := ctx.baseIndent - ctx.baseIndent = code.indent - bb, err := encodeRunIndent(ctx, b, ifaceCodeSet, opt) - if err != nil { - return nil, err - } - ctx.baseIndent = oldBaseIndent - - ctx.ptrs = oldPtrs - ctxptr = ctx.ptr() - ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1] - - b = bb - code = code.next - case opMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.next - break - } - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - b = append(b, `""`...) - b = encodeIndentComma(b) - code = code.next - break - } - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opSlice: - p := load(ctxptr, code.idx) - slice := ptrToSlice(p) - if p == 0 || slice.data == nil { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(slice.len)) - store(ctxptr, code.idx, uintptr(slice.data)) - if slice.len > 0 { - b = append(b, '[', '\n') - b = appendIndent(ctx, b, code.indent+1) - code = code.next - store(ctxptr, code.idx, uintptr(slice.data)) - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '[', ']', ',', '\n') - code = code.end.next - } - } - case opSliceElem: - idx := load(ctxptr, code.elemIdx) - length := load(ctxptr, code.length) - idx++ - if idx < length { - b = appendIndent(ctx, b, code.indent+1) - 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') - b = appendIndent(ctx, b, code.indent) - b = append(b, ']', ',', '\n') - code = code.end.next - } - case opArray: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - if code.length > 0 { - b = append(b, '[', '\n') - b = appendIndent(ctx, b, code.indent+1) - store(ctxptr, code.elemIdx, 0) - code = code.next - store(ctxptr, code.idx, p) - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '[', ']', ',', '\n') - code = code.end.next - } - } - case opArrayElem: - idx := load(ctxptr, code.elemIdx) - idx++ - if idx < code.length { - b = appendIndent(ctx, b, code.indent+1) - 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') - b = appendIndent(ctx, b, code.indent) - b = append(b, ']', ',', '\n') - code = code.end.next - } - case opMapPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opMap: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - uptr := ptrToUnsafePtr(ptr) - 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)) - - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } else { - b = appendIndent(ctx, b, code.next.indent) - } - - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - b = append(b, '{', '}', ',', '\n') - code = code.end.next - } - } - case opMapKey: - idx := load(ctxptr, code.elemIdx) - length := load(ctxptr, code.length) - idx++ - if (opt & EncodeOptionUnorderedMap) != 0 { - if idx < length { - b = appendIndent(ctx, b, code.indent) - store(ctxptr, code.elemIdx, idx) - ptr := load(ctxptr, code.mapIter) - iter := ptrToUnsafePtr(ptr) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - last := len(b) - 1 - b[last] = '\n' - b = appendIndent(ctx, b, code.indent-1) - b = append(b, '}', ',', '\n') - code = code.end.next - } - } else { - ptr := load(ctxptr, code.end.mapPos) - mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr)) - mapCtx.pos = append(mapCtx.pos, len(b)) - if idx < length { - ptr := load(ctxptr, code.mapIter) - iter := ptrToUnsafePtr(ptr) - store(ctxptr, code.elemIdx, idx) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - code = code.end - } - } - case opMapValue: - if (opt & EncodeOptionUnorderedMap) != 0 { - b = append(b, ':', ' ') - } else { - ptr := load(ctxptr, code.end.mapPos) - mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr)) - mapCtx.pos = append(mapCtx.pos, len(b)) - } - ptr := load(ctxptr, code.mapIter) - iter := ptrToUnsafePtr(ptr) - value := mapitervalue(iter) - store(ctxptr, code.next.idx, uintptr(value)) - mapiternext(iter) - code = code.next - case opMapEnd: - // this operation only used by sorted map - length := int(load(ctxptr, code.length)) - ptr := load(ctxptr, code.mapPos) - mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr)) - pos := mapCtx.pos - for i := 0; i < length; i++ { - startKey := pos[i*2] - startValue := pos[i*2+1] - var endValue int - if i+1 < length { - endValue = pos[i*2+2] - } else { - endValue = len(b) - } - mapCtx.slice.items = append(mapCtx.slice.items, mapItem{ - key: b[startKey:startValue], - value: b[startValue:endValue], - }) - } - sort.Sort(mapCtx.slice) - buf := mapCtx.buf - for _, item := range mapCtx.slice.items { - buf = append(buf, ctx.prefix...) - buf = append(buf, bytes.Repeat(ctx.indentStr, ctx.baseIndent+code.indent+1)...) - buf = append(buf, item.key...) - buf[len(buf)-2] = ':' - buf[len(buf)-1] = ' ' - buf = append(buf, item.value...) - } - buf = buf[:len(buf)-2] - buf = append(buf, '\n') - buf = append(buf, ctx.prefix...) - buf = append(buf, bytes.Repeat(ctx.indentStr, ctx.baseIndent+code.indent)...) - buf = append(buf, '}', ',', '\n') - - b = b[:pos[0]] - b = append(b, buf...) - mapCtx.buf = buf - releaseMapContext(mapCtx) - code = code.next - case opStructFieldPtrHeadRecursive: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - case opStructFieldRecursive: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - if recursiveLevel > startDetectingCyclesAfter { - for _, seen := range ctx.seenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.seenPtr = append(ctx.seenPtr, ptr) - c := code.jmp.code - curlen := uintptr(len(ctx.ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.jmp.curLen * uintptrSize - - newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen - if curlen < newLen { - ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.idx, ptr) - store(ctxptr, c.end.next.idx, oldOffset) - store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next))) - code = c - recursiveLevel++ - case opStructFieldRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.idx) - ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1] - - codePtr := load(ctxptr, code.elemIdx) - code = (*opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.ptr() + offset - ptrOffset = offset - case opStructFieldPtrHead: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHead: - p := load(ctxptr, code.idx) - if p == 0 && (code.indirect || code.next.op == opStructEnd) { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if !code.anonymousKey && len(code.key) > 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - } - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmpty: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmpty: - p := load(ctxptr, code.idx) - if p == 0 && (code.indirect || code.next.op == opStructEnd) { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadStringTag: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTag: - p := load(ctxptr, code.idx) - if p == 0 && (code.indirect || code.next.op == opStructEnd) { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadInt: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadInt: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyInt: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyInt: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - u64 := ptrToUint64(p + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagInt: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagInt: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadIntPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyIntPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - - case opStructFieldPtrHeadUint: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadUint: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUint: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyUint: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - u64 := ptrToUint64(p + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagUint: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagUint: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat32: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadFloat32: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat32: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToFloat32(p + code.offset) - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagFloat32: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagFloat32: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat64: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadFloat64: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat64: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagFloat64: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagFloat64: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadString: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadString: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyString: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyString: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToString(p + code.offset) - if v == "" { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagString: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagString: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToString(p + code.offset) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, v))) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBool: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadBool: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBool: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToBool(p + code.offset) - if v { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - code = code.next - } else { - code = code.nextField - } - case opStructFieldPtrHeadStringTagBool: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagBool: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBytes: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadBytes: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBytes: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyBytes: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToBytes(p + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagBytes: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagBytes: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeByteSlice(b, ptrToBytes(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBytesPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeByteSlice(b, ptrToBytes(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldHeadNumber: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldPtrHeadOmitEmptyNumber: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyNumber: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - v := ptrToNumber(p + code.offset) - if v == "" { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeNumber(b, v) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - } - case opStructFieldPtrHeadStringTagNumber: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadStringTagNumber: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p != 0 { - b = append(b, code.key...) - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldPtrHeadStringTagNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagNumberPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray, - opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadArray, opStructFieldHeadStringTagArray, - opStructFieldHeadSlice, opStructFieldHeadStringTagSlice: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmptyArray: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptyArray: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmptySlice: - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - } - fallthrough - case opStructFieldHeadOmitEmptySlice: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - p += code.offset - slice := ptrToSlice(p) - if slice.data == nil { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr, - opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr, - opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - } else { - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMap, opStructFieldHeadStringTagMap: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p != 0 && code.indirect { - p = ptrToPtr(p + code.offset) - } - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldPtrHeadOmitEmptyMap: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMap: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p != 0 && code.indirect { - p = ptrToPtr(p + code.offset) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - break - } - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - } else { - if code.indirect { - p = ptrToPtr(p) - } - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMapPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p == 0 { - code = code.nextField - break - } - p = ptrToPtr(p + code.offset) - if p == 0 { - code = code.nextField - } else { - if code.indirect { - p = ptrToPtr(p) - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadStringTagMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadStringTagMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON { - p = ptrToPtr(p + code.offset) - } - } - if p == 0 && code.nilcheck { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadMarshalText: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadMarshalText { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadStringTagMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadStringTagMarshalText: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText { - p = ptrToPtr(p + code.offset) - } - } - if code.nilcheck && p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - store(ctxptr, code.idx, ptrToPtr(p)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalText: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if code.typ.Kind() == reflect.Ptr { - if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText { - p = ptrToPtr(p + code.offset) - } - } - if p == 0 && code.nilcheck { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.idx) - if p == 0 && code.indirect { - if !code.anonymousHead { - b = encodeNull(b) - b = encodeIndentComma(b) - } - code = code.end.next - break - } - if code.indirect { - p = ptrToPtr(p + code.offset) - } - if !code.anonymousHead { - b = append(b, '{', '\n') - } - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = bb - b = encodeIndentComma(b) - code = code.next - } - case opStructField: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmpty: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldStringTag: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldInt: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyInt: - ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagInt: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldIntPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyIntPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagIntPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldUint: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyUint: - 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.key...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagUint: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldUintPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyUintPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagUintPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat32: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat32: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat32(ptr + code.offset) - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat32: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat32Ptr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat32Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat32Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat64: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldFloat64Ptr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyFloat64Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagFloat64Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldString: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeNoEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyString: - ptr := load(ctxptr, code.headIdx) - v := ptrToString(ptr + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagString: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - s := ptrToString(ptr + code.offset) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s))) - b = encodeIndentComma(b) - code = code.next - case opStructFieldStringPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyStringPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagStringPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldBool: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBool: - ptr := load(ctxptr, code.headIdx) - v := ptrToBool(ptr + code.offset) - if v { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBool: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldBoolPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - 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 = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBoolPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBoolPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - 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 = encodeIndentComma(b) - code = code.next - case opStructFieldBytes: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBytes: - ptr := load(ctxptr, code.headIdx) - v := ptrToBytes(ptr + code.offset) - if len(v) > 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBytes: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldBytesPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeByteSlice(b, ptrToBytes(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyBytesPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(p)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldStringTagBytesPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeByteSlice(b, ptrToBytes(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldOmitEmptyNumber: - p := load(ctxptr, code.headIdx) - v := ptrToNumber(p + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeNumber(b, v) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldStringTagNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = encodeIndentComma(b) - code = code.next - case opStructFieldNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldStringTagNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.headIdx) - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - code = code.nextField - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr: - p := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldMarshalText, opStructFieldStringTagMarshalText: - p := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.headIdx) - p += code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 && code.nilcheck { - code = code.nextField - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - code = code.next - case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr: - p := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = bb - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) - if err != nil { - return nil, err - } - b = encodeIndentComma(bb) - } - code = code.next - case opStructFieldArray, opStructFieldStringTagArray: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyArray: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } - case opStructFieldSlice, opStructFieldStringTagSlice: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p += code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptySlice: - p := load(ctxptr, code.headIdx) - p += code.offset - slice := ptrToSlice(p) - if slice.data == nil { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } - case opStructFieldMap, opStructFieldStringTagMap: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyMap: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldMapPtr, opStructFieldStringTagMapPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - p = ptrToPtr(p) - } - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - p = ptrToPtr(p) - } - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } - case opStructFieldStruct: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - headCode := code.next - if headCode.next == headCode.end { - // not exists fields - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - code = code.next - store(ctxptr, code.idx, p) - } - } - case opStructFieldOmitEmptyStruct: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - headCode := code.next - if headCode.next == headCode.end { - // not exists fields - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - code = code.next - store(ctxptr, code.idx, p) - } - } - case opStructAnonymousEnd: - code = code.next - case opStructEnd: - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - b = encodeIndentComma(b) - code = code.next - break - } - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) - b = append(b, '}') - b = encodeIndentComma(b) - code = code.next - case opStructEndInt: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyInt: - 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.key...) - b = append(b, ' ') - b = appendInt(b, u64, code) - 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 opStructEndStringTagInt: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndIntPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyIntPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - 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 opStructEndStringTagIntPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndUint: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyUint: - 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.key...) - b = append(b, ' ') - b = appendUint(b, u64, code) - 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 opStructEndStringTagUint: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndUintPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyUintPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - 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 opStructEndStringTagUintPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat32: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat32: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat32(ptr + code.offset) - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, v) - 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 opStructEndStringTagFloat32: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat32Ptr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat32Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(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 opStructEndStringTagFloat32Ptr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat64: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if v != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - 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 opStructEndStringTagFloat64: - ptr := load(ctxptr, code.headIdx) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeFloat64(b, v) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndFloat64Ptr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyFloat64Ptr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - 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 opStructEndStringTagFloat64Ptr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndString: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeNoEscapedString(b, ptrToString(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyString: - ptr := load(ctxptr, code.headIdx) - v := ptrToString(ptr + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, v) - 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 opStructEndStringTagString: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - s := ptrToString(ptr + code.offset) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s))) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndStringPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p)) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyStringPtr: - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(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 opStructEndStringTagStringPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndBool: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyBool: - ptr := load(ctxptr, code.headIdx) - v := ptrToBool(ptr + code.offset) - if v { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, v) - 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 opStructEndStringTagBool: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndBoolPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - 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.key...) - 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.key...) - 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 - case opStructEndBytes: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyBytes: - ptr := load(ctxptr, code.headIdx) - v := ptrToBytes(ptr + code.offset) - if len(v) > 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, v) - 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 opStructEndStringTagBytes: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = appendStructEndIndent(ctx, bb, code.indent-1) - code = code.next - case opStructEndOmitEmptyNumber: - p := load(ctxptr, code.headIdx) - v := ptrToNumber(p + code.offset) - if v != "" { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeNumber(b, v) - if err != nil { - return nil, err - } - b = appendStructEndIndent(ctx, bb, code.indent-1) - } else { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.indent-1) - b = append(b, '}') - } - b = encodeIndentComma(b) - } - code = code.next - case opStructEndStringTagNumber: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - p := load(ctxptr, code.headIdx) - bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p != 0 { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEndIndent(ctx, bb, code.indent-1) - } else { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.indent-1) - b = append(b, '}') - } - b = encodeIndentComma(b) - } - code = code.next - case opStructEndStringTagNumberPtr: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := load(ctxptr, code.headIdx) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - bb, err := encodeNumber(b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEndIndent(ctx, b, code.indent-1) - code = code.next - case opEnd: - goto END - } - } -END: - return b, nil -} diff --git a/internal/encoder/encoder.go b/internal/encoder/encoder.go index 2836ec2..b8baf49 100644 --- a/internal/encoder/encoder.go +++ b/internal/encoder/encoder.go @@ -9,6 +9,7 @@ import ( "math" "reflect" "strconv" + "strings" "sync" "unsafe" @@ -439,6 +440,42 @@ func AppendMarshalJSON(code *Opcode, b []byte, v interface{}, escape bool) ([]by return buf.Bytes(), nil } +func AppendMarshalJSONIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}, indent int, escape bool) ([]byte, error) { + rv := reflect.ValueOf(v) // convert by dynamic interface type + if code.AddrForMarshaler { + if rv.CanAddr() { + rv = rv.Addr() + } else { + newV := reflect.New(rv.Type()) + newV.Elem().Set(rv) + rv = newV + } + } + v = rv.Interface() + marshaler, ok := v.(json.Marshaler) + if !ok { + return AppendNull(b), nil + } + bb, err := marshaler.MarshalJSON() + if err != nil { + return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + var compactBuf bytes.Buffer + if err := compact(&compactBuf, bb, escape); err != nil { + return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + var indentBuf bytes.Buffer + if err := encodeIndent( + &indentBuf, + compactBuf.Bytes(), + string(ctx.Prefix)+strings.Repeat(string(ctx.IndentStr), ctx.BaseIndent+indent+1), + string(ctx.IndentStr), + ); err != nil { + return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + return append(b, indentBuf.Bytes()...), nil +} + func AppendMarshalText(code *Opcode, b []byte, v interface{}, escape bool) ([]byte, error) { rv := reflect.ValueOf(v) // convert by dynamic interface type if code.AddrForMarshaler { @@ -465,6 +502,32 @@ func AppendMarshalText(code *Opcode, b []byte, v interface{}, escape bool) ([]by return AppendString(b, *(*string)(unsafe.Pointer(&bytes))), nil } +func AppendMarshalTextIndent(code *Opcode, b []byte, v interface{}, escape bool) ([]byte, error) { + rv := reflect.ValueOf(v) // convert by dynamic interface type + if code.AddrForMarshaler { + if rv.CanAddr() { + rv = rv.Addr() + } else { + newV := reflect.New(rv.Type()) + newV.Elem().Set(rv) + rv = newV + } + } + v = rv.Interface() + marshaler, ok := v.(encoding.TextMarshaler) + if !ok { + return AppendNull(b), nil + } + bytes, err := marshaler.MarshalText() + if err != nil { + return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + if escape { + return AppendEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil + } + return AppendString(b, *(*string)(unsafe.Pointer(&bytes))), nil +} + func AppendNull(b []byte) []byte { return append(b, "null"...) } @@ -473,10 +536,26 @@ func AppendComma(b []byte) []byte { return append(b, ',') } +func AppendCommaIndent(b []byte) []byte { + return append(b, ',', '\n') +} + func AppendStructEnd(b []byte) []byte { return append(b, '}', ',') } +func AppendStructEndIndent(ctx *RuntimeContext, b []byte, indent int) []byte { + b = append(b, '\n') + b = append(b, ctx.Prefix...) + b = append(b, bytes.Repeat(ctx.IndentStr, ctx.BaseIndent+indent)...) + return append(b, '}', ',', '\n') +} + +func AppendIndent(ctx *RuntimeContext, b []byte, indent int) []byte { + b = append(b, ctx.Prefix...) + return append(b, bytes.Repeat(ctx.IndentStr, ctx.BaseIndent+indent)...) +} + func IsNilForMarshaler(v interface{}) bool { rv := reflect.ValueOf(v) switch rv.Kind() { diff --git a/internal/encoder/indent.go b/internal/encoder/indent.go new file mode 100644 index 0000000..ac76159 --- /dev/null +++ b/internal/encoder/indent.go @@ -0,0 +1,112 @@ +package encoder + +import ( + "bytes" + + "github.com/goccy/go-json/internal/errors" +) + +func encodeIndent(dst *bytes.Buffer, src []byte, prefix, indentStr string) error { + length := int64(len(src)) + indentNum := 0 + indentBytes := []byte(indentStr) + for cursor := int64(0); cursor < length; cursor++ { + c := src[cursor] + switch c { + case ' ', '\t', '\n', '\r': + continue + case '"': + if err := dst.WriteByte(c); err != nil { + return err + } + for { + cursor++ + if err := dst.WriteByte(src[cursor]); err != nil { + return err + } + switch src[cursor] { + case '\\': + cursor++ + if err := dst.WriteByte(src[cursor]); err != nil { + return err + } + case '"': + goto LOOP_END + case '\000': + return errors.ErrUnexpectedEndOfJSON("string", length) + } + } + case '{': + if cursor+1 < length && src[cursor+1] == '}' { + if _, err := dst.Write([]byte{'{', '}'}); err != nil { + return err + } + cursor++ + } else { + indentNum++ + b := []byte{c, '\n'} + b = append(b, prefix...) + b = append(b, bytes.Repeat(indentBytes, indentNum)...) + if _, err := dst.Write(b); err != nil { + return err + } + } + case '}': + indentNum-- + if indentNum < 0 { + return errors.ErrInvalidCharacter('}', "}", cursor) + } + b := []byte{'\n'} + b = append(b, prefix...) + b = append(b, bytes.Repeat(indentBytes, indentNum)...) + b = append(b, c) + if _, err := dst.Write(b); err != nil { + return err + } + case '[': + if cursor+1 < length && src[cursor+1] == ']' { + if _, err := dst.Write([]byte{'[', ']'}); err != nil { + return err + } + cursor++ + } else { + indentNum++ + b := []byte{c, '\n'} + b = append(b, prefix...) + b = append(b, bytes.Repeat(indentBytes, indentNum)...) + if _, err := dst.Write(b); err != nil { + return err + } + } + case ']': + indentNum-- + if indentNum < 0 { + return errors.ErrInvalidCharacter(']', "]", cursor) + } + b := []byte{'\n'} + b = append(b, prefix...) + b = append(b, bytes.Repeat(indentBytes, indentNum)...) + b = append(b, c) + if _, err := dst.Write(b); err != nil { + return err + } + case ':': + if _, err := dst.Write([]byte{':', ' '}); err != nil { + return err + } + case ',': + b := []byte{',', '\n'} + b = append(b, prefix...) + b = append(b, bytes.Repeat(indentBytes, indentNum)...) + if _, err := dst.Write(b); err != nil { + return err + } + default: + if err := dst.WriteByte(c); err != nil { + return err + } + } + LOOP_END: + } + return nil +} diff --git a/internal/encoder/vm/vm.go b/internal/encoder/vm/vm.go index ad4154f..87651de 100644 --- a/internal/encoder/vm/vm.go +++ b/internal/encoder/vm/vm.go @@ -409,7 +409,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt if p == 0 { b = appendNull(b) b = appendComma(b) - code = code.Next + code = code.End.Next break } store(ctxptr, code.Idx, p) @@ -3794,7 +3794,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt p := load(ctxptr, code.HeadIdx) p += code.Offset slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { + if slice.Data == nil { code = code.NextField } else { b = append(b, code.Key...) @@ -3820,12 +3820,12 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: b = append(b, code.Key...) p := load(ctxptr, code.HeadIdx) - p = ptrToNPtr(p+code.Offset, code.PtrNum+1) + p = ptrToPtr(p + code.Offset) code = code.Next store(ctxptr, code.Idx, p) case encoder.OpStructFieldOmitEmptyMap: p := load(ctxptr, code.HeadIdx) - p = ptrToNPtr(p+code.Offset, code.PtrNum+1) + p = ptrToPtr(p + code.Offset) if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { code = code.NextField } else { diff --git a/internal/encoder/vm_escaped/vm.go b/internal/encoder/vm_escaped/vm.go index 4bee00f..7843e6a 100644 --- a/internal/encoder/vm_escaped/vm.go +++ b/internal/encoder/vm_escaped/vm.go @@ -3794,7 +3794,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt p := load(ctxptr, code.HeadIdx) p += code.Offset slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { + if slice.Data == nil { code = code.NextField } else { b = append(b, code.EscapedKey...) @@ -3820,12 +3820,12 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: b = append(b, code.EscapedKey...) p := load(ctxptr, code.HeadIdx) - p = ptrToNPtr(p+code.Offset, code.PtrNum+1) + p = ptrToPtr(p + code.Offset) code = code.Next store(ctxptr, code.Idx, p) case encoder.OpStructFieldOmitEmptyMap: p := load(ctxptr, code.HeadIdx) - p = ptrToNPtr(p+code.Offset, code.PtrNum+1) + p = ptrToPtr(p + code.Offset) if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { code = code.NextField } else { diff --git a/internal/encoder/vm_escaped_indent/vm.go b/internal/encoder/vm_escaped_indent/vm.go new file mode 100644 index 0000000..e64d975 --- /dev/null +++ b/internal/encoder/vm_escaped_indent/vm.go @@ -0,0 +1,4993 @@ +package vm_escaped_indent + +import ( + "bytes" + "fmt" + "math" + "reflect" + "sort" + "strings" + "unsafe" + + "github.com/goccy/go-json/internal/encoder" + "github.com/goccy/go-json/internal/runtime" +) + +const uintptrSize = 4 << (^uintptr(0) >> 63) + +var ( + load = encoder.Load + store = encoder.Store + loadNPtr = encoder.LoadNPtr + ptrToPtr = encoder.PtrToPtr + ptrToNPtr = encoder.PtrToNPtr + ptrToUnsafePtr = encoder.PtrToUnsafePtr + ptrToInterface = encoder.PtrToInterface + ptrToUint64 = encoder.PtrToUint64 + ptrToFloat32 = encoder.PtrToFloat32 + ptrToFloat64 = encoder.PtrToFloat64 + ptrToString = encoder.PtrToString + ptrToBool = encoder.PtrToBool + ptrToBytes = encoder.PtrToBytes + ptrToNumber = encoder.PtrToNumber + ptrToSlice = encoder.PtrToSlice + appendInt = encoder.AppendInt + appendUint = encoder.AppendUint + appendFloat32 = encoder.AppendFloat32 + appendFloat64 = encoder.AppendFloat64 + appendString = encoder.AppendEscapedString + appendBool = encoder.AppendBool + appendByteSlice = encoder.AppendByteSlice + appendNumber = encoder.AppendNumber + appendMarshalJSON = encoder.AppendMarshalJSONIndent + appendMarshalText = encoder.AppendMarshalTextIndent + appendNull = encoder.AppendNull + appendComma = encoder.AppendCommaIndent + appendIndent = encoder.AppendIndent + appendStructEnd = encoder.AppendStructEndIndent + errUnsupportedValue = encoder.ErrUnsupportedValue + errUnsupportedFloat = encoder.ErrUnsupportedFloat + errMarshalerWithCode = encoder.ErrMarshalerWithCode + mapiterinit = encoder.MapIterInit + mapiterkey = encoder.MapIterKey + mapitervalue = encoder.MapIterValue + mapiternext = encoder.MapIterNext + maplen = encoder.MapLen +) + +type emptyInterface struct { + typ *runtime.Type + ptr unsafe.Pointer +} + +func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt encoder.Option) ([]byte, error) { + recursiveLevel := 0 + ptrOffset := uintptr(0) + ctxptr := ctx.Ptr() + code := codeSet.Code + + for { + switch code.Op { + default: + return nil, fmt.Errorf("encoder (indent): opcode %s has not been implemented", code.Op) + case encoder.OpPtr: + p := load(ctxptr, code.Idx) + code = code.Next + store(ctxptr, code.Idx, ptrToPtr(p)) + case encoder.OpIntPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpInt: + b = appendInt(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = appendComma(b) + code = code.Next + case encoder.OpUintPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpUint: + b = appendUint(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = appendComma(b) + code = code.Next + case encoder.OpIntString: + b = append(b, '"') + b = appendInt(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpUintString: + b = append(b, '"') + b = appendUint(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpFloat32Ptr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpFloat32: + b = appendFloat32(b, ptrToFloat32(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpFloat64Ptr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpFloat64: + v := ptrToFloat64(load(ctxptr, code.Idx)) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + case encoder.OpStringPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpString: + b = appendString(b, ptrToString(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpBoolPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpBool: + b = appendBool(b, ptrToBool(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpBytesPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpBytes: + b = appendByteSlice(b, ptrToBytes(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpNumberPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpNumber: + bb, err := appendNumber(b, ptrToNumber(load(ctxptr, code.Idx))) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpInterfacePtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpInterface: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + for _, seen := range ctx.SeenPtr { + if p == seen { + return nil, errUnsupportedValue(code, p) + } + } + ctx.SeenPtr = append(ctx.SeenPtr, p) + iface := (*emptyInterface)(ptrToUnsafePtr(p)) + if iface.ptr == nil { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(iface)) + ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ))) + if err != nil { + return nil, err + } + + totalLength := uintptr(codeSet.CodeLength) + nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + + curlen := uintptr(len(ctx.Ptrs)) + offsetNum := ptrOffset / uintptrSize + + newLen := offsetNum + totalLength + nextTotalLength + if curlen < newLen { + ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) + } + oldPtrs := ctx.Ptrs + + newPtrs := ctx.Ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:] + newPtrs[0] = uintptr(iface.ptr) + + ctx.Ptrs = newPtrs + + oldBaseIndent := ctx.BaseIndent + ctx.BaseIndent = code.Indent + bb, err := Run(ctx, b, ifaceCodeSet, opt) + if err != nil { + return nil, err + } + ctx.BaseIndent = oldBaseIndent + + ctx.Ptrs = oldPtrs + ctxptr = ctx.Ptr() + ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] + + b = bb + code = code.Next + case encoder.OpMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, ptrToPtr(p)) + fallthrough + case encoder.OpMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, ptrToPtr(p)) + fallthrough + case encoder.OpMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + b = append(b, `""`...) + b = appendComma(b) + code = code.Next + break + } + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpSlicePtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpSlice: + p := load(ctxptr, code.Idx) + slice := ptrToSlice(p) + if p == 0 || slice.Data == nil { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + 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') + b = appendIndent(ctx, b, code.Indent+1) + code = code.Next + store(ctxptr, code.Idx, uintptr(slice.Data)) + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, '[', ']', ',', '\n') + code = code.End.Next + } + case encoder.OpSliceElem: + idx := load(ctxptr, code.ElemIdx) + length := load(ctxptr, code.Length) + idx++ + if idx < length { + b = appendIndent(ctx, b, code.Indent+1) + 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') + b = appendIndent(ctx, b, code.Indent) + b = append(b, ']', ',', '\n') + code = code.End.Next + } + case encoder.OpArrayPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpArray: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + if code.Length > 0 { + b = append(b, '[', '\n') + b = appendIndent(ctx, b, code.Indent+1) + store(ctxptr, code.ElemIdx, 0) + code = code.Next + store(ctxptr, code.Idx, p) + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, '[', ']', ',', '\n') + code = code.End.Next + } + case encoder.OpArrayElem: + idx := load(ctxptr, code.ElemIdx) + idx++ + if idx < code.Length { + b = appendIndent(ctx, b, code.Indent+1) + 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') + b = appendIndent(ctx, b, code.Indent) + b = append(b, ']', ',', '\n') + code = code.End.Next + } + case encoder.OpMapPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpMap: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + uptr := ptrToUnsafePtr(p) + mlen := maplen(uptr) + if mlen <= 0 { + b = append(b, '{', '}', ',', '\n') + code = code.End.Next + break + } + b = append(b, '{', '\n') + iter := mapiterinit(code.Type, uptr) + ctx.KeepRefs = append(ctx.KeepRefs, iter) + store(ctxptr, code.ElemIdx, 0) + store(ctxptr, code.Length, uintptr(mlen)) + store(ctxptr, code.MapIter, uintptr(iter)) + if (opt & encoder.UnorderedMapOption) == 0 { + mapCtx := encoder.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))) + } else { + b = appendIndent(ctx, b, code.Next.Indent) + } + key := mapiterkey(iter) + store(ctxptr, code.Next.Idx, uintptr(key)) + code = code.Next + case encoder.OpMapKey: + idx := load(ctxptr, code.ElemIdx) + length := load(ctxptr, code.Length) + idx++ + if (opt & encoder.UnorderedMapOption) != 0 { + if idx < length { + b = appendIndent(ctx, b, code.Indent) + store(ctxptr, code.ElemIdx, idx) + ptr := load(ctxptr, code.MapIter) + iter := ptrToUnsafePtr(ptr) + key := mapiterkey(iter) + store(ctxptr, code.Next.Idx, uintptr(key)) + code = code.Next + } else { + last := len(b) - 1 + b[last] = '\n' + b = appendIndent(ctx, b, code.Indent-1) + b = append(b, '}', ',', '\n') + code = code.End.Next + } + } else { + ptr := load(ctxptr, code.End.MapPos) + mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) + mapCtx.Pos = append(mapCtx.Pos, len(b)) + if idx < length { + ptr := load(ctxptr, code.MapIter) + iter := ptrToUnsafePtr(ptr) + store(ctxptr, code.ElemIdx, idx) + key := mapiterkey(iter) + store(ctxptr, code.Next.Idx, uintptr(key)) + code = code.Next + } else { + code = code.End + } + } + case encoder.OpMapValue: + if (opt & encoder.UnorderedMapOption) != 0 { + b = append(b, ':', ' ') + } else { + ptr := load(ctxptr, code.End.MapPos) + mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) + mapCtx.Pos = append(mapCtx.Pos, len(b)) + } + ptr := load(ctxptr, code.MapIter) + iter := ptrToUnsafePtr(ptr) + value := mapitervalue(iter) + store(ctxptr, code.Next.Idx, uintptr(value)) + mapiternext(iter) + code = code.Next + case encoder.OpMapEnd: + // this operation only used by sorted map + length := int(load(ctxptr, code.Length)) + ptr := load(ctxptr, code.MapPos) + mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) + pos := mapCtx.Pos + for i := 0; i < length; i++ { + startKey := pos[i*2] + startValue := pos[i*2+1] + var endValue int + if i+1 < length { + endValue = pos[i*2+2] + } else { + endValue = len(b) + } + mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{ + Key: b[startKey:startValue], + Value: b[startValue:endValue], + }) + } + sort.Sort(mapCtx.Slice) + buf := mapCtx.Buf + for _, item := range mapCtx.Slice.Items { + buf = append(buf, ctx.Prefix...) + buf = append(buf, bytes.Repeat(ctx.IndentStr, ctx.BaseIndent+code.Indent+1)...) + buf = append(buf, item.Key...) + buf[len(buf)-2] = ':' + buf[len(buf)-1] = ' ' + buf = append(buf, item.Value...) + } + buf = buf[:len(buf)-2] + buf = append(buf, '\n') + buf = append(buf, ctx.Prefix...) + buf = append(buf, bytes.Repeat(ctx.IndentStr, ctx.BaseIndent+code.Indent)...) + buf = append(buf, '}', ',', '\n') + + b = b[:pos[0]] + b = append(b, buf...) + mapCtx.Buf = buf + encoder.ReleaseMapContext(mapCtx) + code = code.Next + case encoder.OpStructFieldRecursivePtr: + p := load(ctxptr, code.Idx) + if p == 0 { + code = code.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructFieldRecursive: + ptr := load(ctxptr, code.Idx) + if ptr != 0 { + if recursiveLevel > encoder.StartDetectingCyclesAfter { + for _, seen := range ctx.SeenPtr { + if ptr == seen { + return nil, errUnsupportedValue(code, ptr) + } + } + } + } + ctx.SeenPtr = append(ctx.SeenPtr, ptr) + c := code.Jmp.Code + curlen := uintptr(len(ctx.Ptrs)) + offsetNum := ptrOffset / uintptrSize + oldOffset := ptrOffset + ptrOffset += code.Jmp.CurLen * uintptrSize + + newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen + if curlen < newLen { + ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) + } + ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr + + store(ctxptr, c.Idx, ptr) + store(ctxptr, c.End.Next.Idx, oldOffset) + store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) + code = c + recursiveLevel++ + case encoder.OpStructFieldRecursiveEnd: + recursiveLevel-- + + // restore ctxptr + offset := load(ctxptr, code.Idx) + ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] + + codePtr := load(ctxptr, code.ElemIdx) + code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) + ctxptr = ctx.Ptr() + offset + ptrOffset = offset + case encoder.OpStructPtrHead: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHead: + p := load(ctxptr, code.Idx) + if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if !code.AnonymousKey && len(code.Key) > 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + } + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmpty: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmpty: + p := load(ctxptr, code.Idx) + if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + if p == 0 || (ptrToPtr(p) == 0 && strings.Contains(code.Next.Op.String(), "Ptr")) { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadStringTag: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTag: + p := load(ctxptr, code.Idx) + if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadInt: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadInt: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyInt: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyInt: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendInt(b, u64, code) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagInt: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagInt: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendInt(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadUint: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadUint: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyUint: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyUint: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendUint(b, u64, code) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagUint: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagUint: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat32: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadFloat32: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat32: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyFloat32: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat32(p + code.Offset) + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat32(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagFloat32: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagFloat32: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendFloat32(b, ptrToFloat32(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat64: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadFloat64: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat64: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyFloat64: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagFloat64: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagFloat64: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadString: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadString: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendString(b, ptrToString(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyString: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyString: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToString(p + code.Offset) + if v == "" { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendString(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagString: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagString: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + v := ptrToString(p + code.Offset) + b = appendString(b, string(appendString([]byte{}, v))) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, ptrToString(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendString(b, ptrToString(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, string(appendString([]byte{}, ptrToString(p)))) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBool: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadBool: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBool: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyBool: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBool(p + code.Offset) + if v { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendBool(b, v) + b = appendComma(b) + code = code.Next + } else { + code = code.NextField + } + case encoder.OpStructPtrHeadStringTagBool: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagBool: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendBool(b, ptrToBool(p+code.Offset)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBytes: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadBytes: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBytes: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyBytes: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBytes(p + code.Offset) + if len(v) == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagBytes: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagBytes: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToPtr(p + code.Offset) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadNumber: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadNumber: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyNumber: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyNumber: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToNumber(p + code.Offset) + if v == "" { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendNumber(b, v) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagNumber: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagNumber: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = append(b, code.EscapedKey...) + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadStringTagArray, + encoder.OpStructPtrHeadSlice, encoder.OpStructPtrHeadStringTagSlice: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadArray, encoder.OpStructHeadStringTagArray, + encoder.OpStructHeadSlice, encoder.OpStructHeadStringTagSlice: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmptyArray: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyArray: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmptySlice: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptySlice: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + slice := ptrToSlice(p) + if slice.Data == nil { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadStringTagArrayPtr, + encoder.OpStructPtrHeadSlicePtr, encoder.OpStructPtrHeadStringTagSlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadStringTagArrayPtr, + encoder.OpStructHeadSlicePtr, encoder.OpStructHeadStringTagSlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.NextField + } else { + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadMap, encoder.OpStructPtrHeadStringTagMap: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMap, encoder.OpStructHeadStringTagMap: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if p != 0 && code.Indirect { + p = ptrToPtr(p + code.Offset) + } + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmptyMap: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMap: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p != 0 && code.Indirect { + p = ptrToPtr(p + code.Offset) + } + if maplen(ptrToUnsafePtr(p)) == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadMapPtr, encoder.OpStructPtrHeadStringTagMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMapPtr, encoder.OpStructHeadStringTagMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.NextField + break + } + p = ptrToPtr(p + code.Offset) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.NextField + } else { + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadOmitEmptyMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.NextField + break + } + p = ptrToPtr(p + code.Offset) + if p == 0 { + code = code.NextField + } else { + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadMarshalJSON { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadStringTagMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalJSON { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON { + p = ptrToPtr(p + code.Offset) + } + } + iface := ptrToInterface(code, p) + if code.Nilcheck && encoder.IsNilForMarshaler(iface) { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent, true) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadMarshalJSONPtr, encoder.OpStructPtrHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMarshalJSONPtr, encoder.OpStructHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadMarshalText { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadStringTagMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalText { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadMarshalTextPtr, encoder.OpStructPtrHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMarshalTextPtr, encoder.OpStructHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructField: + if !code.AnonymousKey { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + } + p := load(ctxptr, code.HeadIdx) + code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmpty: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if ptrToPtr(p) == 0 && strings.Contains(code.Next.Op.String(), "Ptr") { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructFieldStringTag: + p := load(ctxptr, code.HeadIdx) + p += 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 encoder.OpStructFieldInt: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyInt: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendInt(b, u64, code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagInt: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldIntPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendInt(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyIntPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagIntPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldUint: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyUint: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendUint(b, u64, code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagUint: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldUintPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyUintPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagUintPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat32: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat32: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat32(p + code.Offset) + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat32(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat32: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat32Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendFloat32(b, ptrToFloat32(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat32Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat32Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat64: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if v != 0 { + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat64(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendFloat64(b, v) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat64Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat64Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat64Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldString: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendString(b, ptrToString(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyString: + p := load(ctxptr, code.HeadIdx) + v := ptrToString(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendString(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagString: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + s := ptrToString(p + code.Offset) + b = appendString(b, string(appendString([]byte{}, s))) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, ptrToString(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyStringPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendString(b, ptrToString(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, string(appendString([]byte{}, ptrToString(p)))) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBool: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendBool(b, ptrToBool(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBool: + p := load(ctxptr, code.HeadIdx) + v := ptrToBool(p + code.Offset) + if v { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendBool(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBool: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendBool(b, ptrToBool(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBoolPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBytes: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBytes: + p := load(ctxptr, code.HeadIdx) + v := ptrToBytes(p + code.Offset) + if len(v) > 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBytes: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBytesPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructFieldOmitEmptyNumber: + p := load(ctxptr, code.HeadIdx) + v := ptrToNumber(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendNumber(b, v) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldStringTagNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyNumberPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldStringTagNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldMarshalJSON, encoder.OpStructFieldStringTagMarshalJSON: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalJSON: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + code = code.NextField + break + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructFieldMarshalJSONPtr, encoder.OpStructFieldStringTagMarshalJSONPtr: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldMarshalText, encoder.OpStructFieldStringTagMarshalText: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalText: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + code = code.NextField + break + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructFieldMarshalTextPtr, encoder.OpStructFieldStringTagMarshalTextPtr: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldArray, encoder.OpStructFieldStringTagArray: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyArray: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldArrayPtr, encoder.OpStructFieldStringTagArrayPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyArrayPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } else { + code = code.NextField + } + case encoder.OpStructFieldSlice, encoder.OpStructFieldStringTagSlice: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptySlice: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + slice := ptrToSlice(p) + if slice.Data == nil { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructFieldSlicePtr, encoder.OpStructFieldStringTagSlicePtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptySlicePtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } else { + code = code.NextField + } + case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyMap: + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructFieldMapPtr, encoder.OpStructFieldStringTagMapPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + if p != 0 { + p = ptrToNPtr(p, code.PtrNum) + } + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyMapPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + if p != 0 { + p = ptrToNPtr(p, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } else { + code = code.NextField + } + case encoder.OpStructFieldStruct, encoder.OpStructFieldStringTagStruct: + p := load(ctxptr, code.HeadIdx) + p += 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 encoder.OpStructFieldOmitEmptyStruct: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if ptrToPtr(p) == 0 && strings.Contains(code.Next.Op.String(), "Ptr") { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructAnonymousEnd: + code = code.Next + case encoder.OpStructEnd: + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + b = appendComma(b) + code = code.Next + break + } + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.Indent) + b = append(b, '}') + b = appendComma(b) + code = code.Next + case encoder.OpStructEndInt: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyInt: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendInt(b, u64, code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagInt: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndIntPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendInt(b, ptrToUint64(p), code) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyIntPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p), code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagIntPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndUint: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyUint: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendUint(b, u64, code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagUint: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndUintPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyUintPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p), code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagUintPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat32: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat32: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat32(p + code.Offset) + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat32(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat32: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat32Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendFloat32(b, ptrToFloat32(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat32Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat32Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat64: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendFloat64(b, v) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat64Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat64Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat64Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndString: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendString(b, ptrToString(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyString: + p := load(ctxptr, code.HeadIdx) + v := ptrToString(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendString(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagString: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + s := ptrToString(p + code.Offset) + b = appendString(b, string(appendString([]byte{}, s))) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, ptrToString(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyStringPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendString(b, ptrToString(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, string(appendString([]byte{}, ptrToString(p)))) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBool: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendBool(b, ptrToBool(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBool: + p := load(ctxptr, code.HeadIdx) + v := ptrToBool(p + code.Offset) + if v { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendBool(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBool: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ', '"') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendBool(b, ptrToBool(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBoolPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBytes: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBytes: + p := load(ctxptr, code.HeadIdx) + v := ptrToBytes(p + code.Offset) + if len(v) > 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBytes: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBytesPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = appendStructEnd(ctx, bb, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyNumber: + p := load(ctxptr, code.HeadIdx) + v := ptrToNumber(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendNumber(b, v) + if err != nil { + return nil, err + } + b = appendStructEnd(ctx, bb, code.Indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.Indent-1) + b = append(b, '}') + } + b = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyNumberPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendStructEnd(ctx, bb, code.Indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.Indent-1) + b = append(b, '}') + } + b = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.EscapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpEnd: + goto END + } + } +END: + return b, nil +} diff --git a/internal/encoder/vm_indent/vm.go b/internal/encoder/vm_indent/vm.go new file mode 100644 index 0000000..fcae72c --- /dev/null +++ b/internal/encoder/vm_indent/vm.go @@ -0,0 +1,4993 @@ +package vm_indent + +import ( + "bytes" + "fmt" + "math" + "reflect" + "sort" + "strings" + "unsafe" + + "github.com/goccy/go-json/internal/encoder" + "github.com/goccy/go-json/internal/runtime" +) + +const uintptrSize = 4 << (^uintptr(0) >> 63) + +var ( + load = encoder.Load + store = encoder.Store + loadNPtr = encoder.LoadNPtr + ptrToPtr = encoder.PtrToPtr + ptrToNPtr = encoder.PtrToNPtr + ptrToUnsafePtr = encoder.PtrToUnsafePtr + ptrToInterface = encoder.PtrToInterface + ptrToUint64 = encoder.PtrToUint64 + ptrToFloat32 = encoder.PtrToFloat32 + ptrToFloat64 = encoder.PtrToFloat64 + ptrToString = encoder.PtrToString + ptrToBool = encoder.PtrToBool + ptrToBytes = encoder.PtrToBytes + ptrToNumber = encoder.PtrToNumber + ptrToSlice = encoder.PtrToSlice + appendInt = encoder.AppendInt + appendUint = encoder.AppendUint + appendFloat32 = encoder.AppendFloat32 + appendFloat64 = encoder.AppendFloat64 + appendString = encoder.AppendString + appendBool = encoder.AppendBool + appendByteSlice = encoder.AppendByteSlice + appendNumber = encoder.AppendNumber + appendMarshalJSON = encoder.AppendMarshalJSONIndent + appendMarshalText = encoder.AppendMarshalTextIndent + appendNull = encoder.AppendNull + appendComma = encoder.AppendCommaIndent + appendIndent = encoder.AppendIndent + appendStructEnd = encoder.AppendStructEndIndent + errUnsupportedValue = encoder.ErrUnsupportedValue + errUnsupportedFloat = encoder.ErrUnsupportedFloat + errMarshalerWithCode = encoder.ErrMarshalerWithCode + mapiterinit = encoder.MapIterInit + mapiterkey = encoder.MapIterKey + mapitervalue = encoder.MapIterValue + mapiternext = encoder.MapIterNext + maplen = encoder.MapLen +) + +type emptyInterface struct { + typ *runtime.Type + ptr unsafe.Pointer +} + +func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt encoder.Option) ([]byte, error) { + recursiveLevel := 0 + ptrOffset := uintptr(0) + ctxptr := ctx.Ptr() + code := codeSet.Code + + for { + switch code.Op { + default: + return nil, fmt.Errorf("encoder (indent): opcode %s has not been implemented", code.Op) + case encoder.OpPtr: + p := load(ctxptr, code.Idx) + code = code.Next + store(ctxptr, code.Idx, ptrToPtr(p)) + case encoder.OpIntPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpInt: + b = appendInt(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = appendComma(b) + code = code.Next + case encoder.OpUintPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpUint: + b = appendUint(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = appendComma(b) + code = code.Next + case encoder.OpIntString: + b = append(b, '"') + b = appendInt(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpUintString: + b = append(b, '"') + b = appendUint(b, ptrToUint64(load(ctxptr, code.Idx)), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpFloat32Ptr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpFloat32: + b = appendFloat32(b, ptrToFloat32(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpFloat64Ptr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpFloat64: + v := ptrToFloat64(load(ctxptr, code.Idx)) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + case encoder.OpStringPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpString: + b = appendString(b, ptrToString(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpBoolPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpBool: + b = appendBool(b, ptrToBool(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpBytesPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpBytes: + b = appendByteSlice(b, ptrToBytes(load(ctxptr, code.Idx))) + b = appendComma(b) + code = code.Next + case encoder.OpNumberPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpNumber: + bb, err := appendNumber(b, ptrToNumber(load(ctxptr, code.Idx))) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpInterfacePtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpInterface: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + for _, seen := range ctx.SeenPtr { + if p == seen { + return nil, errUnsupportedValue(code, p) + } + } + ctx.SeenPtr = append(ctx.SeenPtr, p) + iface := (*emptyInterface)(ptrToUnsafePtr(p)) + if iface.ptr == nil { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(iface)) + ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ))) + if err != nil { + return nil, err + } + + totalLength := uintptr(codeSet.CodeLength) + nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + + curlen := uintptr(len(ctx.Ptrs)) + offsetNum := ptrOffset / uintptrSize + + newLen := offsetNum + totalLength + nextTotalLength + if curlen < newLen { + ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) + } + oldPtrs := ctx.Ptrs + + newPtrs := ctx.Ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:] + newPtrs[0] = uintptr(iface.ptr) + + ctx.Ptrs = newPtrs + + oldBaseIndent := ctx.BaseIndent + ctx.BaseIndent = code.Indent + bb, err := Run(ctx, b, ifaceCodeSet, opt) + if err != nil { + return nil, err + } + ctx.BaseIndent = oldBaseIndent + + ctx.Ptrs = oldPtrs + ctxptr = ctx.Ptr() + ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] + + b = bb + code = code.Next + case encoder.OpMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, ptrToPtr(p)) + fallthrough + case encoder.OpMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, ptrToPtr(p)) + fallthrough + case encoder.OpMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + b = append(b, `""`...) + b = appendComma(b) + code = code.Next + break + } + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpSlicePtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpSlice: + p := load(ctxptr, code.Idx) + slice := ptrToSlice(p) + if p == 0 || slice.Data == nil { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + 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') + b = appendIndent(ctx, b, code.Indent+1) + code = code.Next + store(ctxptr, code.Idx, uintptr(slice.Data)) + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, '[', ']', ',', '\n') + code = code.End.Next + } + case encoder.OpSliceElem: + idx := load(ctxptr, code.ElemIdx) + length := load(ctxptr, code.Length) + idx++ + if idx < length { + b = appendIndent(ctx, b, code.Indent+1) + 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') + b = appendIndent(ctx, b, code.Indent) + b = append(b, ']', ',', '\n') + code = code.End.Next + } + case encoder.OpArrayPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpArray: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + if code.Length > 0 { + b = append(b, '[', '\n') + b = appendIndent(ctx, b, code.Indent+1) + store(ctxptr, code.ElemIdx, 0) + code = code.Next + store(ctxptr, code.Idx, p) + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, '[', ']', ',', '\n') + code = code.End.Next + } + case encoder.OpArrayElem: + idx := load(ctxptr, code.ElemIdx) + idx++ + if idx < code.Length { + b = appendIndent(ctx, b, code.Indent+1) + 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') + b = appendIndent(ctx, b, code.Indent) + b = append(b, ']', ',', '\n') + code = code.End.Next + } + case encoder.OpMapPtr: + p := loadNPtr(ctxptr, code.Idx, code.PtrNum) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + store(ctxptr, code.Idx, p) + fallthrough + case encoder.OpMap: + p := load(ctxptr, code.Idx) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.End.Next + break + } + uptr := ptrToUnsafePtr(p) + mlen := maplen(uptr) + if mlen <= 0 { + b = append(b, '{', '}', ',', '\n') + code = code.End.Next + break + } + b = append(b, '{', '\n') + iter := mapiterinit(code.Type, uptr) + ctx.KeepRefs = append(ctx.KeepRefs, iter) + store(ctxptr, code.ElemIdx, 0) + store(ctxptr, code.Length, uintptr(mlen)) + store(ctxptr, code.MapIter, uintptr(iter)) + if (opt & encoder.UnorderedMapOption) == 0 { + mapCtx := encoder.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))) + } else { + b = appendIndent(ctx, b, code.Next.Indent) + } + key := mapiterkey(iter) + store(ctxptr, code.Next.Idx, uintptr(key)) + code = code.Next + case encoder.OpMapKey: + idx := load(ctxptr, code.ElemIdx) + length := load(ctxptr, code.Length) + idx++ + if (opt & encoder.UnorderedMapOption) != 0 { + if idx < length { + b = appendIndent(ctx, b, code.Indent) + store(ctxptr, code.ElemIdx, idx) + ptr := load(ctxptr, code.MapIter) + iter := ptrToUnsafePtr(ptr) + key := mapiterkey(iter) + store(ctxptr, code.Next.Idx, uintptr(key)) + code = code.Next + } else { + last := len(b) - 1 + b[last] = '\n' + b = appendIndent(ctx, b, code.Indent-1) + b = append(b, '}', ',', '\n') + code = code.End.Next + } + } else { + ptr := load(ctxptr, code.End.MapPos) + mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) + mapCtx.Pos = append(mapCtx.Pos, len(b)) + if idx < length { + ptr := load(ctxptr, code.MapIter) + iter := ptrToUnsafePtr(ptr) + store(ctxptr, code.ElemIdx, idx) + key := mapiterkey(iter) + store(ctxptr, code.Next.Idx, uintptr(key)) + code = code.Next + } else { + code = code.End + } + } + case encoder.OpMapValue: + if (opt & encoder.UnorderedMapOption) != 0 { + b = append(b, ':', ' ') + } else { + ptr := load(ctxptr, code.End.MapPos) + mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) + mapCtx.Pos = append(mapCtx.Pos, len(b)) + } + ptr := load(ctxptr, code.MapIter) + iter := ptrToUnsafePtr(ptr) + value := mapitervalue(iter) + store(ctxptr, code.Next.Idx, uintptr(value)) + mapiternext(iter) + code = code.Next + case encoder.OpMapEnd: + // this operation only used by sorted map + length := int(load(ctxptr, code.Length)) + ptr := load(ctxptr, code.MapPos) + mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) + pos := mapCtx.Pos + for i := 0; i < length; i++ { + startKey := pos[i*2] + startValue := pos[i*2+1] + var endValue int + if i+1 < length { + endValue = pos[i*2+2] + } else { + endValue = len(b) + } + mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{ + Key: b[startKey:startValue], + Value: b[startValue:endValue], + }) + } + sort.Sort(mapCtx.Slice) + buf := mapCtx.Buf + for _, item := range mapCtx.Slice.Items { + buf = append(buf, ctx.Prefix...) + buf = append(buf, bytes.Repeat(ctx.IndentStr, ctx.BaseIndent+code.Indent+1)...) + buf = append(buf, item.Key...) + buf[len(buf)-2] = ':' + buf[len(buf)-1] = ' ' + buf = append(buf, item.Value...) + } + buf = buf[:len(buf)-2] + buf = append(buf, '\n') + buf = append(buf, ctx.Prefix...) + buf = append(buf, bytes.Repeat(ctx.IndentStr, ctx.BaseIndent+code.Indent)...) + buf = append(buf, '}', ',', '\n') + + b = b[:pos[0]] + b = append(b, buf...) + mapCtx.Buf = buf + encoder.ReleaseMapContext(mapCtx) + code = code.Next + case encoder.OpStructFieldRecursivePtr: + p := load(ctxptr, code.Idx) + if p == 0 { + code = code.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructFieldRecursive: + ptr := load(ctxptr, code.Idx) + if ptr != 0 { + if recursiveLevel > encoder.StartDetectingCyclesAfter { + for _, seen := range ctx.SeenPtr { + if ptr == seen { + return nil, errUnsupportedValue(code, ptr) + } + } + } + } + ctx.SeenPtr = append(ctx.SeenPtr, ptr) + c := code.Jmp.Code + curlen := uintptr(len(ctx.Ptrs)) + offsetNum := ptrOffset / uintptrSize + oldOffset := ptrOffset + ptrOffset += code.Jmp.CurLen * uintptrSize + + newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen + if curlen < newLen { + ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) + } + ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr + + store(ctxptr, c.Idx, ptr) + store(ctxptr, c.End.Next.Idx, oldOffset) + store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) + code = c + recursiveLevel++ + case encoder.OpStructFieldRecursiveEnd: + recursiveLevel-- + + // restore ctxptr + offset := load(ctxptr, code.Idx) + ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] + + codePtr := load(ctxptr, code.ElemIdx) + code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) + ctxptr = ctx.Ptr() + offset + ptrOffset = offset + case encoder.OpStructPtrHead: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHead: + p := load(ctxptr, code.Idx) + if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if !code.AnonymousKey && len(code.Key) > 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + } + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmpty: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmpty: + p := load(ctxptr, code.Idx) + if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + if p == 0 || (ptrToPtr(p) == 0 && strings.Contains(code.Next.Op.String(), "Ptr")) { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadStringTag: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTag: + p := load(ctxptr, code.Idx) + if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadInt: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadInt: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyInt: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyInt: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendInt(b, u64, code) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagInt: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagInt: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendInt(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagIntPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadUint: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadUint: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyUint: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyUint: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendUint(b, u64, code) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagUint: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagUint: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagUintPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat32: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadFloat32: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat32: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyFloat32: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat32(p + code.Offset) + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat32(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagFloat32: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagFloat32: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendFloat32(b, ptrToFloat32(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagFloat32Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat64: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadFloat64: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat64: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyFloat64: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + if v == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagFloat64: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagFloat64: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ', '"') + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagFloat64Ptr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadString: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadString: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendString(b, ptrToString(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyString: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyString: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToString(p + code.Offset) + if v == "" { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendString(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagString: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagString: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + v := ptrToString(p + code.Offset) + b = appendString(b, string(appendString([]byte{}, v))) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, ptrToString(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendString(b, ptrToString(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagStringPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, string(appendString([]byte{}, ptrToString(p)))) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBool: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadBool: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBool: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyBool: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBool(p + code.Offset) + if v { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendBool(b, v) + b = appendComma(b) + code = code.Next + } else { + code = code.NextField + } + case encoder.OpStructPtrHeadStringTagBool: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagBool: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendBool(b, ptrToBool(p+code.Offset)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagBoolPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBytes: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadBytes: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBytes: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyBytes: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBytes(p + code.Offset) + if len(v) == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, v) + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagBytes: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagBytes: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagBytesPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToPtr(p + code.Offset) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadNumber: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadNumber: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyNumber: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyNumber: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + v := ptrToNumber(p + code.Offset) + if v == "" { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendNumber(b, v) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + } + case encoder.OpStructPtrHeadStringTagNumber: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagNumber: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p != 0 { + b = append(b, code.Key...) + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructPtrHeadStringTagNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadStringTagNumberPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadStringTagArray, + encoder.OpStructPtrHeadSlice, encoder.OpStructPtrHeadStringTagSlice: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadArray, encoder.OpStructHeadStringTagArray, + encoder.OpStructHeadSlice, encoder.OpStructHeadStringTagSlice: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmptyArray: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyArray: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmptySlice: + if code.Indirect { + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptySlice: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + p += code.Offset + slice := ptrToSlice(p) + if slice.Data == nil { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadStringTagArrayPtr, + encoder.OpStructPtrHeadSlicePtr, encoder.OpStructPtrHeadStringTagSlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadStringTagArrayPtr, + encoder.OpStructHeadSlicePtr, encoder.OpStructHeadStringTagSlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.NextField + } else { + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadMap, encoder.OpStructPtrHeadStringTagMap: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMap, encoder.OpStructHeadStringTagMap: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if p != 0 && code.Indirect { + p = ptrToPtr(p + code.Offset) + } + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructPtrHeadOmitEmptyMap: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMap: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p != 0 && code.Indirect { + p = ptrToPtr(p + code.Offset) + } + if maplen(ptrToUnsafePtr(p)) == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadMapPtr, encoder.OpStructPtrHeadStringTagMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMapPtr, encoder.OpStructHeadStringTagMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.NextField + break + } + p = ptrToPtr(p + code.Offset) + if p == 0 { + b = appendNull(b) + b = appendComma(b) + code = code.NextField + } else { + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadOmitEmptyMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMapPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.NextField + break + } + p = ptrToPtr(p + code.Offset) + if p == 0 { + code = code.NextField + } else { + if code.Indirect { + p = ptrToNPtr(p, code.PtrNum) + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructPtrHeadMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadMarshalJSON { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadStringTagMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalJSON { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON { + p = ptrToPtr(p + code.Offset) + } + } + iface := ptrToInterface(code, p) + if code.Nilcheck && encoder.IsNilForMarshaler(iface) { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent, false) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadMarshalJSONPtr, encoder.OpStructPtrHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMarshalJSONPtr, encoder.OpStructHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadMarshalText { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadStringTagMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadStringTagMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalText { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + } + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalText: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if code.Type.Kind() == reflect.Ptr { + if code.Indirect || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText { + p = ptrToPtr(p + code.Offset) + } + } + if p == 0 && code.Nilcheck { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructPtrHeadMarshalTextPtr, encoder.OpStructPtrHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadMarshalTextPtr, encoder.OpStructHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) + fallthrough + case encoder.OpStructHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.Idx) + if p == 0 && code.Indirect { + if !code.AnonymousHead { + b = appendNull(b) + b = appendComma(b) + } + code = code.End.Next + break + } + if code.Indirect { + p = ptrToNPtr(p+code.Offset, code.PtrNum) + } + if !code.AnonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent+1) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + b = appendComma(b) + code = code.Next + } + case encoder.OpStructField: + if !code.AnonymousKey { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + } + p := load(ctxptr, code.HeadIdx) + code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmpty: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if ptrToPtr(p) == 0 && strings.Contains(code.Next.Op.String(), "Ptr") { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructFieldStringTag: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldInt: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyInt: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendInt(b, u64, code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagInt: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldIntPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendInt(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyIntPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagIntPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldUint: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyUint: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendUint(b, u64, code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagUint: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldUintPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyUintPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p), code) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagUintPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat32: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat32: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat32(p + code.Offset) + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat32(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat32: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat32Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendFloat32(b, ptrToFloat32(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat32Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat32Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat64: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if v != 0 { + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat64(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendFloat64(b, v) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldFloat64Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyFloat64Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagFloat64Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldString: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendString(b, ptrToString(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyString: + p := load(ctxptr, code.HeadIdx) + v := ptrToString(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendString(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagString: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + s := ptrToString(p + code.Offset) + b = appendString(b, string(appendString([]byte{}, s))) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, ptrToString(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyStringPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendString(b, ptrToString(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, string(appendString([]byte{}, ptrToString(p)))) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBool: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendBool(b, ptrToBool(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBool: + p := load(ctxptr, code.HeadIdx) + v := ptrToBool(p + code.Offset) + if v { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendBool(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBool: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = append(b, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendBool(b, ptrToBool(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBoolPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBytes: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBytes: + p := load(ctxptr, code.HeadIdx) + v := ptrToBytes(p + code.Offset) + if len(v) > 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, v) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBytes: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyBytesPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p)) + b = appendComma(b) + } + code = code.Next + case encoder.OpStructFieldStringTagBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructFieldOmitEmptyNumber: + p := load(ctxptr, code.HeadIdx) + v := ptrToNumber(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendNumber(b, v) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldStringTagNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyNumberPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldStringTagNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldMarshalJSON, encoder.OpStructFieldStringTagMarshalJSON: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalJSON: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + code = code.NextField + break + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructFieldMarshalJSONPtr, encoder.OpStructFieldStringTagMarshalJSONPtr: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldMarshalText, encoder.OpStructFieldStringTagMarshalText: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalText: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if code.Type.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.Nilcheck { + code = code.NextField + break + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = appendComma(bb) + code = code.Next + case encoder.OpStructFieldMarshalTextPtr, encoder.OpStructFieldStringTagMarshalTextPtr: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = appendComma(b) + code = code.Next + case encoder.OpStructFieldOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = appendComma(bb) + } + code = code.Next + case encoder.OpStructFieldArray, encoder.OpStructFieldStringTagArray: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyArray: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldArrayPtr, encoder.OpStructFieldStringTagArrayPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyArrayPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } else { + code = code.NextField + } + case encoder.OpStructFieldSlice, encoder.OpStructFieldStringTagSlice: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p += code.Offset + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptySlice: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + slice := ptrToSlice(p) + if slice.Data == nil { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructFieldSlicePtr, encoder.OpStructFieldStringTagSlicePtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptySlicePtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } else { + code = code.NextField + } + case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyMap: + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructFieldMapPtr, encoder.OpStructFieldStringTagMapPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + if p != 0 { + p = ptrToNPtr(p, code.PtrNum) + } + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyMapPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToPtr(p + code.Offset) + if p != 0 { + p = ptrToNPtr(p, code.PtrNum) + } + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } else { + code = code.NextField + } + case encoder.OpStructFieldStruct, encoder.OpStructFieldStringTagStruct: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + case encoder.OpStructFieldOmitEmptyStruct: + p := load(ctxptr, code.HeadIdx) + p += code.Offset + if ptrToPtr(p) == 0 && strings.Contains(code.Next.Op.String(), "Ptr") { + code = code.NextField + } else { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + code = code.Next + store(ctxptr, code.Idx, p) + } + case encoder.OpStructAnonymousEnd: + code = code.Next + case encoder.OpStructEnd: + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + b = appendComma(b) + code = code.Next + break + } + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.Indent) + b = append(b, '}') + b = appendComma(b) + code = code.Next + case encoder.OpStructEndInt: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyInt: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendInt(b, u64, code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagInt: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendInt(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndIntPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendInt(b, ptrToUint64(p), code) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyIntPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendInt(b, ptrToUint64(p), code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagIntPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndUint: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyUint: + p := load(ctxptr, code.HeadIdx) + u64 := ptrToUint64(p + code.Offset) + v := u64 & code.Mask + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendUint(b, u64, code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagUint: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendUint(b, ptrToUint64(p+code.Offset), code) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndUintPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyUintPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p), code) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagUintPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p), code) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat32: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat32: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat32(p + code.Offset) + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat32(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat32: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendFloat32(b, ptrToFloat32(p+code.Offset)) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat32Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendFloat32(b, ptrToFloat32(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat32Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendFloat32(b, ptrToFloat32(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat32Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat64: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if v != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat64: + p := load(ctxptr, code.HeadIdx) + v := ptrToFloat64(p + code.Offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendFloat64(b, v) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndFloat64Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyFloat64Ptr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagFloat64Ptr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = appendFloat64(b, v) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndString: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendString(b, ptrToString(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyString: + p := load(ctxptr, code.HeadIdx) + v := ptrToString(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendString(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagString: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + s := ptrToString(p + code.Offset) + b = appendString(b, string(appendString([]byte{}, s))) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, ptrToString(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyStringPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendString(b, ptrToString(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagStringPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendString(b, string(appendString([]byte{}, ptrToString(p)))) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBool: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendBool(b, ptrToBool(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBool: + p := load(ctxptr, code.HeadIdx) + v := ptrToBool(p + code.Offset) + if v { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendBool(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBool: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ', '"') + b = appendBool(b, ptrToBool(p+code.Offset)) + b = append(b, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendBool(b, ptrToBool(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBoolPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendBool(b, ptrToBool(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBoolPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBytes: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBytes: + p := load(ctxptr, code.HeadIdx) + v := ptrToBytes(p + code.Offset) + if len(v) > 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, v) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBytes: + p := load(ctxptr, code.HeadIdx) + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p+code.Offset)) + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = appendByteSlice(b, ptrToBytes(p)) + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyBytesPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = appendByteSlice(b, ptrToBytes(p)) + b = appendStructEnd(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 = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagBytesPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + b = appendByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = appendStructEnd(ctx, bb, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyNumber: + p := load(ctxptr, code.HeadIdx) + v := ptrToNumber(p + code.Offset) + if v != "" { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendNumber(b, v) + if err != nil { + return nil, err + } + b = appendStructEnd(ctx, bb, code.Indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.Indent-1) + b = append(b, '}') + } + b = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagNumber: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.HeadIdx) + bb, err := appendNumber(b, ptrToNumber(p+code.Offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpStructEndOmitEmptyNumberPtr: + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p != 0 { + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendStructEnd(ctx, bb, code.Indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.Indent-1) + b = append(b, '}') + } + b = appendComma(b) + } + code = code.Next + case encoder.OpStructEndStringTagNumberPtr: + b = appendIndent(ctx, b, code.Indent) + b = append(b, code.Key...) + b = append(b, ' ') + p := load(ctxptr, code.HeadIdx) + p = ptrToNPtr(p+code.Offset, code.PtrNum) + if p == 0 { + b = appendNull(b) + } else { + b = append(b, '"') + bb, err := appendNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = appendStructEnd(ctx, b, code.Indent-1) + code = code.Next + case encoder.OpEnd: + goto END + } + } +END: + return b, nil +}