mirror of https://github.com/goccy/go-json.git
Fix interface
This commit is contained in:
parent
ef70c61783
commit
ee36bdedb6
|
@ -189,40 +189,46 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcod
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c, err := e.compileHead(&encodeCompileContext{
|
ifaceCodeSet, err := e.compileToGetCodeSet(uintptr(unsafe.Pointer(header.typ)))
|
||||||
typ: header.typ,
|
|
||||||
root: code.root,
|
|
||||||
indent: code.indent,
|
|
||||||
structTypeToCompiledCode: map[uintptr]*compiledCode{},
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
beforeLastCode := c.beforeLastCode()
|
/*
|
||||||
lastCode := beforeLastCode.next
|
totalLength := uintptr(codeSet.codeLength)
|
||||||
lastCode.idx = beforeLastCode.idx + uintptrSize
|
nextTotalLength := uintptr(ifaceCodeSet.codeLength)
|
||||||
totalLength := uintptr(code.totalLength())
|
|
||||||
nextTotalLength := uintptr(c.totalLength())
|
|
||||||
curlen := uintptr(len(ctx.ptrs))
|
curlen := uintptr(len(ctx.ptrs))
|
||||||
offsetNum := ptrOffset / uintptrSize
|
offsetNum := ptrOffset / uintptrSize
|
||||||
oldOffset := ptrOffset
|
|
||||||
ptrOffset += totalLength * uintptrSize
|
ptrOffset += totalLength * uintptrSize
|
||||||
|
|
||||||
newLen := offsetNum + totalLength + nextTotalLength
|
newLen := offsetNum + totalLength + nextTotalLength
|
||||||
if curlen < newLen {
|
if curlen < newLen {
|
||||||
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
||||||
}
|
}
|
||||||
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
|
*/
|
||||||
|
|
||||||
store(ctxptr, 0, uintptr(header.ptr))
|
newCtx := &encodeRuntimeContext{
|
||||||
store(ctxptr, lastCode.idx, oldOffset)
|
ptrs: make([]uintptr, ifaceCodeSet.codeLength),
|
||||||
|
keepRefs: ctx.keepRefs,
|
||||||
|
seenPtr: ctx.seenPtr,
|
||||||
|
}
|
||||||
|
newCtx.ptrs[0] = uintptr(header.ptr)
|
||||||
|
//newPtrs := ctx.ptrs[ptrOffset/uintptrSize:]
|
||||||
|
//newPtrs[0] = uintptr(header.ptr)
|
||||||
|
|
||||||
// link lastCode ( opInterfaceEnd ) => code.next
|
//oldPtrs := ctx.ptrs
|
||||||
lastCode.op = opInterfaceEnd
|
//ctx.ptrs = newPtrs
|
||||||
lastCode.next = code.next
|
bb, err := e.runEscaped(newCtx, b, ifaceCodeSet)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ctx.keepRefs = newCtx.keepRefs
|
||||||
|
ctx.seenPtr = newCtx.seenPtr
|
||||||
|
//ctx.ptrs = oldPtrs
|
||||||
|
//ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
|
||||||
|
|
||||||
code = c
|
b = bb
|
||||||
recursiveLevel++
|
code = code.next
|
||||||
case opInterfaceEnd:
|
case opInterfaceEnd:
|
||||||
recursiveLevel--
|
recursiveLevel--
|
||||||
// restore ctxptr
|
// restore ctxptr
|
||||||
|
|
Loading…
Reference in New Issue