From 8aded2b62dc0b0a796f94705e5f02183e3102b26 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Tue, 23 Feb 2021 16:07:04 +0900 Subject: [PATCH] Add NPtr operation --- encode_vm_escaped_indent.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/encode_vm_escaped_indent.go b/encode_vm_escaped_indent.go index 364a47d..548aa6c 100644 --- a/encode_vm_escaped_indent.go +++ b/encode_vm_escaped_indent.go @@ -3844,6 +3844,24 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) 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: ptr := load(ctxptr, code.headIdx) p := ptrToPtr(ptr + code.offset) @@ -4597,6 +4615,24 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = appendStructEndIndent(ctx, b, code.indent-1) 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: ptr := load(ctxptr, code.headIdx) p := ptrToPtr(ptr + code.offset)