mirror of https://github.com/goccy/go-json.git
Merge pull request #132 from goccy/feature/add-opcode-for-ptr-field
Add pointer-type StructField operations to the encoder
This commit is contained in:
commit
cbe680fc5b
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,7 @@ func uint64ptr(v uint64) *uint64 { return &v }
|
|||
func float32ptr(v float32) *float32 { return &v }
|
||||
func float64ptr(v float64) *float64 { return &v }
|
||||
func stringptr(v string) *string { return &v }
|
||||
func boolptr(v bool) *bool { return &v }
|
||||
|
||||
func encodeByEncodingJSON(data interface{}, indent, escape bool) string {
|
||||
var buf bytes.Buffer
|
||||
|
|
1200
cover_int16_test.go
1200
cover_int16_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_int32_test.go
1200
cover_int32_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_int64_test.go
1200
cover_int64_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_int8_test.go
1200
cover_int8_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_int_test.go
1200
cover_int_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_uint16_test.go
1200
cover_uint16_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_uint32_test.go
1200
cover_uint32_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_uint64_test.go
1200
cover_uint64_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_uint8_test.go
1200
cover_uint8_test.go
File diff suppressed because it is too large
Load Diff
1200
cover_uint_test.go
1200
cover_uint_test.go
File diff suppressed because it is too large
Load Diff
854
encode_vm.go
854
encode_vm.go
|
@ -6449,6 +6449,158 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadBool:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadBool:
|
||||
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 = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
v := ptrToBool(ptr + code.offset)
|
||||
if v {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, v)
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
} else {
|
||||
code = code.nextField
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagBool:
|
||||
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 = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
v := ptrToBool(p)
|
||||
if v {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, v)
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadBoolPtr:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadBoolPtr:
|
||||
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 = ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
}
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyBoolPtr:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyBoolPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
p = ptrToPtr(p)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagBoolPtr:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagBoolPtr:
|
||||
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 = ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
b = append(b, '"')
|
||||
}
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
|
@ -6458,24 +6610,18 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
store(ctxptr, code.idx, ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
if code.op == opStructFieldPtrHeadBool {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
} else {
|
||||
b = append(b, '{', '}', ',')
|
||||
}
|
||||
code = code.end.next
|
||||
} else {
|
||||
case opStructFieldHeadBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadBoolOnly:
|
||||
case opStructFieldPtrHeadOmitEmptyBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
|
@ -6483,12 +6629,59 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadBoolOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
case opStructFieldHeadOmitEmptyBoolPtrOnly:
|
||||
b = append(b, '{')
|
||||
p := load(ctxptr, code.idx)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldHeadBoolNPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
for i := 0; i < code.ptrNum; i++ {
|
||||
if p == 0 {
|
||||
break
|
||||
}
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
}
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadBool:
|
||||
|
@ -6504,6 +6697,194 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := ptrToBool(ptr + code.offset)
|
||||
if v {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, v)
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
} else {
|
||||
code = code.nextField
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := ptrToBool(ptr + code.offset)
|
||||
if v {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, v)
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
} else {
|
||||
code = code.nextField
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadBoolPtr:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadBoolPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
b = append(b, code.key...)
|
||||
p = ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyBoolPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
p = ptrToPtr(p)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagBoolPtr:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagBoolPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
b = append(b, code.key...)
|
||||
p = ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagBoolPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(p+code.offset))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadBytes:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -6770,51 +7151,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
v := 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
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := 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
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyBytes:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -7054,45 +7390,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, ptr+code.offset)
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagBool:
|
||||
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 = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagBool:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(ptr+code.offset))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagBytes:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -7328,6 +7625,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyIntPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(ptrToInt(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagIntPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldIntNPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
|
@ -7379,6 +7698,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyInt8Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(ptrToInt8(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagInt8Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(ptrToInt8(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldInt16:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7413,6 +7754,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyInt16Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(ptrToInt16(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagInt16Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(ptrToInt16(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldInt32:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7447,6 +7810,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyInt32Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(ptrToInt32(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagInt32Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(ptrToInt32(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldInt64:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7481,6 +7866,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyInt64Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, ptrToInt64(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagInt64Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToInt64(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldUint:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7515,6 +7922,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyUintPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendUint(b, uint64(ptrToUint(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagUintPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendUint(b, uint64(ptrToUint(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldUint8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7549,6 +7978,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyUint8Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendUint(b, uint64(ptrToUint8(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagUint8Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendUint(b, uint64(ptrToUint8(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldUint16:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7583,6 +8034,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyUint16Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendUint(b, uint64(ptrToUint16(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagUint16Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendUint(b, uint64(ptrToUint16(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldUint32:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7617,6 +8090,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyUint32Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendUint(b, uint64(ptrToUint32(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagUint32Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendUint(b, uint64(ptrToUint32(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldUint64:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7651,6 +8146,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyUint64Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendUint(b, ptrToUint64(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagUint64Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldFloat32:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7685,6 +8202,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyFloat32Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = encodeFloat32(b, ptrToFloat32(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagFloat32Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = encodeFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldFloat64:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7736,6 +8275,36 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
b = encodeFloat64(b, v)
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyFloat64Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
v := 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 opStructFieldStringTagFloat64Ptr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
v := ptrToFloat64(p)
|
||||
if math.IsInf(v, 0) || math.IsNaN(v) {
|
||||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = append(b, '"')
|
||||
b = encodeFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldString:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7823,6 +8392,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyBoolPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagBoolPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldBytes:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -7845,6 +8436,37 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
b = encodeByteSlice(b, v)
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldBytesPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeByteSlice(b, ptrToBytes(p))
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyBytesPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = encodeByteSlice(b, ptrToBytes(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagBytesPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeByteSlice(b, ptrToBytes(p))
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldMarshalJSON:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
@ -9257,6 +9879,36 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyBoolPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = appendStructEnd(b)
|
||||
} else {
|
||||
last := len(b) - 1
|
||||
if b[last] == ',' {
|
||||
b[last] = '}'
|
||||
b = encodeComma(b)
|
||||
} else {
|
||||
b = appendStructEnd(b)
|
||||
}
|
||||
}
|
||||
code = code.next
|
||||
case opStructEndStringTagBoolPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = encodeBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndBytes:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1179
encode_vm_indent.go
1179
encode_vm_indent.go
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue