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-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-12-19 16:40:03 +03:00
|
|
|
func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte, error) {
|
2020-09-04 07:53:25 +03:00
|
|
|
recursiveLevel := 0
|
2020-09-03 09:36:11 +03:00
|
|
|
ptrOffset := uintptr(0)
|
2020-08-30 17:58:58 +03:00
|
|
|
ctxptr := ctx.ptr()
|
2020-12-29 19:29:29 +03:00
|
|
|
|
2020-04-29 18:31:50 +03:00
|
|
|
for {
|
|
|
|
switch code.op {
|
2020-11-16 13:10:46 +03:00
|
|
|
default:
|
2020-12-19 16:40:03 +03:00
|
|
|
return nil, fmt.Errorf("failed to handle opcode. doesn't implement %s", code.op)
|
2021-01-10 23:16:37 +03:00
|
|
|
case opPtr:
|
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-12-20 16:59:23 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opInt8:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt8(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opInt16:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt16(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opInt32:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt32(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opInt64:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendInt(b, e.ptrToInt64(load(ctxptr, code.idx)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opUint:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opUint8:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opUint16:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opUint32:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(load(ctxptr, code.idx))))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opUint64:
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendUint(b, e.ptrToUint64(load(ctxptr, code.idx)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-12-12 12:09:46 +03:00
|
|
|
case opIntString:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt8String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt16String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt32String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opInt64String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, e.ptrToInt64(load(ctxptr, code.idx)))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opUintString:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint8String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint16String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint32String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(load(ctxptr, code.idx))))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
|
|
|
case opUint64String:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, e.ptrToUint64(load(ctxptr, code.idx)))
|
|
|
|
b = append(b, '"')
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-12 12:09:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opFloat32:
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(load(ctxptr, code.idx)))
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
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-12-19 16:40:03 +03:00
|
|
|
return nil, errUnsupportedFloat(v)
|
2020-05-08 19:07:33 +03:00
|
|
|
}
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opString:
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(load(ctxptr, code.idx)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opBool:
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeBool(b, e.ptrToBool(load(ctxptr, code.idx)))
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +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-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-21 05:51:33 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeByteSlice(b, e.ptrToBytes(ptr))
|
2020-08-21 05:51:33 +03:00
|
|
|
}
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +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 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-15 10:25:00 +03:00
|
|
|
for _, seen := range ctx.seenPtr {
|
|
|
|
if ptr == seen {
|
|
|
|
return nil, errUnsupportedValue(code, ptr)
|
|
|
|
}
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
2021-01-15 10:25:00 +03:00
|
|
|
ctx.seenPtr = append(ctx.seenPtr, ptr)
|
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() {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +03:00
|
|
|
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() {
|
2020-12-22 19:37:54 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-07 04:44:24 +03:00
|
|
|
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{
|
2020-12-24 21:53:48 +03:00
|
|
|
typ: header.typ,
|
|
|
|
root: code.root,
|
|
|
|
indent: code.indent,
|
|
|
|
structTypeToCompiledCode: map[uintptr]*compiledCode{},
|
2020-12-07 04:44:24 +03:00
|
|
|
})
|
|
|
|
if err != nil {
|
2020-12-22 19:37:54 +03:00
|
|
|
return nil, err
|
2020-12-07 04:44:24 +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++
|
2021-01-10 23:16:37 +03:00
|
|
|
case opInterfaceEnd:
|
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-12-19 16:40:03 +03:00
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
2020-05-04 12:39:17 +03:00
|
|
|
if err != nil {
|
2020-12-19 16:40:03 +03:00
|
|
|
return nil, errMarshaler(code, err)
|
2020-05-04 12:39:17 +03:00
|
|
|
}
|
2020-12-19 16:40:03 +03:00
|
|
|
if len(bb) == 0 {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
2020-08-18 18:32:45 +03:00
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
2020-08-18 07:36:36 +03:00
|
|
|
var buf bytes.Buffer
|
2020-12-19 16:40:03 +03:00
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
2020-08-18 07:36:36 +03:00
|
|
|
}
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(append(b, buf.Bytes()...), ',')
|
2020-11-16 13:10:46 +03:00
|
|
|
code = code.next
|
2020-05-04 12:39:17 +03:00
|
|
|
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-12-22 19:42:49 +03:00
|
|
|
if p == nil || isPtr && *(*unsafe.Pointer)(p) == nil {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '"', '"', ',')
|
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-12-19 16:40:03 +03:00
|
|
|
return nil, errMarshaler(code, err)
|
2020-11-16 13:10:46 +03:00
|
|
|
}
|
2021-01-11 13:47:33 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-11-16 13:10:46 +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-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
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-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[')
|
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-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[', ']', ',')
|
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-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = ']'
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +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-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
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-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[')
|
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-12-19 16:40:03 +03:00
|
|
|
b = append(b, '[', ']', ',')
|
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-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = ']'
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-30 07:39:47 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opMapHead:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-05-02 17:35:41 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
uptr := e.ptrToUnsafePtr(ptr)
|
|
|
|
mlen := maplen(uptr)
|
|
|
|
if mlen > 0 {
|
|
|
|
b = append(b, '{')
|
|
|
|
iter := mapiterinit(code.typ, uptr)
|
|
|
|
ctx.keepRefs = append(ctx.keepRefs, iter)
|
2020-09-16 08:51:37 +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)
|
2020-12-19 16:40:03 +03:00
|
|
|
pos = append(pos, len(b))
|
2020-09-16 12:15:47 +03:00
|
|
|
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-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{', '}', ',')
|
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 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
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 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
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-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
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)
|
2020-12-19 16:40:03 +03:00
|
|
|
pos = append(pos, len(b))
|
2020-09-16 12:15:47 +03:00
|
|
|
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-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{', '}', ',')
|
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-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = '}'
|
|
|
|
b = encodeComma(b)
|
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-12-19 16:40:03 +03:00
|
|
|
*posPtr = append(*posPtr, len(b))
|
2020-09-16 12:15:47 +03:00
|
|
|
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-12-19 16:40:03 +03:00
|
|
|
last := len(b) - 1
|
|
|
|
b[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-12-19 16:40:03 +03:00
|
|
|
*posPtr = append(*posPtr, len(b))
|
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 {
|
2020-12-19 16:40:03 +03:00
|
|
|
endValue = len(b)
|
2020-09-16 08:51:37 +03:00
|
|
|
}
|
|
|
|
kvs = append(kvs, mapKV{
|
2020-12-19 16:40:03 +03:00
|
|
|
key: string(b[startKey:startValue]),
|
|
|
|
value: string(b[startValue:endValue]),
|
2020-09-16 08:51:37 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
sort.Slice(kvs, func(i, j int) bool {
|
|
|
|
return kvs[i].key < kvs[j].key
|
|
|
|
})
|
2020-12-19 16:40:03 +03:00
|
|
|
buf := b[pos[0]:]
|
2020-09-16 08:51:37 +03:00
|
|
|
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-12-19 16:40:03 +03:00
|
|
|
b = b[:pos[0]]
|
|
|
|
b = append(b, buf...)
|
2020-09-16 08:51:37 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadRecursive:
|
2020-11-16 15:28:33 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadRecursive:
|
2020-11-16 15:28:33 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +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 {
|
2021-01-15 10:25:00 +03:00
|
|
|
for _, seen := range ctx.seenPtr {
|
|
|
|
if ptr == seen {
|
|
|
|
return nil, errUnsupportedValue(code, ptr)
|
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
}
|
2020-08-20 17:56:12 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-15 10:25:00 +03:00
|
|
|
ctx.seenPtr = append(ctx.seenPtr, ptr)
|
2020-09-04 07:48:21 +03:00
|
|
|
c := code.jmp.code
|
|
|
|
curlen := uintptr(len(ctx.ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
|
|
|
oldOffset := ptrOffset
|
2021-01-15 10:25:00 +03:00
|
|
|
ptrOffset += code.jmp.curLen * uintptrSize
|
2020-09-04 07:48:21 +03:00
|
|
|
|
2021-01-15 10:25:00 +03:00
|
|
|
newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen
|
2020-09-04 07:48:21 +03:00
|
|
|
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)
|
2021-01-15 10:25:00 +03:00
|
|
|
store(ctxptr, c.end.next.idx, oldOffset)
|
|
|
|
store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next)))
|
2020-09-04 07:48:21 +03:00
|
|
|
code = c
|
|
|
|
recursiveLevel++
|
|
|
|
case opStructFieldRecursiveEnd:
|
|
|
|
recursiveLevel--
|
|
|
|
|
|
|
|
// restore ctxptr
|
|
|
|
offset := load(ctxptr, code.idx)
|
2021-01-15 10:25:00 +03:00
|
|
|
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
|
|
|
|
|
|
|
|
codePtr := load(ctxptr, code.elemIdx)
|
|
|
|
code = (*opcode)(e.ptrToUnsafePtr(codePtr))
|
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 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
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 {
|
2021-01-09 07:55:34 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.end.next
|
2020-04-29 18:31:50 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-08-31 15:59:22 +03:00
|
|
|
if !code.anonymousKey {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
|
2021-01-09 07:55:34 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
if !code.anonymousKey {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldHeadOmitEmptyOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
if !code.anonymousKey {
|
|
|
|
if ptr != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
} else {
|
|
|
|
code = code.nextField
|
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +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
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
}
|
2020-04-29 19:44:48 +03:00
|
|
|
case opStructFieldPtrHeadInt:
|
2021-01-09 13:55:15 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
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 {
|
2021-01-09 08:24:43 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
2021-01-09 07:55:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
v := int64(e.ptrToInt(p))
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 07:55:34 +03:00
|
|
|
case opStructFieldPtrHeadIntPtr:
|
2021-01-09 13:55:15 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2021-01-09 07:55:34 +03:00
|
|
|
fallthrough
|
2020-12-23 07:13:34 +03:00
|
|
|
case opStructFieldHeadIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-09 07:55:34 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2020-12-23 07:13:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntPtr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagIntPtr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-11 20:40:12 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 07:55:34 +03:00
|
|
|
case opStructFieldPtrHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyIntPtrOnly:
|
|
|
|
b = append(b, '{')
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-11 20:40:12 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-23 07:13:34 +03:00
|
|
|
case opStructFieldHeadIntNPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-11 20:40:12 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadIntPtr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadIntPtr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 13:55:15 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
2020-09-17 15:50:27 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagIntPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-13 18:02:58 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrHeadInt8:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
2020-04-30 05:56:56 +03:00
|
|
|
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 {
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrHeadInt8Only, opStructFieldHeadInt8Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt8Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt8Ptr:
|
2020-12-25 16:26:59 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-09 13:55:15 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt8(p+code.offset)))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadInt8Only, opStructFieldAnonymousHeadInt8Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt8Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt8Ptr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 13:55:15 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
2020-09-17 15:50:27 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadInt8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt16:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
2020-04-30 05:56:56 +03:00
|
|
|
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 {
|
2021-01-09 13:55:15 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-20 16:59:23 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrHeadInt16Only, opStructFieldHeadInt16Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt16Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt16Ptr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 13:55:15 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2021-01-09 13:55:15 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt16(p+code.offset)))
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +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
|
2020-12-25 16:26:59 +03:00
|
|
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 13:55:15 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadInt16Only, opStructFieldAnonymousHeadInt16Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt16Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt16Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadInt16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrHeadInt32:
|
2021-01-09 14:14:34 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
case opStructFieldPtrHeadInt32Only, opStructFieldHeadInt32Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt32Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt32Ptr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2021-01-09 14:14:34 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt32(p+code.offset)))
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:14:34 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +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
|
2020-12-25 16:26:59 +03:00
|
|
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadInt32Only, opStructFieldAnonymousHeadInt32Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt32Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt32Ptr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 14:14:34 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
2020-09-17 15:50:27 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadInt32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
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
|
2021-01-09 14:14:34 +03:00
|
|
|
case opStructFieldAnonymousHeadInt32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt64:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
2020-12-25 16:26:59 +03:00
|
|
|
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 {
|
2021-01-09 14:14:34 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
case opStructFieldPtrHeadInt64Only, opStructFieldHeadInt64Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, e.ptrToInt64(p))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt64Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt64Ptr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 14:14:34 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2021-01-09 14:14:34 +03:00
|
|
|
b = appendInt(b, e.ptrToInt64(p+code.offset))
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadInt64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:14:34 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadInt64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, e.ptrToInt64(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +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
|
2020-12-25 16:26:59 +03:00
|
|
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:14:34 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadInt64Only, opStructFieldAnonymousHeadInt64Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadInt64Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt64Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, e.ptrToInt64(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadInt64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadInt64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, e.ptrToInt64(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrHeadUint:
|
2021-01-09 14:33:55 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-04-30 05:56:56 +03:00
|
|
|
fallthrough
|
2020-12-25 16:26:59 +03:00
|
|
|
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 {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-30 05:56:56 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 14:33:55 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUintPtr:
|
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
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldHeadUintPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:33:55 +03:00
|
|
|
break
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-09 14:33:55 +03:00
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUintPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-09 14:33:55 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldHeadUintPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
} else {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadUintNPtr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-09 14:33:55 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
for i := 0; i < code.ptrNum; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2020-08-22 12:28:03 +03:00
|
|
|
} else {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
|
2020-08-22 12:28:03 +03:00
|
|
|
}
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
2020-08-15 11:41:38 +03:00
|
|
|
fallthrough
|
2021-01-09 14:33:55 +03:00
|
|
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-09 14:33:55 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUintOnly, opStructFieldAnonymousHeadUintOnly:
|
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-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-04-29 19:44:48 +03:00
|
|
|
} else {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-09 14:33:55 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUintPtr:
|
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
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldAnonymousHeadUintPtr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 14:33:55 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2020-08-15 11:41:38 +03:00
|
|
|
} else {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
|
2020-04-30 05:56:56 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadUintPtrOnly:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
2020-08-19 04:34:11 +03:00
|
|
|
fallthrough
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldAnonymousHeadUintPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint8:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint8Only, opStructFieldHeadUint8Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint8Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint8Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(p+code.offset)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadUint8:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint8Only, opStructFieldAnonymousHeadUint8Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint8Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint8Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadUint8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint8PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint16:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadUint16Only, opStructFieldHeadUint16Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint16Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint16Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(p+code.offset)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint16:
|
2021-01-09 14:33:55 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint16Only, opStructFieldAnonymousHeadUint16Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-09 14:33:55 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint16Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint16Ptr:
|
2021-01-09 14:33:55 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadUint16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint16PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint32:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-19 04:34:11 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-19 04:34:11 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldPtrHeadUint32Only, opStructFieldHeadUint32Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(p)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint32Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint32Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(p+code.offset)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadUint32:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint32Only, opStructFieldAnonymousHeadUint32Only:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint32Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint32Ptr:
|
2020-09-17 15:50:27 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 14:33:55 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
2020-09-17 15:50:27 +03:00
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-09 14:33:55 +03:00
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadUint32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(p+code.offset)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint64:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldHeadUint64:
|
2020-08-30 17:58:58 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2020-12-25 16:26:59 +03:00
|
|
|
if ptr == 0 {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-08-23 19:50:18 +03:00
|
|
|
} else {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-08-23 19:50:18 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
case opStructFieldPtrHeadUint64Only, opStructFieldHeadUint64Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, e.ptrToUint64(p))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint64Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint64Ptr:
|
2020-12-25 16:26:59 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2020-08-30 17:58:58 +03:00
|
|
|
if p == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 14:33:55 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-09 14:33:55 +03:00
|
|
|
b = appendUint(b, e.ptrToUint64(p+code.offset))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-09 14:33:55 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadUint64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadUint64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, e.ptrToUint64(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint64:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadUint64Only, opStructFieldAnonymousHeadUint64Only:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-09 14:33:55 +03:00
|
|
|
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadUint64Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint64Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, e.ptrToUint64(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadUint64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadUint64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, e.ptrToUint64(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrHeadFloat32:
|
2021-01-09 15:08:29 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2021-01-09 15:08:29 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-09-17 15:50:27 +03:00
|
|
|
}
|
2021-01-09 15:08:29 +03:00
|
|
|
case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(p))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadFloat32Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat32Ptr:
|
2020-12-25 16:26:59 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-09-17 15:50:27 +03:00
|
|
|
code = code.end.next
|
2020-12-25 16:26:59 +03:00
|
|
|
break
|
2021-01-09 15:08:29 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-09 15:08:29 +03:00
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(p+code.offset))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-09 15:08:29 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadFloat32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
2021-01-09 15:08:29 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 15:08:29 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat32Only, opStructFieldAnonymousHeadFloat32Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadFloat32Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadFloat32Ptr:
|
2020-12-25 16:26:59 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
2021-01-09 15:08:29 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
2020-12-25 16:26:59 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-09 15:08:29 +03:00
|
|
|
} else {
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadFloat32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
2021-01-09 15:08:29 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat32PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadFloat64:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldHeadFloat64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-09 15:08:29 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 15:08:29 +03:00
|
|
|
case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
v := e.ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadFloat64Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
v := e.ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadFloat64PtrOnly:
|
2020-12-25 16:26:59 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
2021-01-09 15:08:29 +03:00
|
|
|
case opStructFieldHeadFloat64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
v := e.ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64:
|
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
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldAnonymousHeadFloat64:
|
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-12-25 16:26:59 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2020-08-18 18:32:45 +03:00
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 15:08:29 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64Only, opStructFieldAnonymousHeadFloat64Only:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadFloat64Ptr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
v := e.ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadFloat64PtrOnly:
|
2021-01-09 15:08:29 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadFloat64PtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-09 15:08:29 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
v := e.ptrToFloat64(p + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrHeadString:
|
2021-01-09 19:03:02 +03:00
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadString:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(p))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrHeadStringPtr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringPtr:
|
2021-01-09 07:55:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
2021-01-09 19:03:02 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(p+code.offset))
|
|
|
|
}
|
2021-01-09 07:55:34 +03:00
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-09 19:03:02 +03:00
|
|
|
case opStructFieldPtrHeadStringPtrOnly:
|
2020-12-25 16:26:59 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
2021-01-09 19:03:02 +03:00
|
|
|
case opStructFieldHeadStringPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadString:
|
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
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldAnonymousHeadString:
|
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-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 19:03:02 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringOnly, opStructFieldAnonymousHeadStringOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringPtr:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringPtr:
|
2021-01-09 07:55:34 +03:00
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
2021-01-09 19:03:02 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldPtrAnonymousHeadStringPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringPtrOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(p+code.offset))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrHeadBool:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
if code.op == opStructFieldPtrHeadBool {
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '{', '}', ',')
|
2020-08-21 05:51:33 +03:00
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-09 07:55:34 +03:00
|
|
|
case opStructFieldPtrHeadBoolOnly:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadBoolOnly:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadBool:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadBytes:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
if code.op == opStructFieldPtrHeadBytes {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '{', '}', ',')
|
|
|
|
}
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadBytes:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadArray:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadArray:
|
|
|
|
ptr := load(ctxptr, code.idx) + code.offset
|
|
|
|
if ptr == 0 {
|
|
|
|
if code.op == opStructFieldPtrHeadArray {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '[', ']', ',')
|
|
|
|
}
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
if !code.anonymousKey {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, ptr)
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadArray:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadArray:
|
|
|
|
ptr := load(ctxptr, code.idx) + code.offset
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
store(ctxptr, code.idx, ptr)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadSlice:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2020-12-19 16:40:03 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadSlice:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 {
|
|
|
|
if code.op == opStructFieldPtrHeadSlice {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '[', ']', ',')
|
|
|
|
}
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
if !code.anonymousKey {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
2020-08-31 15:59:22 +03:00
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadSlice:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadSlice:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadMarshalJSON:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr += code.offset
|
|
|
|
v := e.ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
b = encodeNull(b)
|
|
|
|
code = code.end
|
|
|
|
break
|
|
|
|
}
|
|
|
|
bb, err := rv.Interface().(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, buf.Bytes()...)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadMarshalJSON:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr += code.offset
|
|
|
|
v := e.ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
b = encodeNull(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
bb, err := rv.Interface().(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, buf.Bytes()...)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadMarshalText:
|
|
|
|
p := load(ctxptr, code.idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr += code.offset
|
|
|
|
v := e.ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end
|
|
|
|
break
|
|
|
|
}
|
|
|
|
bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadMarshalText:
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr += code.offset
|
|
|
|
v := e.ptrToInterface(code, ptr)
|
|
|
|
rv := reflect.ValueOf(v)
|
|
|
|
if rv.Type().Kind() == reflect.Interface && rv.IsNil() {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt8:
|
2021-01-10 03:40:38 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-10 23:16:37 +03:00
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt8:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt8:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyInt16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 03:40:38 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2020-12-25 16:26:59 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyInt64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyInt64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyInt64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyInt64:
|
2021-01-10 03:40:38 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyUint:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint:
|
2021-01-10 03:40:38 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 03:40:38 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint:
|
2021-01-10 03:40:38 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-10 23:16:37 +03:00
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint:
|
2021-01-10 03:40:38 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 03:40:38 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 03:40:38 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyUint32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 03:40:38 +03:00
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint32:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint32:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyUint64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-10 07:46:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyUint64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 07:46:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 07:46:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyUint64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyUint64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 07:46:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 07:46:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyFloat64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadOmitEmptyFloat64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 07:46:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyFloat64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 07:46:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyFloat64:
|
2021-01-10 07:46:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyString:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyString:
|
2021-01-10 07:46:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 07:46:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToString(ptr + code.offset)
|
|
|
|
if v == "" {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyString:
|
2021-01-10 07:46:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-10 23:16:37 +03:00
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyString:
|
2021-01-10 07:46:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToString(ptr + code.offset)
|
|
|
|
if v == "" {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 07:46:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
|
|
|
if !v {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
|
|
|
if !v {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 07:46:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 07:46:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 07:46:17 +03:00
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyBytes:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 08:12:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, v)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyMarshalJSON:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
|
|
|
code = code.nextField
|
2021-01-10 08:12:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, buf.Bytes()...)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadOmitEmptyMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
|
|
|
code = code.nextField
|
2021-01-10 08:12:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, buf.Bytes()...)
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadOmitEmptyMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadOmitEmptyMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 08:12:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
|
|
|
code = code.nextField
|
2021-01-10 08:12:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-11 13:47:33 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadOmitEmptyMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadOmitEmptyMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 08:12:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) {
|
|
|
|
code = code.nextField
|
2021-01-10 08:12:17 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-11 13:47:33 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTag:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTag:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
p := ptr + code.offset
|
2021-01-10 08:12:17 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTag:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTag:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, ptr+code.offset)
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagInt8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagInt8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagInt8:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagInt16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagInt16:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagInt16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
2021-01-10 08:12:17 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagInt32:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
2021-01-10 08:12:17 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagInt64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagInt64:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagInt64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagInt64:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUint:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
2021-01-10 23:16:37 +03:00
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagUint:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUint:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagUint8:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:12:17 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUint8:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:12:17 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
2020-12-25 16:26:59 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint16:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2020-12-25 16:26:59 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUint16:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUint32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagUint32:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagUint32:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagUint64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagUint64:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagUint64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:12:17 +03:00
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagUint64:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagFloat32:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat32:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagFloat64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagFloat64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:24:52 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagFloat64:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagFloat64:
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
2021-01-10 08:24:52 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagString:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2020-12-25 16:26:59 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagString:
|
2020-12-25 16:26:59 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
s := e.ptrToString(ptr + code.offset)
|
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagString:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldAnonymousHeadStringTagString:
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
s := string(encodeNoEscapedString([]byte{}, (e.ptrToString(ptr + code.offset))))
|
|
|
|
b = encodeNoEscapedString(b, s)
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagBool:
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNull(b)
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-25 16:26:59 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:24:52 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBool:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.end.next
|
2021-01-10 23:16:37 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case opStructFieldHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:24:52 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 08:24:52 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldPtrAnonymousHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagBytes:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrHeadStringTagMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
2021-01-10 08:24:52 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.end.next
|
2021-01-10 08:24:52 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"', '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagMarshalJSON:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
2021-01-10 08:24:52 +03:00
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
isPtr := code.typ.Kind() == reflect.Ptr
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(bb) == 0 {
|
|
|
|
if isPtr {
|
|
|
|
return nil, errUnexpectedEndOfJSON(
|
|
|
|
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"', '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case opStructFieldPtrHeadStringTagMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldHeadStringTagMarshalText:
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, '{')
|
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, &MarshalerError{
|
|
|
|
Type: rtype2type(code.typ),
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
2021-01-10 08:24:52 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldPtrAnonymousHeadStringTagMarshalText:
|
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
|
|
|
}
|
2021-01-10 08:24:52 +03:00
|
|
|
fallthrough
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldAnonymousHeadStringTagMarshalText:
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.idx)
|
|
|
|
if ptr == 0 {
|
|
|
|
code = code.end.next
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
ptr += code.offset
|
|
|
|
p := e.ptrToUnsafePtr(ptr)
|
|
|
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p}))
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructField:
|
|
|
|
if !code.anonymousKey {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
}
|
|
|
|
ptr := load(ctxptr, code.headIdx) + code.offset
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, ptr)
|
|
|
|
case opStructFieldIntPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
2021-01-10 08:24:52 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
}
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldIntNPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
2021-01-10 08:24:52 +03:00
|
|
|
if p == 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
break
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
p = e.ptrToPtr(p)
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 03:40:38 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:12:17 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldInt:
|
2021-01-10 08:12:17 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldInt8Ptr:
|
2021-01-10 08:24:52 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt8(p)))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldInt8:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldInt16Ptr:
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt16(p)))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldInt16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldInt32Ptr:
|
2021-01-10 08:24:52 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendInt(b, int64(e.ptrToInt32(p)))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldInt32:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldInt64Ptr:
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendInt(b, e.ptrToInt64(p))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldInt64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUintPtr:
|
2021-01-10 08:24:52 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p)))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldUint:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUint8Ptr:
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(p)))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUint8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUint16Ptr:
|
2021-01-10 08:24:52 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(p)))
|
2021-01-10 08:24:52 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldUint16:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUint32Ptr:
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(p)))
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUint32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUint64Ptr:
|
2021-01-10 08:24:52 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, e.ptrToUint64(p))
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2021-01-10 08:24:52 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldUint64:
|
2021-01-10 08:24:52 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldFloat32Ptr:
|
2021-01-10 08:56:49 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(p))
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldFloat32:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:56:49 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldFloat64Ptr:
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 08:56:49 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
break
|
2021-01-10 08:56:49 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat64(p)
|
2020-12-29 17:17:39 +03:00
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringPtr:
|
2021-01-10 08:56:49 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(p))
|
2021-01-10 08:56:49 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldString:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(ptr+code.offset))
|
|
|
|
b = encodeComma(b)
|
2021-01-10 08:56:49 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldBoolPtr:
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 08:56:49 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeBool(b, e.ptrToBool(p))
|
2021-01-10 08:56:49 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, buf.Bytes()...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
2021-01-10 23:16:37 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
2020-12-29 17:17:39 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldArray:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldSlice:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldMap:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldMapLoad:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldStruct:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldOmitEmpty:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
code = code.next
|
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
2020-12-29 17:17:39 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyInt8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
2020-12-29 17:17:39 +03:00
|
|
|
if v != 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendInt(b, int64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyInt16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
2020-12-29 17:17:39 +03:00
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyInt32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
|
|
|
if v != 0 {
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendInt(b, int64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyInt64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyUint:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyUint8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyUint16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyUint32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyUint64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToString(ptr + code.offset)
|
|
|
|
if v != "" {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) > 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, v)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
if v != nil {
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, buf.Bytes()...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
if v != nil {
|
2021-01-10 23:16:37 +03:00
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
2020-12-29 17:17:39 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyArray:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-01-10 23:16:37 +03:00
|
|
|
array := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(array.data) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptySlice:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
slice := e.ptrToSlice(p)
|
|
|
|
if p == 0 || uintptr(slice.data) == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
code = code.next
|
|
|
|
}
|
|
|
|
case opStructFieldOmitEmptyMap:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
if mlen == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
code = code.next
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldOmitEmptyMapLoad:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
2021-01-10 23:16:37 +03:00
|
|
|
if p == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
|
|
|
|
if mlen == 0 {
|
|
|
|
code = code.nextField
|
|
|
|
} else {
|
|
|
|
code = code.next
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTag:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
store(ctxptr, code.idx, p)
|
|
|
|
case opStructFieldStringTagInt:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagInt8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagInt16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagInt32:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagInt64:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructFieldStringTagUint:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagUint8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagUint16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagUint32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagUint64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint64(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
s := e.ptrToString(ptr + code.offset)
|
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, v)
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructFieldStringTagMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEnd:
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last] == ',' {
|
|
|
|
b[last] = '}'
|
|
|
|
} else {
|
|
|
|
b = append(b, '}')
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeComma(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructAnonymousEnd:
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-12 18:14:46 +03:00
|
|
|
case opStructEndInt:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndOmitEmptyInt:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToInt(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndStringTagInt:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndIntPtr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-12 18:14:46 +03:00
|
|
|
case opStructEndOmitEmptyIntPtr:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndStringTagIntPtr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
2021-01-13 18:02:58 +03:00
|
|
|
b = encodeNull(b)
|
2021-01-12 18:14:46 +03:00
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndIntNPtr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
for i := 0; i < code.ptrNum-1; i++ {
|
|
|
|
if p == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
p = e.ptrToPtr(p)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt(p)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt8Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(p)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt16Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(p)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt32Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(p)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt64Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, e.ptrToInt64(p))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndInt64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUintPtr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(p)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndUint8Ptr:
|
|
|
|
b = append(b, code.key...)
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(p)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint16Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(p)))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint32Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(p)))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint64Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, e.ptrToUint64(p))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndUint64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, e.ptrToUint64(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndFloat32Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(p))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndFloat64Ptr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
v := e.ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = encodeFloat64(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringPtr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(p))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNoEscapedString(b, e.ptrToString(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndBoolPtr:
|
|
|
|
b = append(b, code.key...)
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := e.ptrToPtr(ptr + code.offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = encodeNull(b)
|
|
|
|
} else {
|
|
|
|
b = encodeBool(b, e.ptrToBool(p))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, e.ptrToBytes(ptr+code.offset))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, buf.Bytes()...)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyInt8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt8(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyInt16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt16(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyInt32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt32(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, int64(v))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyInt64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToInt64(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendInt(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyUint:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyUint8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint8(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyUint16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint16(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyUint32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint32(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, uint64(v))
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyUint64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToUint64(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = appendUint(b, v)
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat32(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat32(b, v)
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if v != 0 {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
}
|
2020-12-29 17:17:39 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToString(ptr + code.offset)
|
|
|
|
if v != "" {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToBool(ptr + code.offset)
|
|
|
|
if v {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeBool(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
|
|
|
case opStructEndOmitEmptyBytes:
|
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
|
|
|
if len(v) > 0 {
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeByteSlice(b, v)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if v != nil {
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, buf.Bytes()...)
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndOmitEmptyMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
2021-01-10 23:16:37 +03:00
|
|
|
if v != nil {
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
2020-12-29 17:17:39 +03:00
|
|
|
}
|
|
|
|
b = appendStructEnd(b)
|
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagInt8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagInt16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagInt32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, int64(e.ptrToInt32(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagInt64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, e.ptrToInt64(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagUint:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagUint8:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint8(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagUint16:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint16(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagUint32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, uint64(e.ptrToUint32(ptr+code.offset)))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagUint64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendUint(b, uint64(e.ptrToUint64(ptr+code.offset)))
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagFloat32:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat32(b, e.ptrToFloat32(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagFloat64:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
v := e.ptrToFloat64(ptr + code.offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagString:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
s := e.ptrToString(ptr + code.offset)
|
|
|
|
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagBool:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
b = append(b, code.key...)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = encodeBool(b, e.ptrToBool(ptr+code.offset))
|
|
|
|
b = append(b, '"')
|
2021-01-10 23:16:37 +03:00
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagBytes:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
2021-01-10 23:16:37 +03:00
|
|
|
v := e.ptrToBytes(ptr + code.offset)
|
2020-12-29 17:17:39 +03:00
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeByteSlice(b, v)
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagMarshalJSON:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
bb, err := v.(Marshaler).MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, code.key...)
|
2021-01-10 23:16:37 +03:00
|
|
|
b = encodeNoEscapedString(b, buf.String())
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2021-01-10 23:16:37 +03:00
|
|
|
case opStructEndStringTagMarshalText:
|
2020-12-29 17:17:39 +03:00
|
|
|
ptr := load(ctxptr, code.headIdx)
|
|
|
|
p := ptr + code.offset
|
|
|
|
v := e.ptrToInterface(code, p)
|
|
|
|
bytes, err := v.(encoding.TextMarshaler).MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errMarshaler(code, err)
|
|
|
|
}
|
2021-01-10 23:16:37 +03:00
|
|
|
b = append(b, code.key...)
|
|
|
|
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
|
|
|
b = appendStructEnd(b)
|
2020-12-29 17:17:39 +03:00
|
|
|
code = code.next
|
2020-04-29 18:31:50 +03:00
|
|
|
case opEnd:
|
|
|
|
goto END
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END:
|
2020-12-19 16:40:03 +03:00
|
|
|
return b, nil
|
2020-04-29 18:31:50 +03:00
|
|
|
}
|
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)),
|
|
|
|
}))
|
|
|
|
}
|