mirror of https://github.com/goccy/go-json.git
Fix index number
This commit is contained in:
parent
18a6e4cffe
commit
4f4060f808
|
@ -954,7 +954,7 @@ func (e *Encoder) compileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode,
|
||||||
}
|
}
|
||||||
|
|
||||||
structEndCode.displayIdx = ctx.opcodeIndex
|
structEndCode.displayIdx = ctx.opcodeIndex
|
||||||
structEndCode.idx = opcodeOffset(ctx.opcodeIndex)
|
structEndCode.idx = opcodeOffset(ctx.ptrIndex)
|
||||||
ctx.incIndex()
|
ctx.incIndex()
|
||||||
|
|
||||||
if ctx.withIndent {
|
if ctx.withIndent {
|
||||||
|
|
|
@ -95,6 +95,18 @@ func (c *opcode) decOpcodeIndex() {
|
||||||
for code := c; code.op != opEnd; {
|
for code := c; code.op != opEnd; {
|
||||||
code.displayIdx--
|
code.displayIdx--
|
||||||
code.idx -= uintptrSize
|
code.idx -= uintptrSize
|
||||||
|
if code.headIdx > 0 {
|
||||||
|
code.headIdx -= uintptrSize
|
||||||
|
}
|
||||||
|
if code.elemIdx > 0 {
|
||||||
|
code.elemIdx -= uintptrSize
|
||||||
|
}
|
||||||
|
if code.mapIter > 0 {
|
||||||
|
code.mapIter -= uintptrSize
|
||||||
|
}
|
||||||
|
if code.length > 0 && code.op.codeType() != codeArrayHead && code.op.codeType() != codeArrayElem {
|
||||||
|
code.length -= uintptrSize
|
||||||
|
}
|
||||||
switch code.op.codeType() {
|
switch code.op.codeType() {
|
||||||
case codeArrayElem, codeSliceElem, codeMapKey:
|
case codeArrayElem, codeSliceElem, codeMapKey:
|
||||||
code = code.end
|
code = code.end
|
||||||
|
@ -106,7 +118,7 @@ func (c *opcode) decOpcodeIndex() {
|
||||||
|
|
||||||
func (c *opcode) dumpHead(code *opcode) string {
|
func (c *opcode) dumpHead(code *opcode) string {
|
||||||
var length uintptr
|
var length uintptr
|
||||||
if code.op.codeType() == codeArrayElem {
|
if code.op.codeType() == codeArrayHead {
|
||||||
length = code.length
|
length = code.length
|
||||||
} else {
|
} else {
|
||||||
length = code.length / uintptrSize
|
length = code.length / uintptrSize
|
||||||
|
@ -382,12 +394,3 @@ func newRecursiveCode(ctx *encodeCompileContext, jmp *compiledCode) *opcode {
|
||||||
jmp: jmp,
|
jmp: jmp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//func newRecursiveCode(recursive *recursiveCode) *opcode {
|
|
||||||
//code := copyOpcode(recursive.jmp.code)
|
|
||||||
//head := (*structFieldCode)(unsafe.Pointer(code))
|
|
||||||
//head.end.next = newEndOp(&encodeCompileContext{})
|
|
||||||
|
|
||||||
//code.op = code.op.ptrHeadToHead()
|
|
||||||
// return code
|
|
||||||
//}
|
|
||||||
|
|
Loading…
Reference in New Issue