2020-04-29 18:31:50 +03:00
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
2020-08-18 07:36:36 +03:00
|
|
|
"bytes"
|
2020-05-08 14:22:57 +03:00
|
|
|
"encoding"
|
2020-08-19 04:34:11 +03:00
|
|
|
"encoding/base64"
|
2020-08-18 18:32:45 +03:00
|
|
|
"fmt"
|
2020-05-08 19:07:33 +03:00
|
|
|
"math"
|
2020-04-29 18:31:50 +03:00
|
|
|
"reflect"
|
2020-09-16 08:51:37 +03:00
|
|
|
"sort"
|
2020-05-08 19:07:33 +03:00
|
|
|
"strconv"
|
2020-04-29 18:31:50 +03:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2020-09-01 16:26:26 +03:00
|
|
|
const startDetectingCyclesAfter = 1000
|
|
|
|
|
2020-08-30 21:14:37 +03:00
|
|
|
func load(base uintptr, idx uintptr) uintptr {
|
2020-11-14 23:27:15 +03:00
|
|
|
addr := base + idx
|
|
|
|
return **(**uintptr)(unsafe.Pointer(&addr))
|
2020-08-30 17:58:58 +03:00
|
|
|
}
|
|
|
|
|
2020-08-30 21:14:37 +03:00
|
|
|
func store(base uintptr, idx uintptr, p uintptr) {
|
2020-11-14 23:27:15 +03:00
|
|
|
addr := base + idx
|
|
|
|
**(**uintptr)(unsafe.Pointer(&addr)) = p
|
2020-08-30 17:58:58 +03:00
|
|
|
}
|
|
|
|
|
2020-09-15 14:48:02 +03:00
|
|
|
func errUnsupportedValue(code *opcode, ptr uintptr) *UnsupportedValueError {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)),
|
2020-09-15 14:48:02 +03:00
|
|
|
}))
|
|
|
|
return &UnsupportedValueError{
|
|
|
|
Value: reflect.ValueOf(v),
|
|
|
|
Str: fmt.Sprintf("encountered a cycle via %s", code.typ),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-17 09:06:05 +03:00
|
|
|
func errUnsupportedFloat(v float64) *UnsupportedValueError {
|
|
|
|
return &UnsupportedValueError{
|
|
|
|
Value: reflect.ValueOf(v),
|
|
|
|
Str: strconv.FormatFloat(v, 'g', -1, 64),
|
|
|
|
}
|
|
|
|
}
|
2020-11-17 09:08:12 +03:00
|
|
|
|
|
|
|
func errMarshaler(code *opcode, err error) *MarshalerError {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-04 07:53:25 +03:00
|
|
|
func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
|
|
|
recursiveLevel := 0
|
|
|
|
seenPtr := map[uintptr]struct{}{}
|
2020-09-03 09:36:11 +03:00
|
|
|
ptrOffset := uintptr(0)
|
2020-08-30 17:58:58 +03:00
|
|
|
ctxptr := ctx.ptr()
|
2020-09-04 07:53:25 +03:00
|
|
|
|
2020-04-29 18:31:50 +03:00
|
|
|
for {
|
|
|
|
switch code.op {
|
2020-11-16 13:10:46 +03:00
|
|
|
default:
|
|
|
|
return fmt.Errorf("failed to handle opcode. doesn't implement %s", code.op)
|
|
|
|
case opPtr, opPtrIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-04-29 18:31:50 +03:00
|
|
|
case opInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeInt(e.ptrToInt(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opIntIndent:
|
|
|
|
e.encodeInt(e.ptrToInt(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeInt8(e.ptrToInt8(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opInt8Indent:
|
|
|
|
e.encodeInt8(e.ptrToInt8(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeInt16(e.ptrToInt16(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opInt16Indent:
|
|
|
|
e.encodeInt16(e.ptrToInt16(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeInt32(e.ptrToInt32(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opInt32Indent:
|
|
|
|
e.encodeInt32(e.ptrToInt32(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeInt64(e.ptrToInt64(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opInt64Indent:
|
|
|
|
e.encodeInt64(e.ptrToInt64(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeUint(e.ptrToUint(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opUintIndent:
|
|
|
|
e.encodeUint(e.ptrToUint(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeUint8(e.ptrToUint8(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opUint8Indent:
|
|
|
|
e.encodeUint8(e.ptrToUint8(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeUint16(e.ptrToUint16(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opUint16Indent:
|
|
|
|
e.encodeUint16(e.ptrToUint16(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeUint32(e.ptrToUint32(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opUint32Indent:
|
|
|
|
e.encodeUint32(e.ptrToUint32(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeUint64(e.ptrToUint64(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opUint64Indent:
|
|
|
|
e.encodeUint64(e.ptrToUint64(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeFloat32(e.ptrToFloat32(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opFloat32Indent:
|
|
|
|
e.encodeFloat32(e.ptrToFloat32(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
v := e.ptrToFloat64(load(ctxptr, code.idx))
|
2020-05-08 19:07:33 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:06:05 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opFloat64Indent:
|
|
|
|
v := e.ptrToFloat64(load(ctxptr, code.idx))
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:06:05 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
|
|
|
e.encodeFloat64(v)
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opString:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeString(e.ptrToString(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opStringIndent:
|
|
|
|
e.encodeString(e.ptrToString(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
|
|
|
case opBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
e.encodeBool(e.ptrToBool(load(ctxptr, code.idx)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opBoolIndent:
|
|
|
|
e.encodeBool(e.ptrToBool(load(ctxptr, code.idx)))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
case opBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(ptr)
|
|
|
|
if ptr == 0 || uintptr(slice.data) == 0 {
|
2020-08-21 05:51:33 +03:00
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(e.ptrToBytes(ptr))
|
2020-08-21 05:51:33 +03:00
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opBytesIndent:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(ptr)
|
|
|
|
if ptr == 0 || uintptr(slice.data) == 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeByteSlice(e.ptrToBytes(ptr))
|
|
|
|
}
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 04:34:11 +03:00
|
|
|
code = code.next
|
2020-04-30 07:39:47 +03:00
|
|
|
case opInterface:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-09-17 15:50:27 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if _, exists := seenPtr[ptr]; exists {
|
2020-11-17 09:09:06 +03:00
|
|
|
return errUnsupportedValue(code, ptr)
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
|
|
|
seenPtr[ptr] = struct{}{}
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-11-18 11:05:27 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(&v))
|
2020-11-16 13:10:46 +03:00
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.IsNil() {
|
|
|
|
e.encodeNull()
|
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
vv := rv.Interface()
|
|
|
|
header := (*interfaceHeader)(unsafe.Pointer(&vv))
|
2020-12-07 04:44:24 +03:00
|
|
|
if header.typ.Kind() == reflect.Ptr {
|
|
|
|
if rv.Elem().IsNil() {
|
|
|
|
e.encodeNull()
|
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
break
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
|
|
|
}
|
2020-12-07 04:44:24 +03:00
|
|
|
c, err := e.compileHead(&encodeCompileContext{
|
|
|
|
typ: header.typ,
|
|
|
|
root: code.root,
|
|
|
|
withIndent: e.enabledIndent,
|
|
|
|
indent: code.indent,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
beforeLastCode := c.beforeLastCode()
|
|
|
|
lastCode := beforeLastCode.next
|
|
|
|
lastCode.idx = beforeLastCode.idx + uintptrSize
|
|
|
|
totalLength := uintptr(code.totalLength())
|
|
|
|
nextTotalLength := uintptr(c.totalLength())
|
|
|
|
curlen := uintptr(len(ctx.ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
|
|
|
oldOffset := ptrOffset
|
|
|
|
ptrOffset += totalLength * uintptrSize
|
|
|
|
|
|
|
|
newLen := offsetNum + totalLength + nextTotalLength
|
|
|
|
if curlen < newLen {
|
|
|
|
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
|
|
|
}
|
|
|
|
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
|
|
|
|
|
|
|
|
store(ctxptr, 0, uintptr(header.ptr))
|
|
|
|
store(ctxptr, lastCode.idx, oldOffset)
|
|
|
|
|
|
|
|
// link lastCode ( opInterfaceEnd ) => code.next
|
|
|
|
lastCode.op = opInterfaceEnd
|
|
|
|
lastCode.next = code.next
|
|
|
|
|
|
|
|
code = c
|
|
|
|
recursiveLevel++
|
|
|
|
case opInterfaceIndent:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
2020-08-20 19:01:24 +03:00
|
|
|
if _, exists := seenPtr[ptr]; exists {
|
2020-11-17 09:09:06 +03:00
|
|
|
return errUnsupportedValue(code, ptr)
|
2020-08-20 17:56:12 +03:00
|
|
|
}
|
2020-08-20 19:01:24 +03:00
|
|
|
seenPtr[ptr] = struct{}{}
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-11-18 11:05:27 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(&v))
|
2020-08-12 10:54:15 +03:00
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.IsNil() {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-12 10:54:15 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
vv := rv.Interface()
|
2020-04-30 07:39:47 +03:00
|
|
|
header := (*interfaceHeader)(unsafe.Pointer(&vv))
|
|
|
|
typ := header.typ
|
|
|
|
if typ.Kind() == reflect.Ptr {
|
|
|
|
typ = typ.Elem()
|
|
|
|
}
|
2020-08-12 19:21:10 +03:00
|
|
|
var c *opcode
|
|
|
|
if typ.Kind() == reflect.Map {
|
2020-08-29 09:11:31 +03:00
|
|
|
code, err := e.compileMap(&encodeCompileContext{
|
|
|
|
typ: typ,
|
2020-08-31 15:59:22 +03:00
|
|
|
root: code.root,
|
2020-08-29 09:11:31 +03:00
|
|
|
withIndent: e.enabledIndent,
|
2020-08-31 15:59:22 +03:00
|
|
|
indent: code.indent,
|
2020-08-29 09:11:31 +03:00
|
|
|
}, false)
|
2020-08-12 19:21:10 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
c = code
|
|
|
|
} else {
|
2020-08-29 09:11:31 +03:00
|
|
|
code, err := e.compile(&encodeCompileContext{
|
|
|
|
typ: typ,
|
2020-08-31 15:59:22 +03:00
|
|
|
root: code.root,
|
2020-08-29 09:11:31 +03:00
|
|
|
withIndent: e.enabledIndent,
|
2020-08-31 15:59:22 +03:00
|
|
|
indent: code.indent,
|
2020-08-29 09:11:31 +03:00
|
|
|
})
|
2020-08-12 19:21:10 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
c = code
|
2020-04-30 07:39:47 +03:00
|
|
|
}
|
2020-09-03 09:36:11 +03:00
|
|
|
|
|
|
|
beforeLastCode := c.beforeLastCode()
|
|
|
|
lastCode := beforeLastCode.next
|
|
|
|
lastCode.idx = beforeLastCode.idx + uintptrSize
|
|
|
|
totalLength := uintptr(code.totalLength())
|
|
|
|
nextTotalLength := uintptr(c.totalLength())
|
|
|
|
curlen := uintptr(len(ctx.ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
|
|
|
oldOffset := ptrOffset
|
2020-09-03 16:05:46 +03:00
|
|
|
ptrOffset += totalLength * uintptrSize
|
|
|
|
|
2020-09-03 09:36:11 +03:00
|
|
|
newLen := offsetNum + totalLength + nextTotalLength
|
|
|
|
if curlen < newLen {
|
|
|
|
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
2020-08-30 17:58:58 +03:00
|
|
|
}
|
2020-09-03 09:36:11 +03:00
|
|
|
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
|
2020-09-03 16:05:46 +03:00
|
|
|
|
|
|
|
store(ctxptr, 0, uintptr(header.ptr))
|
2020-09-03 09:36:11 +03:00
|
|
|
store(ctxptr, lastCode.idx, oldOffset)
|
|
|
|
|
|
|
|
// link lastCode ( opInterfaceEnd ) => code.next
|
|
|
|
lastCode.op = opInterfaceEnd
|
|
|
|
lastCode.next = code.next
|
|
|
|
|
|
|
|
code = c
|
|
|
|
recursiveLevel++
|
2020-11-16 13:10:46 +03:00
|
|
|
case opInterfaceEnd, opInterfaceEndIndent:
|
2020-09-03 09:36:11 +03:00
|
|
|
recursiveLevel--
|
|
|
|
// restore ctxptr
|
|
|
|
offset := load(ctxptr, code.idx)
|
|
|
|
ctxptr = ctx.ptr() + offset
|
|
|
|
ptrOffset = offset
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-04 12:39:17 +03:00
|
|
|
case opMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-08-18 07:36:36 +03:00
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
2020-05-04 12:39:17 +03:00
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-05-04 12:39:17 +03:00
|
|
|
}
|
2020-08-18 18:32:45 +03:00
|
|
|
if len(b) == 0 {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2020-08-18 07:36:36 +03:00
|
|
|
var buf bytes.Buffer
|
2020-11-17 09:09:06 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
|
|
|
return err
|
2020-08-18 07:36:36 +03:00
|
|
|
}
|
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
|
|
|
code = code.next
|
|
|
|
case opMarshalJSONIndent:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-11-16 13:10:46 +03:00
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
|
|
|
if len(b) == 0 {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
2020-11-17 09:09:06 +03:00
|
|
|
if err := encodeWithIndent(
|
|
|
|
&buf,
|
|
|
|
b,
|
|
|
|
string(e.prefix)+string(bytes.Repeat(e.indentStr, code.indent)),
|
|
|
|
string(e.indentStr),
|
|
|
|
); err != nil {
|
|
|
|
return err
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
|
|
|
e.encodeBytes(buf.Bytes())
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-04 12:39:17 +03:00
|
|
|
code = code.next
|
|
|
|
case opMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-20 11:47:38 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-21 05:07:55 +03:00
|
|
|
if p == nil {
|
2020-12-07 04:49:00 +03:00
|
|
|
e.encodeBytes([]byte{'"', '"', ','})
|
2020-11-16 13:10:46 +03:00
|
|
|
} else if isPtr && *(*unsafe.Pointer)(p) == nil {
|
2020-11-17 09:09:06 +03:00
|
|
|
e.encodeBytes([]byte{'"', '"', ','})
|
2020-11-16 13:10:46 +03:00
|
|
|
} else {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
|
|
|
ptr: p,
|
|
|
|
}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
e.encodeByte(',')
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opMarshalTextIndent:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-11-16 13:10:46 +03:00
|
|
|
if p == nil {
|
|
|
|
e.encodeNull()
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-21 05:07:55 +03:00
|
|
|
} else if isPtr && *(*unsafe.Pointer)(p) == nil {
|
2020-11-17 09:09:06 +03:00
|
|
|
e.encodeBytes([]byte{'"', '"', ',', '\n'})
|
2020-08-20 11:47:38 +03:00
|
|
|
} else {
|
|
|
|
if isPtr && code.typ.Elem().Implements(marshalTextType) {
|
|
|
|
p = *(*unsafe.Pointer)(p)
|
|
|
|
}
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
|
|
|
ptr: p,
|
|
|
|
}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-05-08 19:38:00 +03:00
|
|
|
}
|
2020-08-20 11:47:38 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-04 12:39:17 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opSliceHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.length, uintptr(slice.len))
|
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
|
|
|
if slice.len > 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte('[')
|
2020-04-29 19:44:48 +03:00
|
|
|
code = code.next
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', ']', ','})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
}
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
|
|
|
case opSliceElem:
|
2020-08-31 15:59:22 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
length := load(ctxptr, code.length)
|
|
|
|
idx++
|
|
|
|
if idx < length {
|
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
data := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
size := code.size
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, data+idx*size)
|
2020-04-29 18:31:50 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
last := len(e.buf) - 1
|
|
|
|
e.buf[last] = ']'
|
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
case opSliceHeadIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if p == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(p)
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.length, uintptr(slice.len))
|
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
|
|
|
if slice.len > 0 {
|
2020-08-12 10:54:15 +03:00
|
|
|
e.encodeBytes([]byte{'[', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
|
|
|
code = code.next
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', ']', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-12 10:54:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opRootSliceHeadIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2020-08-12 10:54:15 +03:00
|
|
|
if p == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-12 10:54:15 +03:00
|
|
|
} else {
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(p)
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.length, uintptr(slice.len))
|
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
|
|
|
if slice.len > 0 {
|
2020-08-12 10:54:15 +03:00
|
|
|
e.encodeBytes([]byte{'[', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
|
|
|
code = code.next
|
2020-11-17 09:09:06 +03:00
|
|
|
store(ctxptr, code.idx, uintptr(slice.data))
|
2020-08-12 10:54:15 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', ']', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opSliceElemIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
length := load(ctxptr, code.length)
|
|
|
|
idx++
|
|
|
|
if idx < length {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
data := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
size := code.size
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, data+idx*size)
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.buf = e.buf[:len(e.buf)-2]
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte('\n')
|
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{']', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-12 10:54:15 +03:00
|
|
|
case opRootSliceElemIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
length := load(ctxptr, code.length)
|
|
|
|
idx++
|
|
|
|
if idx < length {
|
2020-08-12 10:54:15 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
2020-08-12 10:54:15 +03:00
|
|
|
code = code.next
|
2020-08-31 15:59:22 +03:00
|
|
|
data := load(ctxptr, code.headIdx)
|
|
|
|
store(ctxptr, code.idx, data+idx*code.size)
|
2020-08-12 10:54:15 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('\n')
|
|
|
|
e.encodeIndent(code.indent)
|
2020-08-27 15:01:53 +03:00
|
|
|
e.encodeByte(']')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-12 10:54:15 +03:00
|
|
|
}
|
2020-04-30 07:39:47 +03:00
|
|
|
case opArrayHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2020-04-30 07:39:47 +03:00
|
|
|
if p == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
if code.length > 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte('[')
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
2020-04-30 07:39:47 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-04-30 07:39:47 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', ']', ','})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opArrayElem:
|
2020-08-31 15:59:22 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
idx++
|
|
|
|
if idx < code.length {
|
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
p := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
size := code.size
|
2020-04-30 07:39:47 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p+idx*size)
|
2020-04-30 07:39:47 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
last := len(e.buf) - 1
|
|
|
|
e.buf[last] = ']'
|
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
case opArrayHeadIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if p == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
if code.length > 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', ']', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opArrayElemIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
idx++
|
|
|
|
if idx < code.length {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
p := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
size := code.size
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p+idx*size)
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.buf = e.buf[:len(e.buf)-2]
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte('\n')
|
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{']', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapHead:
|
2020-09-16 08:51:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2020-11-17 09:09:06 +03:00
|
|
|
uptr := e.ptrToUnsafePtr(ptr)
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(uptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
if mlen > 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte('{')
|
2020-11-14 23:27:15 +03:00
|
|
|
iter := mapiterinit(code.typ, uptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, iter)
|
|
|
|
store(ctxptr, code.elemIdx, 0)
|
|
|
|
store(ctxptr, code.length, uintptr(mlen))
|
|
|
|
store(ctxptr, code.mapIter, uintptr(iter))
|
2020-09-16 12:15:47 +03:00
|
|
|
if !e.unorderedMap {
|
|
|
|
pos := make([]int, 0, mlen)
|
|
|
|
pos = append(pos, len(e.buf))
|
|
|
|
posPtr := unsafe.Pointer(&pos)
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, posPtr)
|
|
|
|
store(ctxptr, code.end.mapPos, uintptr(posPtr))
|
|
|
|
}
|
2020-09-16 08:51:37 +03:00
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapHeadLoad:
|
2020-09-16 08:51:37 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
// load pointer
|
2020-11-17 09:09:06 +03:00
|
|
|
ptr = e.ptrToPtr(ptr)
|
|
|
|
uptr := e.ptrToUnsafePtr(ptr)
|
2020-09-17 15:50:27 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(uptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
if mlen > 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte('{')
|
2020-11-14 23:27:15 +03:00
|
|
|
iter := mapiterinit(code.typ, uptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, iter)
|
|
|
|
store(ctxptr, code.elemIdx, 0)
|
|
|
|
store(ctxptr, code.length, uintptr(mlen))
|
|
|
|
store(ctxptr, code.mapIter, uintptr(iter))
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
2020-09-16 12:15:47 +03:00
|
|
|
if !e.unorderedMap {
|
|
|
|
pos := make([]int, 0, mlen)
|
|
|
|
pos = append(pos, len(e.buf))
|
|
|
|
posPtr := unsafe.Pointer(&pos)
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, posPtr)
|
|
|
|
store(ctxptr, code.end.mapPos, uintptr(posPtr))
|
|
|
|
}
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapKey:
|
2020-09-16 08:51:37 +03:00
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
length := load(ctxptr, code.length)
|
|
|
|
idx++
|
2020-09-16 12:15:47 +03:00
|
|
|
if e.unorderedMap {
|
|
|
|
if idx < length {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2020-11-17 09:09:06 +03:00
|
|
|
iter := e.ptrToUnsafePtr(ptr)
|
2020-09-16 12:15:47 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
last := len(e.buf) - 1
|
|
|
|
e.buf[last] = '}'
|
|
|
|
e.encodeByte(',')
|
2020-09-16 12:15:47 +03:00
|
|
|
code = code.end.next
|
|
|
|
}
|
2020-09-16 08:51:37 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.end.mapPos)
|
|
|
|
posPtr := (*[]int)(*(*unsafe.Pointer)(unsafe.Pointer(&ptr)))
|
2020-09-16 12:15:47 +03:00
|
|
|
*posPtr = append(*posPtr, len(e.buf))
|
|
|
|
if idx < length {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2020-11-17 09:09:06 +03:00
|
|
|
iter := e.ptrToUnsafePtr(ptr)
|
2020-09-16 12:15:47 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
|
|
|
code = code.end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opMapValue:
|
|
|
|
if e.unorderedMap {
|
2020-11-16 13:10:46 +03:00
|
|
|
last := len(e.buf) - 1
|
|
|
|
e.buf[last] = ':'
|
2020-09-16 12:15:47 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.end.mapPos)
|
|
|
|
posPtr := (*[]int)(*(*unsafe.Pointer)(unsafe.Pointer(&ptr)))
|
2020-09-16 12:15:47 +03:00
|
|
|
*posPtr = append(*posPtr, len(e.buf))
|
2020-09-16 08:51:37 +03:00
|
|
|
}
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2020-11-17 09:09:06 +03:00
|
|
|
iter := e.ptrToUnsafePtr(ptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
value := mapitervalue(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(value))
|
|
|
|
mapiternext(iter)
|
|
|
|
code = code.next
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapEnd:
|
|
|
|
// this operation only used by sorted map.
|
2020-09-16 08:51:37 +03:00
|
|
|
length := int(load(ctxptr, code.length))
|
|
|
|
type mapKV struct {
|
|
|
|
key string
|
|
|
|
value string
|
|
|
|
}
|
|
|
|
kvs := make([]mapKV, 0, length)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapPos)
|
2020-11-17 09:09:06 +03:00
|
|
|
posPtr := e.ptrToUnsafePtr(ptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
pos := *(*[]int)(posPtr)
|
|
|
|
for i := 0; i < length; i++ {
|
|
|
|
startKey := pos[i*2]
|
|
|
|
startValue := pos[i*2+1]
|
|
|
|
var endValue int
|
|
|
|
if i+1 < length {
|
|
|
|
endValue = pos[i*2+2]
|
|
|
|
} else {
|
|
|
|
endValue = len(e.buf)
|
|
|
|
}
|
|
|
|
kvs = append(kvs, mapKV{
|
|
|
|
key: string(e.buf[startKey:startValue]),
|
|
|
|
value: string(e.buf[startValue:endValue]),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
sort.Slice(kvs, func(i, j int) bool {
|
|
|
|
return kvs[i].key < kvs[j].key
|
|
|
|
})
|
|
|
|
buf := e.buf[pos[0]:]
|
|
|
|
buf = buf[:0]
|
2020-11-16 13:10:46 +03:00
|
|
|
for _, kv := range kvs {
|
2020-09-16 08:51:37 +03:00
|
|
|
buf = append(buf, []byte(kv.key)...)
|
2020-11-16 13:10:46 +03:00
|
|
|
buf[len(buf)-1] = ':'
|
2020-09-16 08:51:37 +03:00
|
|
|
buf = append(buf, []byte(kv.value)...)
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
buf[len(buf)-1] = '}'
|
|
|
|
buf = append(buf, ',')
|
2020-09-16 08:51:37 +03:00
|
|
|
e.buf = e.buf[:pos[0]]
|
|
|
|
e.buf = append(e.buf, buf...)
|
|
|
|
code = code.next
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapHeadIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 07:39:47 +03:00
|
|
|
if ptr == 0 {
|
2020-09-16 12:15:47 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
} else {
|
2020-11-17 09:09:06 +03:00
|
|
|
uptr := e.ptrToUnsafePtr(ptr)
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(uptr)
|
2020-04-30 07:39:47 +03:00
|
|
|
if mlen > 0 {
|
2020-09-16 12:15:47 +03:00
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-11-14 23:27:15 +03:00
|
|
|
iter := mapiterinit(code.typ, uptr)
|
2020-09-04 14:28:27 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, iter)
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
|
|
|
store(ctxptr, code.length, uintptr(mlen))
|
|
|
|
store(ctxptr, code.mapIter, uintptr(iter))
|
2020-09-16 12:15:47 +03:00
|
|
|
|
|
|
|
if !e.unorderedMap {
|
|
|
|
pos := make([]int, 0, mlen)
|
|
|
|
pos = append(pos, len(e.buf))
|
|
|
|
posPtr := unsafe.Pointer(&pos)
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, posPtr)
|
|
|
|
store(ctxptr, code.end.mapPos, uintptr(posPtr))
|
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.next.indent)
|
|
|
|
}
|
|
|
|
|
2020-04-30 07:39:47 +03:00
|
|
|
key := mapiterkey(iter)
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
2020-04-30 07:39:47 +03:00
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-09-16 12:15:47 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
}
|
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapHeadLoadIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-08 12:53:01 +03:00
|
|
|
if ptr == 0 {
|
2020-09-16 12:15:47 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-08-08 12:53:01 +03:00
|
|
|
e.encodeNull()
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-08 12:53:01 +03:00
|
|
|
} else {
|
|
|
|
// load pointer
|
2020-11-17 09:09:06 +03:00
|
|
|
ptr = e.ptrToPtr(ptr)
|
|
|
|
uptr := e.ptrToUnsafePtr(ptr)
|
2020-11-14 23:27:15 +03:00
|
|
|
if uintptr(uptr) == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(uptr)
|
2020-08-08 12:53:01 +03:00
|
|
|
if mlen > 0 {
|
2020-09-16 12:15:47 +03:00
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-11-14 23:27:15 +03:00
|
|
|
iter := mapiterinit(code.typ, uptr)
|
2020-09-04 14:28:27 +03:00
|
|
|
ctx.keepRefs = append(ctx.keepRefs, iter)
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.elemIdx, 0)
|
|
|
|
store(ctxptr, code.length, uintptr(mlen))
|
|
|
|
store(ctxptr, code.mapIter, uintptr(iter))
|
2020-08-08 12:53:01 +03:00
|
|
|
key := mapiterkey(iter)
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
2020-09-16 12:15:47 +03:00
|
|
|
|
|
|
|
if !e.unorderedMap {
|
|
|
|
pos := make([]int, 0, mlen)
|
|
|
|
pos = append(pos, len(e.buf))
|
|
|
|
posPtr := unsafe.Pointer(&pos)
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, posPtr)
|
|
|
|
store(ctxptr, code.end.mapPos, uintptr(posPtr))
|
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.next.indent)
|
|
|
|
}
|
|
|
|
|
2020-08-08 12:53:01 +03:00
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-09-16 12:15:47 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapKeyIndent:
|
|
|
|
idx := load(ctxptr, code.elemIdx)
|
|
|
|
length := load(ctxptr, code.length)
|
|
|
|
idx++
|
|
|
|
if e.unorderedMap {
|
|
|
|
if idx < length {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
store(ctxptr, code.elemIdx, idx)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2020-11-17 09:09:06 +03:00
|
|
|
iter := e.ptrToUnsafePtr(ptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
last := len(e.buf) - 1
|
|
|
|
e.buf[last] = '\n'
|
2020-09-16 12:15:47 +03:00
|
|
|
e.encodeIndent(code.indent - 1)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'}', ',', '\n'})
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.end.next
|
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.end.mapPos)
|
|
|
|
posPtr := (*[]int)(*(*unsafe.Pointer)(unsafe.Pointer(&ptr)))
|
2020-09-16 12:15:47 +03:00
|
|
|
*posPtr = append(*posPtr, len(e.buf))
|
|
|
|
if idx < length {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2020-11-17 09:09:06 +03:00
|
|
|
iter := e.ptrToUnsafePtr(ptr)
|
2020-09-16 12:15:47 +03:00
|
|
|
store(ctxptr, code.elemIdx, idx)
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(key))
|
|
|
|
code = code.next
|
|
|
|
} else {
|
|
|
|
code = code.end
|
|
|
|
}
|
2020-09-16 08:51:37 +03:00
|
|
|
}
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapValueIndent:
|
|
|
|
if e.unorderedMap {
|
|
|
|
e.encodeBytes([]byte{':', ' '})
|
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.end.mapPos)
|
|
|
|
posPtr := (*[]int)(*(*unsafe.Pointer)(unsafe.Pointer(&ptr)))
|
2020-09-16 12:15:47 +03:00
|
|
|
*posPtr = append(*posPtr, len(e.buf))
|
2020-09-16 08:51:37 +03:00
|
|
|
}
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapIter)
|
2020-11-17 09:09:06 +03:00
|
|
|
iter := e.ptrToUnsafePtr(ptr)
|
2020-09-16 08:51:37 +03:00
|
|
|
value := mapitervalue(iter)
|
|
|
|
store(ctxptr, code.next.idx, uintptr(value))
|
|
|
|
mapiternext(iter)
|
|
|
|
code = code.next
|
2020-09-16 12:15:47 +03:00
|
|
|
case opMapEndIndent:
|
|
|
|
// this operation only used by sorted map
|
2020-09-16 08:51:37 +03:00
|
|
|
length := int(load(ctxptr, code.length))
|
|
|
|
type mapKV struct {
|
|
|
|
key string
|
|
|
|
value string
|
|
|
|
}
|
|
|
|
kvs := make([]mapKV, 0, length)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.mapPos)
|
|
|
|
pos := *(*[]int)(*(*unsafe.Pointer)(unsafe.Pointer(&ptr)))
|
2020-09-16 08:51:37 +03:00
|
|
|
for i := 0; i < length; i++ {
|
|
|
|
startKey := pos[i*2]
|
|
|
|
startValue := pos[i*2+1]
|
|
|
|
var endValue int
|
|
|
|
if i+1 < length {
|
|
|
|
endValue = pos[i*2+2]
|
|
|
|
} else {
|
|
|
|
endValue = len(e.buf)
|
|
|
|
}
|
|
|
|
kvs = append(kvs, mapKV{
|
|
|
|
key: string(e.buf[startKey:startValue]),
|
|
|
|
value: string(e.buf[startValue:endValue]),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
sort.Slice(kvs, func(i, j int) bool {
|
|
|
|
return kvs[i].key < kvs[j].key
|
|
|
|
})
|
|
|
|
buf := e.buf[pos[0]:]
|
|
|
|
buf = buf[:0]
|
2020-11-16 13:10:46 +03:00
|
|
|
for _, kv := range kvs {
|
2020-09-16 08:51:37 +03:00
|
|
|
buf = append(buf, e.prefix...)
|
|
|
|
buf = append(buf, bytes.Repeat(e.indentStr, code.indent+1)...)
|
|
|
|
|
|
|
|
buf = append(buf, []byte(kv.key)...)
|
2020-11-16 13:10:46 +03:00
|
|
|
buf[len(buf)-2] = ':'
|
|
|
|
buf[len(buf)-1] = ' '
|
2020-09-16 08:51:37 +03:00
|
|
|
buf = append(buf, []byte(kv.value)...)
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
buf = buf[:len(buf)-2]
|
2020-09-16 08:51:37 +03:00
|
|
|
buf = append(buf, '\n')
|
|
|
|
buf = append(buf, e.prefix...)
|
|
|
|
buf = append(buf, bytes.Repeat(e.indentStr, code.indent)...)
|
2020-11-16 13:10:46 +03:00
|
|
|
buf = append(buf, '}', ',', '\n')
|
2020-09-16 08:51:37 +03:00
|
|
|
e.buf = e.buf[:pos[0]]
|
|
|
|
e.buf = append(e.buf, buf...)
|
|
|
|
code = code.next
|
2020-11-16 15:28:33 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadRecursive:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadRecursive:
|
|
|
|
fallthrough
|
2020-08-12 12:42:29 +03:00
|
|
|
case opStructFieldRecursive:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-31 15:59:22 +03:00
|
|
|
if ptr != 0 {
|
2020-09-01 16:26:26 +03:00
|
|
|
if recursiveLevel > startDetectingCyclesAfter {
|
|
|
|
if _, exists := seenPtr[ptr]; exists {
|
2020-09-15 14:48:02 +03:00
|
|
|
return errUnsupportedValue(code, ptr)
|
2020-08-31 15:59:22 +03:00
|
|
|
}
|
2020-08-20 17:56:12 +03:00
|
|
|
}
|
|
|
|
}
|
2020-09-01 16:26:26 +03:00
|
|
|
seenPtr[ptr] = struct{}{}
|
2020-09-04 07:48:21 +03:00
|
|
|
c := code.jmp.code
|
2020-08-31 15:59:22 +03:00
|
|
|
c.end.next = newEndOp(&encodeCompileContext{})
|
|
|
|
c.op = c.op.ptrHeadToHead()
|
2020-09-04 07:48:21 +03:00
|
|
|
|
|
|
|
beforeLastCode := c.end
|
|
|
|
lastCode := beforeLastCode.next
|
|
|
|
|
|
|
|
lastCode.idx = beforeLastCode.idx + uintptrSize
|
|
|
|
lastCode.elemIdx = lastCode.idx + uintptrSize
|
|
|
|
|
|
|
|
// extend length to alloc slot for elemIdx
|
|
|
|
totalLength := uintptr(code.totalLength() + 1)
|
|
|
|
nextTotalLength := uintptr(c.totalLength() + 1)
|
|
|
|
|
|
|
|
curlen := uintptr(len(ctx.ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
|
|
|
oldOffset := ptrOffset
|
|
|
|
ptrOffset += totalLength * uintptrSize
|
|
|
|
|
|
|
|
newLen := offsetNum + totalLength + nextTotalLength
|
|
|
|
if curlen < newLen {
|
|
|
|
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
2020-08-12 12:42:29 +03:00
|
|
|
}
|
2020-09-04 07:48:21 +03:00
|
|
|
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
|
|
|
|
|
2020-09-15 14:48:16 +03:00
|
|
|
store(ctxptr, c.idx, ptr)
|
2020-09-04 07:48:21 +03:00
|
|
|
store(ctxptr, lastCode.idx, oldOffset)
|
|
|
|
store(ctxptr, lastCode.elemIdx, uintptr(unsafe.Pointer(code.next)))
|
|
|
|
|
|
|
|
// link lastCode ( opStructFieldRecursiveEnd ) => code.next
|
|
|
|
lastCode.op = opStructFieldRecursiveEnd
|
|
|
|
code = c
|
|
|
|
recursiveLevel++
|
|
|
|
case opStructFieldRecursiveEnd:
|
|
|
|
recursiveLevel--
|
|
|
|
|
|
|
|
// restore ctxptr
|
|
|
|
offset := load(ctxptr, code.idx)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr := load(ctxptr, code.elemIdx)
|
2020-11-17 09:09:06 +03:00
|
|
|
code = (*opcode)(e.ptrToUnsafePtr(ptr))
|
2020-09-04 07:48:21 +03:00
|
|
|
ctxptr = ctx.ptr() + offset
|
|
|
|
ptrOffset = offset
|
2020-04-29 19:44:48 +03:00
|
|
|
case opStructFieldPtrHead:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-29 19:44:48 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 18:31:50 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:16:06 +03:00
|
|
|
if code.op == opStructFieldPtrHead {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:16:06 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:16:06 +03:00
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
if !code.anonymousKey {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
2020-09-01 16:26:26 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-04-29 19:44:48 +03:00
|
|
|
}
|
2020-08-22 06:58:34 +03:00
|
|
|
case opStructFieldAnonymousHead:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-22 06:58:34 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-22 06:58:34 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-08-22 06:58:34 +03:00
|
|
|
}
|
2020-04-29 19:44:48 +03:00
|
|
|
case opStructFieldPtrHeadInt:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-29 19:44:48 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 19:44:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadInt {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt(e.ptrToInt(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt(e.ptrToInt(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-29 19:44:48 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
case opStructFieldPtrHeadInt8:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadInt8 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt8(e.ptrToInt8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt8(e.ptrToInt8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadInt16:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadInt16 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt16(e.ptrToInt16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt16(e.ptrToInt16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadInt32:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadInt32 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt32(e.ptrToInt32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt32(e.ptrToInt32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadInt64:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadInt64 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt64(e.ptrToInt64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt64(e.ptrToInt64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadUint {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint(e.ptrToUint(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint(e.ptrToUint(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint8:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadUint8 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint8(e.ptrToUint8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint8:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint8(e.ptrToUint8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint16:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadUint16 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint16(e.ptrToUint16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint16(e.ptrToUint16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint32:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadUint32 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint32(e.ptrToUint32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint32(e.ptrToUint32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint64:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadUint64 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint64(e.ptrToUint64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint64(e.ptrToUint64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadFloat32:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadFloat32 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeFloat32(e.ptrToFloat32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeFloat32(e.ptrToFloat32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadFloat64:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadFloat64 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-05-08 19:07:33 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-08 19:07:33 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-15 11:41:38 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 11:41:38 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2020-04-29 19:44:48 +03:00
|
|
|
case opStructFieldPtrHeadString:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-29 19:44:48 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-29 19:44:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadString {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(e.ptrToString(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadString:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(e.ptrToString(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
case opStructFieldPtrHeadBool:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-04-30 05:56:56 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadBool {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeBool(e.ptrToBool(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 11:41:38 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeBool(e.ptrToBool(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2020-08-19 04:34:11 +03:00
|
|
|
case opStructFieldPtrHeadBytes:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-08-19 04:34:11 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 04:34:11 +03:00
|
|
|
if ptr == 0 {
|
2020-08-22 12:28:03 +03:00
|
|
|
if code.op == opStructFieldPtrHeadBytes {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ','})
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(e.ptrToBytes(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-19 04:34:11 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 04:34:11 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(e.ptrToBytes(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldPtrHeadArray:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-08-23 19:50:18 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadArray:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.idx) + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
if code.op == opStructFieldPtrHeadArray {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', ']', ','})
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
if !code.anonymousKey {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadArray:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-23 19:50:18 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadArray:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.idx) + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadSlice:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-08-23 19:50:18 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadSlice:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-30 17:58:58 +03:00
|
|
|
if p == 0 {
|
2020-08-23 19:50:18 +03:00
|
|
|
if code.op == opStructFieldPtrHeadSlice {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'[', ']', ','})
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
if !code.anonymousKey {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadSlice:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-23 19:50:18 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadSlice:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-30 17:58:58 +03:00
|
|
|
if p == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2020-08-18 18:32:45 +03:00
|
|
|
case opStructFieldPtrHeadMarshalJSON:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-08-18 18:32:45 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-08-21 05:51:33 +03:00
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
2020-08-21 05:07:55 +03:00
|
|
|
e.encodeNull()
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end
|
2020-08-21 05:07:55 +03:00
|
|
|
break
|
|
|
|
}
|
2020-08-21 05:51:33 +03:00
|
|
|
b, err := rv.Interface().(Marshaler).MarshalJSON()
|
2020-08-18 18:32:45 +03:00
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
if len(b) == 0 {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-18 18:32:45 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-18 18:32:45 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-08-21 05:51:33 +03:00
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
e.encodeNull()
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-21 05:51:33 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
b, err := rv.Interface().(Marshaler).MarshalJSON()
|
2020-08-18 18:32:45 +03:00
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
if len(b) == 0 {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-18 18:32:45 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadMarshalText:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-08-18 18:32:45 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-08-21 05:51:33 +03:00
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
2020-08-21 05:07:55 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end
|
2020-08-21 05:07:55 +03:00
|
|
|
break
|
|
|
|
}
|
2020-08-21 05:51:33 +03:00
|
|
|
bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText()
|
2020-08-18 18:32:45 +03:00
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-18 18:32:45 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, ptr)
|
2020-08-21 05:51:33 +03:00
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-21 05:51:33 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText()
|
2020-08-18 18:32:45 +03:00
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructFieldPtrHeadIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructFieldHeadIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else if code.next == code.end {
|
2020-08-22 18:54:43 +03:00
|
|
|
// not exists fields
|
|
|
|
e.encodeIndent(code.indent)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructFieldPtrHeadIntIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadIntIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-08-27 15:01:53 +03:00
|
|
|
if code.op == opStructFieldPtrHeadIntIndent {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-27 15:01:53 +03:00
|
|
|
} else {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-27 15:01:53 +03:00
|
|
|
}
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt(e.ptrToInt(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructFieldPtrHeadInt8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-01 07:12:01 +03:00
|
|
|
fallthrough
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructFieldHeadInt8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeInt8(e.ptrToInt8(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadInt16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeInt16(e.ptrToInt16(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadInt32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeInt32(e.ptrToInt32(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadInt64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeInt64(e.ptrToInt64(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUintIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUintIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeUint(e.ptrToUint(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeUint8(e.ptrToUint8(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeUint16(e.ptrToUint16(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeUint32(e.ptrToUint32(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeUint64(e.ptrToUint64(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadFloat32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeFloat32(e.ptrToFloat32(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadFloat64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-08-15 12:36:02 +03:00
|
|
|
v := e.ptrToFloat64(ptr)
|
2020-05-08 19:07:33 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-08 19:07:33 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeString(e.ptrToString(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadBoolIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-05-02 17:35:41 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadBoolIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-15 12:36:02 +03:00
|
|
|
e.encodeBool(e.ptrToBool(ptr))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-19 04:34:11 +03:00
|
|
|
case opStructFieldPtrHeadBytesIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-19 04:34:11 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadBytesIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 04:34:11 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 04:34:11 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
s := base64.StdEncoding.EncodeToString(e.ptrToBytes(ptr))
|
|
|
|
e.encodeByte('"')
|
|
|
|
e.encodeBytes(*(*[]byte)(unsafe.Pointer(&s)))
|
|
|
|
e.encodeByte('"')
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmpty:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmpty:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-11-14 23:27:15 +03:00
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmpty:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmpty:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-11-14 23:27:15 +03:00
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeInt(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeInt(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeInt8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeInt8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeInt16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeInt16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeInt32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeInt32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeInt64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeInt64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeUint(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeUint(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeUint8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeUint8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeUint16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeUint16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeUint32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeUint32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeUint64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeUint64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeFloat32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeFloat32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-05-08 19:07:33 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToString(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if v == "" {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeString(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToString(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if v == "" {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeString(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
2020-05-02 17:35:41 +03:00
|
|
|
if !v {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeBool(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-15 12:17:48 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
2020-08-15 12:17:48 +03:00
|
|
|
if !v {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-15 12:17:48 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-15 12:17:48 +03:00
|
|
|
e.encodeBool(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-15 12:17:48 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-19 04:34:11 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 04:34:11 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
2020-08-19 04:34:11 +03:00
|
|
|
if len(v) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 04:34:11 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
2020-08-19 04:34:11 +03:00
|
|
|
if len(v) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-18 18:32:45 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-18 18:32:45 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(b) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-18 18:32:45 +03:00
|
|
|
return err
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-18 18:32:45 +03:00
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-18 18:32:45 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(b) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-18 18:32:45 +03:00
|
|
|
return err
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-18 18:32:45 +03:00
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-18 18:32:45 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-18 18:32:45 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-18 18:32:45 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-18 18:32:45 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-18 18:32:45 +03:00
|
|
|
} else {
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-18 18:32:45 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-02 17:35:41 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-11-14 23:27:15 +03:00
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyIntIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeInt(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeInt8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeInt16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeInt32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeInt64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUintIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUintIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeUint(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeUint8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeUint16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeUint32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeUint64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeFloat32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-08 19:07:33 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyStringIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyStringIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToString(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if v == "" {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeString(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBoolIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBoolIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-05-01 07:12:01 +03:00
|
|
|
if ptr == 0 {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-05-03 11:41:33 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
2020-05-01 07:12:01 +03:00
|
|
|
if !v {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-05-01 07:12:01 +03:00
|
|
|
} else {
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte(' ')
|
2020-05-01 07:12:01 +03:00
|
|
|
e.encodeBool(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-19 04:34:11 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBytesIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyBytesIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 04:34:11 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
2020-08-19 04:34:11 +03:00
|
|
|
if len(v) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 04:34:11 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
s := base64.StdEncoding.EncodeToString(v)
|
|
|
|
e.encodeByte('"')
|
|
|
|
e.encodeBytes(*(*[]byte)(unsafe.Pointer(&s)))
|
|
|
|
e.encodeByte('"')
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldPtrHeadStringTag:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTag:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTag:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTag:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, ptr+code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagUint:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagUint8:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagUint16:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagUint32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToFloat32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagFloat32:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToFloat32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(fmt.Sprint(v))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagFloat64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(fmt.Sprint(v))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
|
|
|
var buf bytes.Buffer
|
|
|
|
enc := NewEncoder(&buf)
|
|
|
|
s := e.ptrToString(ptr + code.offset)
|
|
|
|
if e.enabledHTMLEscape {
|
|
|
|
enc.encodeEscapedString(s)
|
|
|
|
} else {
|
|
|
|
enc.encodeNoEscapedString(s)
|
|
|
|
}
|
|
|
|
e.encodeString(string(enc.buf))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-16 19:26:39 +03:00
|
|
|
enc.release()
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagString:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(strconv.Quote(e.ptrToString(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToBool(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagBool:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToBool(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(e.ptrToBytes(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagBytes:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(e.ptrToBytes(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-19 13:56:02 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(b) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeBytes([]byte{'"', '"'})
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-19 13:56:02 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
e.encodeString(buf.String())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagMarshalJSON:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-19 13:56:02 +03:00
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(b) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeBytes([]byte{'"', '"'})
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-19 13:56:02 +03:00
|
|
|
return err
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(buf.String())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeByte('{')
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-19 13:56:02 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagMarshalText:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
ptr += code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
2020-08-19 13:56:02 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagIntIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagIntIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUintIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUintIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint8Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint16Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagUint64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagFloat32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagFloat32Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToFloat32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagFloat64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagFloat64Indent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeString(fmt.Sprint(v))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagStringIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagStringIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-11-16 13:10:46 +03:00
|
|
|
var buf bytes.Buffer
|
|
|
|
enc := NewEncoder(&buf)
|
|
|
|
s := e.ptrToString(ptr + code.offset)
|
|
|
|
if e.enabledHTMLEscape {
|
|
|
|
enc.encodeEscapedString(s)
|
|
|
|
} else {
|
|
|
|
enc.encodeNoEscapedString(s)
|
|
|
|
}
|
|
|
|
e.encodeString(string(enc.buf))
|
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagBoolIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagBoolIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToBool(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagBytesIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagBytesIndent:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-08-19 13:56:02 +03:00
|
|
|
if ptr == 0 {
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
|
|
|
e.encodeBytes([]byte{'{', '\n'})
|
|
|
|
e.encodeIndent(code.indent + 1)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
s := base64.StdEncoding.EncodeToString(
|
2020-08-31 15:59:22 +03:00
|
|
|
e.ptrToBytes(ptr + code.offset),
|
2020-08-19 13:56:02 +03:00
|
|
|
)
|
|
|
|
e.encodeByte('"')
|
|
|
|
e.encodeBytes(*(*[]byte)(unsafe.Pointer(&s)))
|
|
|
|
e.encodeByte('"')
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-04-29 18:31:50 +03:00
|
|
|
case opStructField:
|
2020-08-31 15:59:22 +03:00
|
|
|
if !code.anonymousKey {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-22 06:58:34 +03:00
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx) + code.offset
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
2020-08-31 15:59:22 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrInt:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeInt(e.ptrToInt(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldInt:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt(e.ptrToInt(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrInt8:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeInt8(e.ptrToInt8(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldInt8:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt8(e.ptrToInt8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrInt16:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeInt16(e.ptrToInt16(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldInt16:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt16(e.ptrToInt16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrInt32:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeInt32(e.ptrToInt32(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldInt32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt32(e.ptrToInt32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrInt64:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeInt64(e.ptrToInt64(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldInt64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeInt64(e.ptrToInt64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrUint:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeUint(e.ptrToUint(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldUint:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint(e.ptrToUint(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrUint8:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeUint8(e.ptrToUint8(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldUint8:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint8(e.ptrToUint8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrUint16:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeUint16(e.ptrToUint16(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldUint16:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint16(e.ptrToUint16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrUint32:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeUint32(e.ptrToUint32(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldUint32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint32(e.ptrToUint32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrUint64:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeUint64(e.ptrToUint64(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldUint64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeUint64(e.ptrToUint64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrFloat32:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeFloat32(e.ptrToFloat32(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldFloat32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeFloat32(e.ptrToFloat32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrFloat64:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
v := e.ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-09-17 15:50:27 +03:00
|
|
|
}
|
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldFloat64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrString:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeString(e.ptrToString(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldString:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(e.ptrToString(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
case opStructFieldPtrBool:
|
|
|
|
e.encodeKey(code)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
|
|
|
} else {
|
|
|
|
e.encodeBool(e.ptrToBool(p))
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldBool:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeBool(e.ptrToBool(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldBytes:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(e.ptrToBytes(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldMarshalJSON:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-19 13:56:02 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldMarshalText:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldArray:
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldSlice:
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldMap:
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldMapLoad:
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldStruct:
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-01 16:26:26 +03:00
|
|
|
p := ptr + code.offset
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-09-01 16:26:26 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldIntIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeInt(e.ptrToInt(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldInt8Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeInt8(e.ptrToInt8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldInt16Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeInt16(e.ptrToInt16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldInt32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeInt32(e.ptrToInt32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldInt64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeInt64(e.ptrToInt64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldUintIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeUint(e.ptrToUint(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldUint8Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeUint8(e.ptrToUint8(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldUint16Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeUint16(e.ptrToUint16(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldUint32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeUint32(e.ptrToUint32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldUint64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeUint64(e.ptrToUint64(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldFloat32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeFloat32(e.ptrToFloat32(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldFloat64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeString(e.ptrToString(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldBoolIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeBool(e.ptrToBool(ptr + code.offset))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldBytesIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
s := base64.StdEncoding.EncodeToString(e.ptrToBytes(ptr + code.offset))
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte('"')
|
|
|
|
e.encodeBytes(*(*[]byte)(unsafe.Pointer(&s)))
|
|
|
|
e.encodeByte('"')
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldMarshalJSONIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-19 13:56:02 +03:00
|
|
|
return err
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldArrayIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
array := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(array.data) == 0 {
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldSliceIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeNull()
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldMapIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-17 09:09:06 +03:00
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
mlen := maplen(e.ptrToUnsafePtr(p))
|
2020-08-23 19:50:18 +03:00
|
|
|
if mlen == 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-23 19:50:18 +03:00
|
|
|
mapCode := code.next
|
2020-08-31 15:59:22 +03:00
|
|
|
code = mapCode.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldMapLoadIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if p == 0 {
|
|
|
|
e.encodeNull()
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-17 09:09:06 +03:00
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
mlen := maplen(e.ptrToUnsafePtr(p))
|
2020-08-23 19:50:18 +03:00
|
|
|
if mlen == 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldStructIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
if p == 0 {
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
headCode := code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
if headCode.next == headCode.end {
|
|
|
|
// not exists fields
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmpty:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-14 23:27:15 +03:00
|
|
|
if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyInt:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeInt(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyInt8:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeInt8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyInt16:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeInt16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyInt32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeInt32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyInt64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeInt64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyUint:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeUint(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyUint8:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeUint8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyUint16:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeUint16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyUint32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeUint32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyUint64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeUint64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyFloat32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeFloat32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyFloat64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyString:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToString(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != "" {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyBool:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeBool(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-08-19 04:34:11 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyBytes:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if len(v) > 0 {
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyMarshalJSON:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != nil {
|
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-19 13:56:02 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
e.encodeBytes(buf.Bytes())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyMarshalText:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != nil {
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldOmitEmptyArray:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
array := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(array.data) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptySlice:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyMap:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if p == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
2020-08-23 19:50:18 +03:00
|
|
|
if mlen == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyMapLoad:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if p == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
2020-08-23 19:50:18 +03:00
|
|
|
if mlen == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-14 23:27:15 +03:00
|
|
|
if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-19 13:56:02 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyIntIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeInt(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyInt8Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeInt8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyInt16Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeInt16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyInt32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeInt32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyInt64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeInt64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyUintIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeUint(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyUint8Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeUint8(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyUint16Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeUint16(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyUint32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeUint32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyUint64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeUint64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyFloat32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeFloat32(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-08 12:53:01 +03:00
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyFloat64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != 0 {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeFloat64(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyStringIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToString(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v != "" {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeString(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldOmitEmptyBoolIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if v {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeBool(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldOmitEmptyBytesIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if len(v) > 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
s := base64.StdEncoding.EncodeToString(v)
|
|
|
|
e.encodeByte('"')
|
|
|
|
e.encodeBytes(*(*[]byte)(unsafe.Pointer(&s)))
|
|
|
|
e.encodeByte('"')
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
case opStructFieldOmitEmptyArrayIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
array := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(array.data) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptySliceIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
slice := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyMapIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if p == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
2020-08-23 19:50:18 +03:00
|
|
|
if mlen == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyMapLoadIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if p == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-11-14 23:27:15 +03:00
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
2020-08-23 19:50:18 +03:00
|
|
|
if mlen == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyStructIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-08-23 19:50:18 +03:00
|
|
|
if p == 0 {
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-23 19:50:18 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
headCode := code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
if headCode.next == headCode.end {
|
|
|
|
// not exists fields
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{'{', '}', ',', '\n'})
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.nextField
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTag:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagInt:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagInt8:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagInt16:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagInt32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagInt64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint8:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint16:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagFloat32:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToFloat32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagFloat64:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-05-01 07:12:01 +03:00
|
|
|
}
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(fmt.Sprint(v))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagString:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-11-16 13:10:46 +03:00
|
|
|
var b bytes.Buffer
|
|
|
|
enc := NewEncoder(&b)
|
|
|
|
enc.encodeString(e.ptrToString(ptr + code.offset))
|
|
|
|
e.encodeString(string(enc.buf))
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagBool:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToBool(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-05-01 07:12:01 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagBytes:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-09-15 17:22:35 +03:00
|
|
|
e.encodeByteSlice(v)
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-19 04:34:11 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagMarshalJSON:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-19 13:56:02 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
e.encodeString(buf.String())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-18 18:32:45 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagMarshalText:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeByte(',')
|
2020-08-18 18:32:45 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
code = code.next
|
2020-08-30 17:58:58 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagIntIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagInt8Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagInt16Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagInt32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagInt64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToInt64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUintIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint8Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint8(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint16Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint16(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagUint64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToUint64(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagFloat32Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToFloat32(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagFloat64Indent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
2020-08-19 13:56:02 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
2020-11-17 09:14:07 +03:00
|
|
|
return errUnsupportedFloat(v)
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
e.encodeString(fmt.Sprint(v))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagStringIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
var b bytes.Buffer
|
|
|
|
enc := NewEncoder(&b)
|
2020-08-31 15:59:22 +03:00
|
|
|
enc.encodeString(e.ptrToString(ptr + code.offset))
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(string(enc.buf))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 13:56:02 +03:00
|
|
|
enc.release()
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagBoolIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
e.encodeString(fmt.Sprint(e.ptrToBool(ptr + code.offset)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagBytesIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
|
|
|
s := base64.StdEncoding.EncodeToString(
|
2020-08-31 15:59:22 +03:00
|
|
|
e.ptrToBytes(ptr + code.offset),
|
2020-08-19 13:56:02 +03:00
|
|
|
)
|
|
|
|
e.encodeByte('"')
|
|
|
|
e.encodeBytes(*(*[]byte)(unsafe.Pointer(&s)))
|
|
|
|
e.encodeByte('"')
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagMarshalJSONIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
b, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-05-02 17:35:41 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
var buf bytes.Buffer
|
2020-09-16 19:26:39 +03:00
|
|
|
if err := compact(&buf, b, e.enabledHTMLEscape); err != nil {
|
2020-08-19 13:56:02 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
e.encodeString(buf.String())
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-08-19 13:56:02 +03:00
|
|
|
case opStructFieldStringTagMarshalTextIndent:
|
2020-08-31 15:59:22 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
e.encodeIndent(code.indent)
|
2020-09-16 19:26:39 +03:00
|
|
|
e.encodeKey(code)
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeByte(' ')
|
2020-08-31 15:59:22 +03:00
|
|
|
p := ptr + code.offset
|
2020-11-17 09:09:06 +03:00
|
|
|
v := e.ptrToInterface(code, p)
|
2020-08-19 13:56:02 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
2020-11-17 09:08:12 +03:00
|
|
|
return errMarshaler(code, err)
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
2020-08-19 13:56:02 +03:00
|
|
|
e.encodeString(*(*string)(unsafe.Pointer(&bytes)))
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-08-19 04:34:11 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opStructEnd:
|
2020-11-16 13:10:46 +03:00
|
|
|
last := len(e.buf) - 1
|
|
|
|
if e.buf[last] == ',' {
|
|
|
|
e.buf[last] = '}'
|
|
|
|
} else {
|
|
|
|
e.encodeByte('}')
|
|
|
|
}
|
|
|
|
e.encodeByte(',')
|
2020-04-29 18:31:50 +03:00
|
|
|
code = code.next
|
2020-08-15 11:41:38 +03:00
|
|
|
case opStructAnonymousEnd:
|
|
|
|
code = code.next
|
2020-05-02 17:35:41 +03:00
|
|
|
case opStructEndIndent:
|
2020-11-16 13:10:46 +03:00
|
|
|
last := len(e.buf) - 1
|
|
|
|
if e.buf[last] == '\n' {
|
|
|
|
// to remove ',' and '\n' characters
|
|
|
|
e.buf = e.buf[:len(e.buf)-2]
|
|
|
|
}
|
2020-05-02 17:35:41 +03:00
|
|
|
e.encodeByte('\n')
|
|
|
|
e.encodeIndent(code.indent)
|
|
|
|
e.encodeByte('}')
|
2020-11-16 13:10:46 +03:00
|
|
|
e.encodeBytes([]byte{',', '\n'})
|
2020-05-02 17:35:41 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opEnd:
|
|
|
|
goto END
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END:
|
|
|
|
return nil
|
|
|
|
}
|
2020-04-30 07:52:24 +03:00
|
|
|
|
2020-11-17 09:09:06 +03:00
|
|
|
func (e *Encoder) ptrToInt(p uintptr) int { return **(**int)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToInt8(p uintptr) int8 { return **(**int8)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToInt16(p uintptr) int16 { return **(**int16)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToInt32(p uintptr) int32 { return **(**int32)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToInt64(p uintptr) int64 { return **(**int64)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToUint(p uintptr) uint { return **(**uint)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToUint8(p uintptr) uint8 { return **(**uint8)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToUint16(p uintptr) uint16 { return **(**uint16)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToUint32(p uintptr) uint32 { return **(**uint32)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToByte(p uintptr) byte { return **(**byte)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToSlice(p uintptr) *sliceHeader { return *(**sliceHeader)(unsafe.Pointer(&p)) }
|
|
|
|
func (e *Encoder) ptrToPtr(p uintptr) uintptr {
|
|
|
|
return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
}
|
|
|
|
func (e *Encoder) ptrToUnsafePtr(p uintptr) unsafe.Pointer {
|
|
|
|
return *(*unsafe.Pointer)(unsafe.Pointer(&p))
|
|
|
|
}
|
|
|
|
func (e *Encoder) ptrToInterface(code *opcode, p uintptr) interface{} {
|
|
|
|
return *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
|
|
|
typ: code.typ,
|
|
|
|
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)),
|
|
|
|
}))
|
|
|
|
}
|