From c6f40ed5467b3bc85dd9d26991b8287abf791d24 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sun, 28 Feb 2021 23:22:46 +0900 Subject: [PATCH] Remove only operation and add indirect property to opcode --- cmd/generator/main.go | 12 +- cover_int_test.go | 4 +- encode_compile.go | 76 +- encode_opcode.go | 4 +- encode_optype.go | 12 +- encode_vm.go | 1333 +++----------------------------- encode_vm_escaped.go | 1317 +++----------------------------- encode_vm_escaped_indent.go | 1443 +++------------------------------- encode_vm_indent.go | 1444 +++-------------------------------- rtype.go | 4 + 10 files changed, 456 insertions(+), 5193 deletions(-) diff --git a/cmd/generator/main.go b/cmd/generator/main.go index 92d9044..c9a19ed 100644 --- a/cmd/generator/main.go +++ b/cmd/generator/main.go @@ -163,7 +163,7 @@ func (t opType) headToPtrHead() opType { } suffix := "Ptr"+t.String()[idx+len("Field"):] - const toPtrOffset = 12 + const toPtrOffset = 6 if strings.Contains(opType(int(t) + toPtrOffset).String(), suffix) { return opType(int(t) + toPtrOffset) } @@ -184,7 +184,7 @@ func (t opType) headToNPtrHead() opType { } suffix := "NPtr"+t.String()[idx+len("Field"):] - const toPtrOffset = 24 + const toPtrOffset = 12 if strings.Contains(opType(int(t) + toPtrOffset).String(), suffix) { return opType(int(t) + toPtrOffset) } @@ -192,7 +192,7 @@ func (t opType) headToNPtrHead() opType { } func (t opType) headToAnonymousHead() opType { - const toAnonymousOffset = 6 + const toAnonymousOffset = 3 if strings.Contains(opType(int(t) + toAnonymousOffset).String(), "Anonymous") { return opType(int(t) + toAnonymousOffset) } @@ -200,7 +200,7 @@ func (t opType) headToAnonymousHead() opType { } func (t opType) headToOmitEmptyHead() opType { - const toOmitEmptyOffset = 2 + const toOmitEmptyOffset = 1 if strings.Contains(opType(int(t) + toOmitEmptyOffset).String(), "OmitEmpty") { return opType(int(t) + toOmitEmptyOffset) } @@ -209,7 +209,7 @@ func (t opType) headToOmitEmptyHead() opType { } func (t opType) headToStringTagHead() opType { - const toStringTagOffset = 4 + const toStringTagOffset = 2 if strings.Contains(opType(int(t) + toStringTagOffset).String(), "StringTag") { return opType(int(t) + toStringTagOffset) } @@ -223,7 +223,7 @@ func (t opType) ptrHeadToHead() opType { } suffix := t.String()[idx+len("Ptr"):] - const toPtrOffset = 12 + const toPtrOffset = 6 if strings.Contains(opType(int(t) - toPtrOffset).String(), suffix) { return opType(int(t) - toPtrOffset) } diff --git a/cover_int_test.go b/cover_int_test.go index 282e8bb..0154d7f 100644 --- a/cover_int_test.go +++ b/cover_int_test.go @@ -1774,11 +1774,11 @@ func TestCoverInt(t *testing.T) { enc.SetIndent("", " ") } if err := enc.Encode(test.data); err != nil { - t.Fatalf("%s(htmlEscape:%T): %+v: %s", test.name, htmlEscape, test.data, err) + t.Fatalf("%s(htmlEscape:%v,indent:%v): %+v: %s", test.name, htmlEscape, indent, test.data, err) } stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape) if buf.String() != stdresult { - t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String()) + t.Errorf("%s(htmlEscape:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String()) } } } diff --git a/encode_compile.go b/encode_compile.go index 474cabf..04e8a76 100644 --- a/encode_compile.go +++ b/encode_compile.go @@ -96,7 +96,9 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) { if err != nil { return nil, err } - encodeConvertHeadOnlyCode(code, isPtr) + if !code.indirect && isPtr { + code.indirect = true + } encodeOptimizeStructEnd(code) encodeLinkRecursiveCode(code) return code, nil @@ -105,11 +107,13 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) { } else if isPtr && typ.Implements(marshalJSONType) { typ = orgType } - code, err := encodeCompile(ctx.withType(typ)) + code, err := encodeCompile(ctx.withType(typ), isPtr) if err != nil { return nil, err } - encodeConvertHeadOnlyCode(code, isPtr) + if !code.indirect && isPtr { + code.indirect = true + } encodeOptimizeStructEnd(code) encodeLinkRecursiveCode(code) return code, nil @@ -200,55 +204,6 @@ func encodeOptimizeStructEnd(c *opcode) { } } -func encodeConvertHeadOnlyCode(c *opcode, isPtrHead bool) { - if c.nextField == nil { - return - } - if c.nextField.op.codeType() != codeStructEnd { - return - } - switch c.op { - case opStructFieldHead: - encodeConvertHeadOnlyCode(c.next, false) - if !strings.Contains(c.next.op.String(), "Only") { - return - } - c.op = opStructFieldHeadOnly - case opStructFieldHeadOmitEmpty: - encodeConvertHeadOnlyCode(c.next, false) - if !strings.Contains(c.next.op.String(), "Only") { - return - } - c.op = opStructFieldHeadOmitEmptyOnly - case opStructFieldHeadStringTag: - encodeConvertHeadOnlyCode(c.next, false) - if !strings.Contains(c.next.op.String(), "Only") { - return - } - c.op = opStructFieldHeadStringTagOnly - case opStructFieldPtrHead: - } - - if strings.Contains(c.op.String(), "Marshal") { - return - } - if strings.Contains(c.op.String(), "Slice") { - return - } - if strings.Contains(c.op.String(), "Map") { - return - } - - isPtrOp := strings.Contains(c.op.String(), "Ptr") - if isPtrOp && !isPtrHead { - c.op = c.op.headToOnlyHead() - } else if !isPtrOp && isPtrHead { - c.op = c.op.headToPtrHead().headToOnlyHead() - } else if isPtrOp && isPtrHead { - c.op = c.op.headToPtrHead().headToOnlyHead() - } -} - func encodeImplementsMarshaler(typ *rtype) bool { switch { case typ.Implements(marshalJSONType): @@ -263,7 +218,7 @@ func encodeImplementsMarshaler(typ *rtype) bool { return false } -func encodeCompile(ctx *encodeCompileContext) (*opcode, error) { +func encodeCompile(ctx *encodeCompileContext, isPtr bool) (*opcode, error) { typ := ctx.typ switch { case typ.Implements(marshalJSONType): @@ -289,7 +244,7 @@ func encodeCompile(ctx *encodeCompileContext) (*opcode, error) { case reflect.Map: return encodeCompileMap(ctx, true) case reflect.Struct: - return encodeCompileStruct(ctx, false) + return encodeCompileStruct(ctx, isPtr) case reflect.Interface: return encodeCompileInterface(ctx) case reflect.Int: @@ -371,7 +326,7 @@ func encodeCompilePtr(ctx *encodeCompileContext) (*opcode, error) { ptrOpcodeIndex := ctx.opcodeIndex ptrIndex := ctx.ptrIndex ctx.incIndex() - code, err := encodeCompile(ctx.withType(ctx.typ.Elem())) + code, err := encodeCompile(ctx.withType(ctx.typ.Elem()), true) if err != nil { return nil, err } @@ -642,7 +597,7 @@ func encodeCompileSlice(ctx *encodeCompileContext) (*opcode, error) { header := newSliceHeaderCode(ctx) ctx.incIndex() - code, err := encodeCompile(ctx.withType(ctx.typ.Elem()).incIndent()) + code, err := encodeCompile(ctx.withType(ctx.typ.Elem()).incIndent(), false) if err != nil { return nil, err } @@ -676,7 +631,7 @@ func encodeCompileArray(ctx *encodeCompileContext) (*opcode, error) { header := newArrayHeaderCode(ctx, alen) ctx.incIndex() - code, err := encodeCompile(ctx.withType(elem).incIndent()) + code, err := encodeCompile(ctx.withType(elem).incIndent(), false) if err != nil { return nil, err } @@ -734,7 +689,7 @@ func encodeCompileMap(ctx *encodeCompileContext, withLoad bool) (*opcode, error) ctx.incIndex() valueType := typ.Elem() - valueCode, err := encodeCompile(ctx.withType(valueType)) + valueCode, err := encodeCompile(ctx.withType(valueType), false) if err != nil { return nil, err } @@ -1227,6 +1182,7 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) // ^ | // |__________| fieldNum := typ.NumField() + indirect := ifaceIndir(typ) fieldIdx := 0 var ( head *opcode @@ -1258,7 +1214,7 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) fieldOpcodeIndex := ctx.opcodeIndex fieldPtrIndex := ctx.ptrIndex ctx.incIndex() - valueCode, err := encodeCompile(ctx.withType(fieldType)) + valueCode, err := encodeCompile(ctx.withType(fieldType), false) if err != nil { return nil, err } @@ -1280,6 +1236,7 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) } key := fmt.Sprintf(`"%s":`, tag.key) escapedKey := fmt.Sprintf(`%s:`, string(encodeEscapedString([]byte{}, tag.key))) + valueCode.indirect = indirect fieldCode := &opcode{ typ: valueCode.typ, displayIdx: fieldOpcodeIndex, @@ -1292,6 +1249,7 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) isTaggedKey: tag.isTaggedKey, displayKey: tag.key, offset: field.Offset, + indirect: indirect, } if fieldIdx == 0 { fieldCode.headIdx = fieldCode.idx diff --git a/encode_opcode.go b/encode_opcode.go index e1a9c49..cfb98d5 100644 --- a/encode_opcode.go +++ b/encode_opcode.go @@ -19,11 +19,10 @@ type opcode struct { isTaggedKey bool // whether tagged key anonymousKey bool // whether anonymous key root bool // whether root + indirect bool // whether indirect or not rshiftNum uint8 // use to take bit for judging whether negative integer or not mask uint64 // mask for number indent int // indent number - rshiftNum uint8 // use to take bit for judging whether negative integer or not - mask uint64 // mask for number idx uintptr // offset to access ptr headIdx uintptr // offset to access slice/struct head @@ -93,6 +92,7 @@ func (c *opcode) copy(codeMap map[uintptr]*opcode) *opcode { isTaggedKey: c.isTaggedKey, anonymousKey: c.anonymousKey, root: c.root, + indirect: c.indirect, indent: c.indent, idx: c.idx, headIdx: c.headIdx, diff --git a/encode_optype.go b/encode_optype.go index 90216d8..4ca52dd 100644 --- a/encode_optype.go +++ b/encode_optype.go @@ -1722,7 +1722,7 @@ func (t opType) headToPtrHead() opType { } suffix := "Ptr" + t.String()[idx+len("Field"):] - const toPtrOffset = 12 + const toPtrOffset = 6 if strings.Contains(opType(int(t)+toPtrOffset).String(), suffix) { return opType(int(t) + toPtrOffset) } @@ -1743,7 +1743,7 @@ func (t opType) headToNPtrHead() opType { } suffix := "NPtr" + t.String()[idx+len("Field"):] - const toPtrOffset = 24 + const toPtrOffset = 12 if strings.Contains(opType(int(t)+toPtrOffset).String(), suffix) { return opType(int(t) + toPtrOffset) } @@ -1751,7 +1751,7 @@ func (t opType) headToNPtrHead() opType { } func (t opType) headToAnonymousHead() opType { - const toAnonymousOffset = 6 + const toAnonymousOffset = 3 if strings.Contains(opType(int(t)+toAnonymousOffset).String(), "Anonymous") { return opType(int(t) + toAnonymousOffset) } @@ -1759,7 +1759,7 @@ func (t opType) headToAnonymousHead() opType { } func (t opType) headToOmitEmptyHead() opType { - const toOmitEmptyOffset = 2 + const toOmitEmptyOffset = 1 if strings.Contains(opType(int(t)+toOmitEmptyOffset).String(), "OmitEmpty") { return opType(int(t) + toOmitEmptyOffset) } @@ -1768,7 +1768,7 @@ func (t opType) headToOmitEmptyHead() opType { } func (t opType) headToStringTagHead() opType { - const toStringTagOffset = 4 + const toStringTagOffset = 2 if strings.Contains(opType(int(t)+toStringTagOffset).String(), "StringTag") { return opType(int(t) + toStringTagOffset) } @@ -1782,7 +1782,7 @@ func (t opType) ptrHeadToHead() opType { } suffix := t.String()[idx+len("Ptr"):] - const toPtrOffset = 12 + const toPtrOffset = 6 if strings.Contains(opType(int(t)-toPtrOffset).String(), suffix) { return opType(int(t) - toPtrOffset) } diff --git a/encode_vm.go b/encode_vm.go index faf1c73..b5356e7 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -509,7 +509,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco fallthrough case opStructFieldHead: ptr := load(ctxptr, code.idx) - if ptr == 0 { + if ptr == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -530,7 +530,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco fallthrough case opStructFieldHeadOmitEmpty: ptr := load(ctxptr, code.idx) - if ptr == 0 { + if ptr == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -545,27 +545,24 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco store(ctxptr, code.idx, p) } } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: + case opStructFieldPtrHeadStringTag: ptr := load(ctxptr, code.idx) - b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.key...) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) } - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldHeadOmitEmptyOnly: + fallthrough + case opStructFieldHeadStringTag: ptr := load(ctxptr, code.idx) - b = append(b, '{') - if !code.anonymousKey { - if ptr != 0 { - b = append(b, code.key...) - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } + if ptr == 0 && code.indirect { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + p := ptr + code.offset + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) } case opStructFieldAnonymousHead: ptr := load(ctxptr, code.idx) @@ -596,7 +593,9 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } } case opStructFieldPtrHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadInt: ptr := load(ctxptr, code.idx) @@ -612,9 +611,8 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.next } case opStructFieldPtrHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadOmitEmptyInt: @@ -637,9 +635,8 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } } case opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadStringTagInt: @@ -657,39 +654,19 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = appendInt(b, ptrToUint64(p), code) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = append(b, code.key...) - b = appendInt(b, u64, code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -697,7 +674,9 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, '{') b = append(b, code.key...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -707,17 +686,26 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next } else { b = append(b, '{') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = append(b, code.key...) b = appendInt(b, ptrToUint64(p), code) @@ -726,11 +714,18 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.next } case opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringTagIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -738,7 +733,9 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, '{') b = append(b, code.key...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -749,69 +746,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyIntPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.key...) - b = appendInt(b, ptrToUint64(p), code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadIntNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -834,30 +768,31 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + p := load(ctxptr, code.idx) + if p == 0 { code = code.end.next } else { b = append(b, code.key...) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) + b = appendInt(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) code = code.next } case opStructFieldPtrAnonymousHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldAnonymousHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + p := load(ctxptr, code.idx) + if p == 0 { code = code.end.next } else { - u64 := ptrToUint64(ptr + code.offset) + u64 := ptrToUint64(p + code.offset) v := u64 & code.mask if v == 0 { code = code.nextField @@ -869,72 +804,40 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } } case opStructFieldPtrAnonymousHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldAnonymousHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + p := load(ctxptr, code.idx) + if p == 0 { code = code.end.next } else { b = append(b, code.key...) b = append(b, '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = appendInt(b, u64, code) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = append(b, '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) + b = appendInt(b, ptrToUint64(p+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next } case opStructFieldPtrAnonymousHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + code = code.end.next + break + } b = append(b, code.key...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -943,15 +846,22 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } - p = ptrToPtr(p + code.offset) + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { code = code.nextField } else { @@ -961,16 +871,23 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.next } case opStructFieldPtrAnonymousHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadStringTagIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + code = code.end.next + break + } b = append(b, code.key...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -980,62 +897,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadUint: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1098,33 +959,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p), code) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = append(b, code.key...) - b = appendUint(b, u64, code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1190,69 +1024,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyUintPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadUintNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1327,44 +1098,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadUintOnly, opStructFieldAnonymousHeadUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyUintOnly, opStructFieldAnonymousHeadOmitEmptyUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = appendUint(b, u64, code) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagUintOnly, opStructFieldAnonymousHeadStringTagUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1421,62 +1154,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat32: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1538,32 +1215,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = encodeFloat32(b, ptrToFloat32(p)) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToFloat32(p) - if v != 0 { - b = append(b, code.key...) - b = encodeFloat32(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1629,69 +1280,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat32PtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.key...) - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadFloat32NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1765,43 +1353,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat32Only, opStructFieldAnonymousHeadFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Only, opStructFieldAnonymousHeadOmitEmptyFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeFloat32(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat32Only, opStructFieldAnonymousHeadStringTagFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1858,62 +1409,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat64: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1986,43 +1481,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToFloat64(p) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, code.key...) - b = encodeFloat64(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2100,81 +1558,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.key...) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadFloat64NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2264,55 +1647,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat64Only, opStructFieldAnonymousHeadFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Only, opStructFieldAnonymousHeadOmitEmptyFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat64Only, opStructFieldAnonymousHeadStringTagFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = append(b, '"') - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2381,74 +1715,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadString: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2509,30 +1775,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = encodeNoEscapedString(b, ptrToString(p)) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToString(p) - if v != "" { - b = append(b, code.key...) - b = encodeNoEscapedString(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2596,67 +1838,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyStringPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.key...) - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeComma(b) - code = code.next case opStructFieldHeadStringNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2728,41 +1909,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadStringOnly, opStructFieldAnonymousHeadStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = encodeNoEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyStringOnly, opStructFieldAnonymousHeadOmitEmptyStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToString(ptr + code.offset) - if v == "" { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeNoEscapedString(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagStringOnly, opStructFieldAnonymousHeadStringTagStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(ptr)))) - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2817,60 +1963,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadBool: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2932,32 +2024,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = encodeBool(b, ptrToBool(p)) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToBool(p) - if v { - b = append(b, code.key...) - b = encodeBool(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(p)) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2971,7 +2037,9 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, '{') b = append(b, code.key...) - p = ptrToPtr(p) + if code.indirect { + p = ptrToPtr(p) + } if p == 0 { b = encodeNull(b) } else { @@ -3023,69 +2091,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBoolPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.key...) - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadBoolNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -3159,43 +2164,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBool(ptr + code.offset) - if v { - b = append(b, code.key...) - b = encodeBool(b, v) - b = encodeComma(b) - code = code.next - } else { - code = code.nextField - } - } - case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3252,62 +2220,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadBytes: p := load(ctxptr, code.idx) if p == 0 { @@ -3779,25 +2691,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.next } } - case opStructFieldPtrHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p := ptr + code.offset - b = append(b, code.key...) - code = code.next - store(ctxptr, code.idx, p) - } case opStructFieldPtrAnonymousHeadStringTag: ptr := load(ctxptr, code.idx) if ptr != 0 { diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index 2c2c6d0..8248dde 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -451,7 +451,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o fallthrough case opStructFieldHead: ptr := load(ctxptr, code.idx) - if ptr == 0 { + if ptr == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -472,7 +472,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o fallthrough case opStructFieldHeadOmitEmpty: ptr := load(ctxptr, code.idx) - if ptr == 0 { + if ptr == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -487,25 +487,24 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o store(ctxptr, code.idx, p) } } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.escapedKey...) + case opStructFieldPtrHeadStringTag: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) } - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldHeadOmitEmptyOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - if !code.anonymousKey { - if p != 0 { - b = append(b, code.escapedKey...) - code = code.next - store(ctxptr, code.idx, p) - } else { - code = code.nextField - } + fallthrough + case opStructFieldHeadStringTag: + ptr := load(ctxptr, code.idx) + if ptr == 0 && code.indirect { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + p := ptr + code.offset + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) } case opStructFieldAnonymousHead: ptr := load(ctxptr, code.idx) @@ -536,7 +535,9 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } } case opStructFieldPtrHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadInt: ptr := load(ctxptr, code.idx) @@ -552,9 +553,8 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next } case opStructFieldPtrHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadOmitEmptyInt: @@ -577,9 +577,8 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } } case opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadStringTagInt: @@ -597,39 +596,19 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(p), code) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = append(b, code.escapedKey...) - b = appendInt(b, u64, code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -637,7 +616,9 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, '{') b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -647,17 +628,26 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next } else { b = append(b, '{') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = append(b, code.escapedKey...) b = appendInt(b, ptrToUint64(p), code) @@ -666,11 +656,18 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next } case opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringTagIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeComma(b) code = code.end.next @@ -678,7 +675,9 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, '{') b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -689,69 +688,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyIntPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(p), code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadIntNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -774,7 +710,9 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadInt: ptr := load(ctxptr, code.idx) @@ -787,9 +725,8 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next } case opStructFieldPtrAnonymousHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldAnonymousHeadOmitEmptyInt: @@ -809,9 +746,8 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } } case opStructFieldPtrAnonymousHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldAnonymousHeadStringTagInt: @@ -826,55 +762,24 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = appendInt(b, u64, code) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = append(b, '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadIntPtr: + p := load(ctxptr, code.idx) + if code.indirect && p == 0 { + code = code.end.next + break + } b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -883,15 +788,22 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } - p = ptrToPtr(p + code.offset) + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { code = code.nextField } else { @@ -901,16 +813,23 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next } case opStructFieldPtrAnonymousHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadStringTagIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + code = code.end.next + break + } b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -920,62 +839,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadUint: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1038,33 +901,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p), code) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = append(b, code.escapedKey...) - b = appendUint(b, u64, code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1130,69 +966,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyUintPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadUintNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1267,44 +1040,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadUintOnly, opStructFieldAnonymousHeadUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyUintOnly, opStructFieldAnonymousHeadOmitEmptyUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = appendUint(b, u64, code) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagUintOnly, opStructFieldAnonymousHeadStringTagUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1361,62 +1096,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p+code.offset), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset), code) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat32: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1478,32 +1157,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeFloat32(b, ptrToFloat32(p)) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToFloat32(p) - if v != 0 { - b = append(b, code.escapedKey...) - b = encodeFloat32(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1569,69 +1222,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat32PtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.escapedKey...) - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadFloat32NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1705,43 +1295,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat32Only, opStructFieldAnonymousHeadFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Only, opStructFieldAnonymousHeadOmitEmptyFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeFloat32(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat32Only, opStructFieldAnonymousHeadStringTagFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1798,62 +1351,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat64: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1926,43 +1423,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToFloat64(p) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, code.escapedKey...) - b = encodeFloat64(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2040,81 +1500,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.escapedKey...) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadFloat64NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2204,55 +1589,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat64Only, opStructFieldAnonymousHeadFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Only, opStructFieldAnonymousHeadOmitEmptyFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat64Only, opStructFieldAnonymousHeadStringTagFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = append(b, '"') - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2321,74 +1657,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadString: p := load(ctxptr, code.idx) if p == 0 { @@ -2456,30 +1724,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, ptrToString(p+code.offset)) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToString(p) - if v != "" { - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2543,67 +1787,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyStringPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, ptrToString(p+code.offset)) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeComma(b) - code = code.next case opStructFieldHeadStringNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2675,41 +1858,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadStringOnly, opStructFieldAnonymousHeadStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyStringOnly, opStructFieldAnonymousHeadOmitEmptyStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToString(ptr + code.offset) - if v == "" { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagStringOnly, opStructFieldAnonymousHeadStringTagStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(ptr)))) - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2764,60 +1912,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, ptrToString(p+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadBool: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2879,32 +1973,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(p)) - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToBool(p) - if v { - b = append(b, code.escapedKey...) - b = encodeBool(b, v) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(p)) - b = append(b, '"') - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2918,7 +1986,9 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, '{') b = append(b, code.escapedKey...) - p = ptrToPtr(p) + if code.indirect { + p = ptrToPtr(p) + } if p == 0 { b = encodeNull(b) } else { @@ -2970,69 +2040,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBoolPtrOnly: - b = append(b, '{') - p := load(ctxptr, code.idx) - if p != 0 { - b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldHeadBoolNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -3106,43 +2113,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBool(ptr + code.offset) - if v { - b = append(b, code.escapedKey...) - b = encodeBool(b, v) - b = encodeComma(b) - code = code.next - } else { - code = code.nextField - } - } - case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3199,62 +2169,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeComma(b) - code = code.next case opStructFieldPtrHeadBytes: p := load(ctxptr, code.idx) if p == 0 { @@ -3722,25 +2636,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next } } - case opStructFieldPtrHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p := ptr + code.offset - b = append(b, code.escapedKey...) - code = code.next - store(ctxptr, code.idx, p) - } case opStructFieldPtrAnonymousHeadStringTag: ptr := load(ctxptr, code.idx) if ptr != 0 { diff --git a/encode_vm_escaped_indent.go b/encode_vm_escaped_indent.go index 0a24438..36bd418 100644 --- a/encode_vm_escaped_indent.go +++ b/encode_vm_escaped_indent.go @@ -492,7 +492,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode fallthrough case opStructFieldHead: ptr := load(ctxptr, code.idx) - if ptr == 0 { + if ptr == 0 && code.indirect { b = appendIndent(ctx, b, code.indent) b = encodeNull(b) b = encodeIndentComma(b) @@ -522,8 +522,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode fallthrough case opStructFieldHeadOmitEmpty: ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) + if ptr == 0 && code.indirect { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -541,32 +540,31 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode store(ctxptr, code.idx, p) } } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: + case opStructFieldPtrHeadStringTag: ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) } - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldHeadOmitEmptyOnly: + fallthrough + case opStructFieldHeadStringTag: ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey && ptr != 0 { + if ptr == 0 && code.indirect { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + p := ptr + code.offset b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - p := ptr + code.offset code = code.next store(ctxptr, code.idx, p) - } else { - code = code.nextField } case opStructFieldPtrHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadInt: ptr := load(ctxptr, code.idx) @@ -584,9 +582,8 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.next } case opStructFieldPtrHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadOmitEmptyInt: @@ -611,9 +608,8 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } } case opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadStringTagInt: @@ -632,44 +628,19 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -679,7 +650,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -689,17 +662,26 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next } else { b = append(b, '{', '\n') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) @@ -710,11 +692,18 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.next } case opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringTagIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -724,7 +713,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -735,75 +726,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadIntNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -828,7 +750,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadInt: ptr := load(ctxptr, code.idx) @@ -843,7 +767,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.next } case opStructFieldPtrAnonymousHeadOmitEmptyInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadOmitEmptyInt: ptr := load(ctxptr, code.idx) @@ -864,7 +790,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } } case opStructFieldPtrAnonymousHeadStringTagInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadStringTagInt: ptr := load(ctxptr, code.idx) @@ -880,63 +808,26 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - b = appendInt(b, ptrToUint64(ptr), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldAnonymousHeadIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { code = code.end.next break } b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -945,15 +836,22 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } - p = ptrToPtr(p + code.offset) + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { code = code.nextField } else { @@ -965,80 +863,25 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.next } case opStructFieldPtrAnonymousHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldAnonymousHeadStringTagIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { code = code.end.next break } b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') + if code.indirect { + p = ptrToPtr(p + code.offset) } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') if p == 0 { b = encodeNull(b) } else { @@ -1115,38 +958,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1218,75 +1029,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadUintNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1363,50 +1105,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadUintOnly, opStructFieldAnonymousHeadUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyUintOnly, opStructFieldAnonymousHeadOmitEmptyUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagUintOnly, opStructFieldAnonymousHeadStringTagUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1469,68 +1167,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat32: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1597,37 +1233,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat32(p) - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1699,75 +1304,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadFloat32NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1843,49 +1379,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat32Only, opStructFieldAnonymousHeadFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Only, opStructFieldAnonymousHeadOmitEmptyFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat32Only, opStructFieldAnonymousHeadStringTagFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1948,68 +1441,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat64: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2087,48 +1518,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2212,87 +1601,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadFloat64NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2383,61 +1691,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat64Only, opStructFieldAnonymousHeadFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Only, opStructFieldAnonymousHeadOmitEmptyFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat64Only, opStructFieldAnonymousHeadStringTagFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2512,80 +1765,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadString: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2652,36 +1831,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(p)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToString(p) - if v != "" { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2751,73 +1900,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(p+code.offset)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p+code.offset)))) - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadStringNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2891,47 +1973,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadStringOnly, opStructFieldAnonymousHeadStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyStringOnly, opStructFieldAnonymousHeadOmitEmptyStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToString(ptr + code.offset) - if v == "" { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagStringOnly, opStructFieldAnonymousHeadStringTagStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(ptr+code.offset)))) - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2992,66 +2033,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p+code.offset)))) - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadBool: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3118,37 +2099,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToBool(p) - if v { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(p)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3164,7 +2114,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - p = ptrToPtr(p) + if code.indirect { + p = ptrToPtr(p) + } if p == 0 { b = encodeNull(b) } else { @@ -3220,75 +2172,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadBoolNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -3364,49 +2247,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBool(ptr + code.offset) - if v { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - code = code.next - } else { - code = code.nextField - } - } - case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3469,68 +2309,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadBytes: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3579,27 +2357,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.next } } - case opStructFieldPtrHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p := ptr + code.offset - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } case opStructFieldPtrHeadStringTagBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { diff --git a/encode_vm_indent.go b/encode_vm_indent.go index a05bc9e..f15abc1 100644 --- a/encode_vm_indent.go +++ b/encode_vm_indent.go @@ -492,8 +492,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op fallthrough case opStructFieldHead: ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) + if ptr == 0 && code.indirect { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -522,8 +521,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op fallthrough case opStructFieldHeadOmitEmpty: ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) + if ptr == 0 && code.indirect { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -541,32 +539,31 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op store(ctxptr, code.idx, p) } } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: + case opStructFieldPtrHeadStringTag: ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) } - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - case opStructFieldHeadOmitEmptyOnly: + fallthrough + case opStructFieldHeadStringTag: ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey && ptr != 0 { + if ptr == 0 && code.indirect { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + p := ptr + code.offset b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - p := ptr + code.offset code = code.next store(ctxptr, code.idx, p) - } else { - code = code.nextField } case opStructFieldPtrHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadInt: ptr := load(ctxptr, code.idx) @@ -584,9 +581,8 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.next } case opStructFieldPtrHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadOmitEmptyInt: @@ -611,9 +607,8 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } } case opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough case opStructFieldHeadStringTagInt: @@ -632,44 +627,19 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -679,7 +649,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -689,17 +661,26 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next } else { b = append(b, '{', '\n') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) @@ -710,11 +691,18 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.next } case opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringTagIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -724,7 +712,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -735,75 +725,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadIntNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -828,7 +749,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadInt: ptr := load(ctxptr, code.idx) @@ -843,7 +766,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.next } case opStructFieldPtrAnonymousHeadOmitEmptyInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadOmitEmptyInt: ptr := load(ctxptr, code.idx) @@ -864,7 +789,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } } case opStructFieldPtrAnonymousHeadStringTagInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldAnonymousHeadStringTagInt: ptr := load(ctxptr, code.idx) @@ -880,63 +807,26 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - b = appendInt(b, ptrToUint64(ptr), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldAnonymousHeadIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { code = code.end.next break } b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -945,15 +835,22 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { code = code.end.next break } - p = ptrToPtr(p + code.offset) + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { code = code.nextField } else { @@ -965,80 +862,25 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.next } case opStructFieldPtrAnonymousHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldAnonymousHeadStringTagIntPtr: p := load(ctxptr, code.idx) - if p == 0 { + if p == 0 && code.indirect { code = code.end.next break } b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') + if code.indirect { + p = ptrToPtr(p + code.offset) } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadIntPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagIntPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') if p == 0 { b = encodeNull(b) } else { @@ -1115,38 +957,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - u64 := ptrToUint64(p) - v := u64 & code.mask - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1218,75 +1028,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadUintNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1363,50 +1104,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadUintOnly, opStructFieldAnonymousHeadUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyUintOnly, opStructFieldAnonymousHeadOmitEmptyUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - u64 := ptrToUint64(ptr) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, u64, code) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagUintOnly, opStructFieldAnonymousHeadStringTagUintOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadUintPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1469,68 +1166,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadUintPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(p), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat32: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1597,37 +1232,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat32(p) - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(p)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1699,75 +1303,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadFloat32NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -1843,49 +1378,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat32Only, opStructFieldAnonymousHeadFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Only, opStructFieldAnonymousHeadOmitEmptyFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat32Only, opStructFieldAnonymousHeadStringTagFloat32Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat32Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -1948,68 +1440,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat64: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2087,48 +1517,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2212,87 +1600,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadFloat64NPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2383,61 +1690,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadFloat64Only, opStructFieldAnonymousHeadFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64Only, opStructFieldAnonymousHeadOmitEmptyFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat64Only, opStructFieldAnonymousHeadStringTagFloat64Only: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadFloat64Ptr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2512,80 +1764,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64PtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = encodeFloat64(b, v) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadString: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2652,36 +1830,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToString(p) - if v != "" { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2751,73 +1899,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p+code.offset)))) - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadStringNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -2891,47 +1972,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadStringOnly, opStructFieldAnonymousHeadStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyStringOnly, opStructFieldAnonymousHeadOmitEmptyStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToString(ptr + code.offset) - if v == "" { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagStringOnly, opStructFieldAnonymousHeadStringTagStringOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(ptr+code.offset)))) - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadStringPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -2992,66 +2032,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p+code.offset)))) - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadBool: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3118,37 +2098,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToBool(p) - if v { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(p)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3164,7 +2113,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - p = ptrToPtr(p) + if code.indirect { + p = ptrToPtr(p) + } if p == 0 { b = encodeNull(b) } else { @@ -3220,75 +2171,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeIndentComma(b) - } - code = code.next - case opStructFieldPtrHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldHeadBoolNPtr: p := load(ctxptr, code.idx) if p == 0 { @@ -3364,49 +2246,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBool(ptr + code.offset) - if v { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - code = code.next - } else { - code = code.nextField - } - } - case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrAnonymousHeadBoolPtr: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3469,68 +2308,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtrOnly: - p := load(ctxptr, code.idx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = encodeBool(b, ptrToBool(p+code.offset)) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next case opStructFieldPtrHeadBytes: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -3579,27 +2356,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.next } } - case opStructFieldPtrHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p := ptr + code.offset - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } case opStructFieldPtrHeadStringTagBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { diff --git a/rtype.go b/rtype.go index a4cbf73..e505528 100644 --- a/rtype.go +++ b/rtype.go @@ -244,6 +244,10 @@ func (t *rtype) Out(i int) reflect.Type { return rtype_Out(t, i) } +//go:linkname ifaceIndir reflect.ifaceIndir +//go:noescape +func ifaceIndir(*rtype) bool + //go:linkname rtype2type reflect.toType //go:noescape func rtype2type(t *rtype) reflect.Type