From 413c811e37088839c18aefdfc609543cdcd0115f Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Fri, 19 Feb 2021 03:34:21 +0900 Subject: [PATCH] WIP: workaround --- encode_compile.go | 2 -- encode_vm_escaped.go | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/encode_compile.go b/encode_compile.go index 58b289a..8262d91 100644 --- a/encode_compile.go +++ b/encode_compile.go @@ -104,8 +104,6 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) { typ = orgType } else if isPtr && typ.Implements(marshalJSONType) { typ = orgType - } else if isPtr && isIntOrUintType(typ) { - //typ = orgType } code, err := encodeCompile(ctx.withType(typ)) if err != nil { diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index 7bac7f0..a06e0b8 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -29,7 +29,12 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o case opInt: p := load(ctxptr, code.idx) u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, (u64>>code.rshiftNum)&1 == 1) + if (u64>>code.rshiftNum)&1 == 1 { + v := ^u64&code.mask + 1 + b = appendInt(b, -v, true) + } else { + b = appendInt(b, u64&code.mask, (u64>>code.rshiftNum)&1 == 1) + } b = encodeComma(b) code = code.next case opUint: