forked from mirror/go-json
parent
8aded2b62d
commit
02fb2b9de7
87
encode_vm.go
87
encode_vm.go
|
@ -748,64 +748,67 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case opStructFieldPtrHeadInt:
|
case opStructFieldPtrHeadInt:
|
||||||
p := ptrToPtr(load(ctxptr, code.idx))
|
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||||
if p == 0 {
|
|
||||||
b = encodeNull(b)
|
|
||||||
b = encodeComma(b)
|
|
||||||
code = code.end.next
|
|
||||||
break
|
|
||||||
}
|
|
||||||
store(ctxptr, code.idx, p)
|
|
||||||
fallthrough
|
fallthrough
|
||||||
case opStructFieldHeadInt:
|
case opStructFieldHeadInt:
|
||||||
p := load(ctxptr, code.idx) + code.offset
|
ptr := load(ctxptr, code.idx)
|
||||||
b = append(b, '{')
|
if ptr == 0 {
|
||||||
b = append(b, code.key...)
|
|
||||||
b = appendInt(b, ptrToUint64(p), code)
|
|
||||||
b = encodeComma(b)
|
|
||||||
code = code.next
|
|
||||||
case opStructFieldPtrHeadOmitEmptyInt:
|
|
||||||
p := ptrToPtr(load(ctxptr, code.idx))
|
|
||||||
if p == 0 {
|
|
||||||
b = encodeNull(b)
|
b = encodeNull(b)
|
||||||
b = encodeComma(b)
|
b = encodeComma(b)
|
||||||
code = code.end.next
|
code = code.end.next
|
||||||
break
|
|
||||||
}
|
|
||||||
store(ctxptr, code.idx, p)
|
|
||||||
fallthrough
|
|
||||||
case opStructFieldHeadOmitEmptyInt:
|
|
||||||
p := load(ctxptr, code.idx) + code.offset
|
|
||||||
b = append(b, '{')
|
|
||||||
u64 := ptrToUint64(p)
|
|
||||||
v := u64 & code.mask
|
|
||||||
if v == 0 {
|
|
||||||
code = code.nextField
|
|
||||||
} else {
|
} else {
|
||||||
|
b = append(b, '{')
|
||||||
b = append(b, code.key...)
|
b = append(b, code.key...)
|
||||||
b = appendInt(b, u64, code)
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
||||||
b = encodeComma(b)
|
b = encodeComma(b)
|
||||||
code = code.next
|
code = code.next
|
||||||
}
|
}
|
||||||
case opStructFieldPtrHeadStringTagInt:
|
case opStructFieldPtrHeadOmitEmptyInt:
|
||||||
p := ptrToPtr(load(ctxptr, code.idx))
|
ptr := load(ctxptr, code.idx)
|
||||||
if p == 0 {
|
if ptr != 0 {
|
||||||
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
|
case opStructFieldHeadOmitEmptyInt:
|
||||||
|
ptr := load(ctxptr, code.idx)
|
||||||
|
if ptr == 0 {
|
||||||
b = encodeNull(b)
|
b = encodeNull(b)
|
||||||
b = encodeComma(b)
|
b = encodeComma(b)
|
||||||
code = code.end.next
|
code = code.end.next
|
||||||
break
|
} else {
|
||||||
|
b = append(b, '{')
|
||||||
|
u64 := ptrToUint64(ptr + code.offset)
|
||||||
|
v := u64 & code.mask
|
||||||
|
if v == 0 {
|
||||||
|
code = code.nextField
|
||||||
|
} else {
|
||||||
|
b = append(b, code.key...)
|
||||||
|
b = appendInt(b, u64, code)
|
||||||
|
b = encodeComma(b)
|
||||||
|
code = code.next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case opStructFieldPtrHeadStringTagInt:
|
||||||
|
ptr := load(ctxptr, code.idx)
|
||||||
|
if ptr != 0 {
|
||||||
|
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||||
}
|
}
|
||||||
store(ctxptr, code.idx, p)
|
|
||||||
fallthrough
|
fallthrough
|
||||||
case opStructFieldHeadStringTagInt:
|
case opStructFieldHeadStringTagInt:
|
||||||
p := load(ctxptr, code.idx) + code.offset
|
ptr := load(ctxptr, code.idx)
|
||||||
b = append(b, '{')
|
if ptr == 0 {
|
||||||
b = append(b, code.key...)
|
b = encodeNull(b)
|
||||||
b = append(b, '"')
|
b = encodeComma(b)
|
||||||
b = appendInt(b, ptrToUint64(p), code)
|
code = code.end.next
|
||||||
b = append(b, '"')
|
} else {
|
||||||
b = encodeComma(b)
|
b = append(b, '{')
|
||||||
code = code.next
|
b = append(b, code.key...)
|
||||||
|
b = append(b, '"')
|
||||||
|
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
||||||
|
b = append(b, '"')
|
||||||
|
b = encodeComma(b)
|
||||||
|
code = code.next
|
||||||
|
}
|
||||||
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
||||||
p := load(ctxptr, code.idx)
|
p := load(ctxptr, code.idx)
|
||||||
b = append(b, '{')
|
b = append(b, '{')
|
||||||
|
|
Loading…
Reference in New Issue