mirror of https://github.com/goccy/go-json.git
Add NPtr operation
This commit is contained in:
parent
52b2bf1089
commit
8aded2b62d
|
@ -3844,6 +3844,24 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
|
||||||
}
|
}
|
||||||
b = encodeIndentComma(b)
|
b = encodeIndentComma(b)
|
||||||
code = code.next
|
code = code.next
|
||||||
|
case opStructFieldIntNPtr:
|
||||||
|
b = appendIndent(ctx, b, code.indent)
|
||||||
|
b = append(b, code.escapedKey...)
|
||||||
|
b = append(b, ' ')
|
||||||
|
p := load(ctxptr, code.headIdx) + code.offset
|
||||||
|
for i := 0; i < code.ptrNum; i++ {
|
||||||
|
if p == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
p = ptrToPtr(p)
|
||||||
|
}
|
||||||
|
if p == 0 {
|
||||||
|
b = encodeNull(b)
|
||||||
|
} else {
|
||||||
|
b = appendInt(b, ptrToUint64(p), code)
|
||||||
|
}
|
||||||
|
b = encodeIndentComma(b)
|
||||||
|
code = code.next
|
||||||
case opStructFieldOmitEmptyIntPtr:
|
case opStructFieldOmitEmptyIntPtr:
|
||||||
ptr := load(ctxptr, code.headIdx)
|
ptr := load(ctxptr, code.headIdx)
|
||||||
p := ptrToPtr(ptr + code.offset)
|
p := ptrToPtr(ptr + code.offset)
|
||||||
|
@ -4597,6 +4615,24 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
|
||||||
}
|
}
|
||||||
b = appendStructEndIndent(ctx, b, code.indent-1)
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
||||||
code = code.next
|
code = code.next
|
||||||
|
case opStructEndIntNPtr:
|
||||||
|
b = appendIndent(ctx, b, code.indent)
|
||||||
|
b = append(b, code.escapedKey...)
|
||||||
|
b = append(b, ' ')
|
||||||
|
p := load(ctxptr, code.headIdx) + code.offset
|
||||||
|
for i := 0; i < code.ptrNum; i++ {
|
||||||
|
if p == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
p = ptrToPtr(p)
|
||||||
|
}
|
||||||
|
if p == 0 {
|
||||||
|
b = encodeNull(b)
|
||||||
|
} else {
|
||||||
|
b = appendInt(b, ptrToUint64(p), code)
|
||||||
|
}
|
||||||
|
b = appendStructEndIndent(ctx, b, code.indent-1)
|
||||||
|
code = code.next
|
||||||
case opStructEndOmitEmptyIntPtr:
|
case opStructEndOmitEmptyIntPtr:
|
||||||
ptr := load(ctxptr, code.headIdx)
|
ptr := load(ctxptr, code.headIdx)
|
||||||
p := ptrToPtr(ptr + code.offset)
|
p := ptrToPtr(ptr + code.offset)
|
||||||
|
|
Loading…
Reference in New Issue