diff --git a/cmd/generator/main.go b/cmd/generator/main.go index 48357a8..6c3d7e0 100644 --- a/cmd/generator/main.go +++ b/cmd/generator/main.go @@ -15,11 +15,8 @@ type opType struct { Op string Code string HeadToPtrHead func() string - HeadToNPtrHead func() string - HeadToAnonymousHead func() string HeadToOmitEmptyHead func() string HeadToStringTagHead func() string - HeadToOnlyHead func() string PtrHeadToHead func() string FieldToEnd func() string FieldToOmitEmptyField func() string @@ -30,14 +27,6 @@ func (t opType) IsHeadToPtrHead() bool { return t.Op != t.HeadToPtrHead() } -func (t opType) IsHeadToNPtrHead() bool { - return t.Op != t.HeadToNPtrHead() -} - -func (t opType) IsHeadToAnonymousHead() bool { - return t.Op != t.HeadToAnonymousHead() -} - func (t opType) IsHeadToOmitEmptyHead() bool { return t.Op != t.HeadToOmitEmptyHead() } @@ -50,10 +39,6 @@ func (t opType) IsPtrHeadToHead() bool { return t.Op != t.PtrHeadToHead() } -func (t opType) IsHeadToOnlyHead() bool { - return t.Op != t.HeadToOnlyHead() -} - func (t opType) IsFieldToEnd() bool { return t.Op != t.FieldToEnd() } @@ -71,11 +56,8 @@ func createOpType(op, code string) opType { Op: op, Code: code, HeadToPtrHead: func() string { return op }, - HeadToNPtrHead: func() string { return op }, - HeadToAnonymousHead: func() string { return op }, HeadToOmitEmptyHead: func() string { return op }, HeadToStringTagHead: func() string { return op }, - HeadToOnlyHead: func() string { return op }, PtrHeadToHead: func() string { return op }, FieldToEnd: func() string { return op }, FieldToOmitEmptyField: func() string { return op }, @@ -127,19 +109,19 @@ func (t opType) codeType() codeType { } return codeStructField } - if strings.Contains(t.String(), "ArrayHead") { + if t.String() == "Array" || t.String() == "ArrayPtr" { return codeArrayHead } if strings.Contains(t.String(), "ArrayElem") { return codeArrayElem } - if strings.Contains(t.String(), "SliceHead") { + if t.String() == "Slice" || t.String() == "SlicePtr" { return codeSliceHead } if strings.Contains(t.String(), "SliceElem") { return codeSliceElem } - if strings.Contains(t.String(), "MapHead") { + if t.String() == "Map" || t.String() == "MapPtr" { return codeMapHead } if strings.Contains(t.String(), "MapKey") { @@ -159,9 +141,6 @@ func (t opType) headToPtrHead() opType { if strings.Index(t.String(), "PtrHead") > 0 { return t } - if strings.Index(t.String(), "PtrAnonymousHead") > 0 { - return t - } idx := strings.Index(t.String(), "Field") if idx == -1 { @@ -169,44 +148,15 @@ func (t opType) headToPtrHead() opType { } suffix := "Ptr"+t.String()[idx+len("Field"):] - const toPtrOffset = 12 + const toPtrOffset = 3 if strings.Contains(opType(int(t) + toPtrOffset).String(), suffix) { return opType(int(t) + toPtrOffset) } return t } -func (t opType) headToNPtrHead() opType { - if strings.Index(t.String(), "PtrHead") > 0 { - return t - } - if strings.Index(t.String(), "PtrAnonymousHead") > 0 { - return t - } - - idx := strings.Index(t.String(), "Field") - if idx == -1 { - return t - } - suffix := "NPtr"+t.String()[idx+len("Field"):] - - const toPtrOffset = 24 - if strings.Contains(opType(int(t) + toPtrOffset).String(), suffix) { - return opType(int(t) + toPtrOffset) - } - return t -} - -func (t opType) headToAnonymousHead() opType { - const toAnonymousOffset = 6 - if strings.Contains(opType(int(t) + toAnonymousOffset).String(), "Anonymous") { - return opType(int(t) + toAnonymousOffset) - } - return t -} - 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) } @@ -215,25 +165,13 @@ 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) } return t } -func (t opType) headToOnlyHead() opType { - if strings.HasSuffix(t.String(), "Head") || strings.HasSuffix(t.String(), "HeadOmitEmpty") || strings.HasSuffix(t.String(), "HeadStringTag") { - return t - } - - const toOnlyOffset = 1 - if opType(int(t) + toOnlyOffset).String() == t.String() + "Only" { - return opType(int(t) + toOnlyOffset) - } - return t -} - func (t opType) ptrHeadToHead() opType { idx := strings.Index(t.String(), "Ptr") if idx == -1 { @@ -241,7 +179,7 @@ func (t opType) ptrHeadToHead() opType { } suffix := t.String()[idx+len("Ptr"):] - const toPtrOffset = 12 + const toPtrOffset = 3 if strings.Contains(opType(int(t) - toPtrOffset).String(), suffix) { return opType(int(t) - toPtrOffset) } @@ -295,11 +233,11 @@ func (t opType) fieldToStringTagField() opType { "StructEnd", } primitiveTypes := []string{ - "int", "uint", "float32", "float64", "bool", "string", "bytes", - "array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive", + "int", "uint", "float32", "float64", "bool", "string", "bytes", "number", + "array", "map", "slice", "struct", "MarshalJSON", "MarshalText", "recursive", "intString", "uintString", - "intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr", - "intNPtr", "uintNPtr", "float32NPtr", "float64NPtr", "boolNPtr", "stringNPtr", "bytesNPtr", + "intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr", "numberPtr", + "arrayPtr", "mapPtr", "slicePtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr", "recursivePtr", } primitiveTypesUpper := []string{} for _, typ := range primitiveTypes { @@ -309,17 +247,12 @@ func (t opType) fieldToStringTagField() opType { createOpType("End", "Op"), createOpType("Interface", "Op"), createOpType("Ptr", "Op"), - createOpType("NPtr", "Op"), - createOpType("SliceHead", "SliceHead"), createOpType("RootSliceHead", "SliceHead"), createOpType("SliceElem", "SliceElem"), createOpType("RootSliceElem", "SliceElem"), createOpType("SliceEnd", "Op"), - createOpType("ArrayHead", "ArrayHead"), createOpType("ArrayElem", "ArrayElem"), createOpType("ArrayEnd", "Op"), - createOpType("MapHead", "MapHead"), - createOpType("MapHeadLoad", "MapHead"), createOpType("MapKey", "MapKey"), createOpType("MapValue", "MapValue"), createOpType("MapEnd", "Op"), @@ -331,102 +264,53 @@ func (t opType) fieldToStringTagField() opType { opTypes = append(opTypes, createOpType(typ, "Op")) } for _, typ := range append(primitiveTypesUpper, "") { - for _, ptrOrNot := range []string{"", "Ptr", "NPtr"} { - for _, headType := range []string{"", "Anonymous"} { - for _, opt := range []string{"", "OmitEmpty", "StringTag"} { - for _, onlyOrNot := range []string{"", "Only"} { - ptrOrNot := ptrOrNot - headType := headType - opt := opt - typ := typ - onlyOrNot := onlyOrNot + for _, ptrOrNot := range []string{"", "Ptr"} { + for _, opt := range []string{"", "OmitEmpty", "StringTag"} { + ptrOrNot := ptrOrNot + opt := opt + typ := typ - op := fmt.Sprintf( - "StructField%s%sHead%s%s%s", - ptrOrNot, - headType, + op := fmt.Sprintf( + "StructField%sHead%s%s", + ptrOrNot, + opt, + typ, + ) + opTypes = append(opTypes, opType{ + Op: op, + Code: "StructField", + HeadToPtrHead: func() string { + return fmt.Sprintf( + "StructFieldPtrHead%s%s", opt, typ, - onlyOrNot, ) - opTypes = append(opTypes, opType{ - Op: op, - Code: "StructField", - HeadToPtrHead: func() string { - return fmt.Sprintf( - "StructFieldPtr%sHead%s%s%s", - headType, - opt, - typ, - onlyOrNot, - ) - }, - HeadToNPtrHead: func() string { - return fmt.Sprintf( - "StructFieldNPtr%sHead%s%s%s", - headType, - opt, - typ, - onlyOrNot, - ) - }, - HeadToAnonymousHead: func() string { - return fmt.Sprintf( - "StructField%sAnonymousHead%s%s%s", - ptrOrNot, - opt, - typ, - onlyOrNot, - ) - }, - HeadToOmitEmptyHead: func() string { - return fmt.Sprintf( - "StructField%s%sHeadOmitEmpty%s%s", - ptrOrNot, - headType, - typ, - onlyOrNot, - ) - }, - HeadToStringTagHead: func() string { - return fmt.Sprintf( - "StructField%s%sHeadStringTag%s%s", - ptrOrNot, - headType, - typ, - onlyOrNot, - ) - }, - HeadToOnlyHead: func() string { - switch typ { - case "", "Array", "Map", "MapLoad", "Slice", - "Struct", "Recursive", "MarshalJSON", "MarshalText", - "IntString", "UintString": - return op - } - return fmt.Sprintf( - "StructField%s%sHead%s%sOnly", - ptrOrNot, - headType, - opt, - typ, - ) - }, - PtrHeadToHead: func() string { - return fmt.Sprintf( - "StructField%sHead%s%s%s", - headType, - opt, - typ, - onlyOrNot, - ) - }, - FieldToEnd: func() string { return op }, - FieldToOmitEmptyField: func() string { return op }, - FieldToStringTagField: func() string { return op }, - }) - } - } + }, + HeadToOmitEmptyHead: func() string { + return fmt.Sprintf( + "StructField%sHeadOmitEmpty%s", + ptrOrNot, + typ, + ) + }, + HeadToStringTagHead: func() string { + return fmt.Sprintf( + "StructField%sHeadStringTag%s", + ptrOrNot, + typ, + ) + }, + PtrHeadToHead: func() string { + return fmt.Sprintf( + "StructFieldHead%s%s", + opt, + typ, + ) + }, + FieldToEnd: func() string { return op }, + FieldToOmitEmptyField: func() string { return op }, + FieldToStringTagField: func() string { return op }, + }) } } } @@ -444,15 +328,12 @@ func (t opType) fieldToStringTagField() opType { Op: op, Code: "StructField", HeadToPtrHead: func() string { return op }, - HeadToNPtrHead: func() string { return op }, - HeadToAnonymousHead: func() string { return op }, HeadToOmitEmptyHead: func() string { return op }, HeadToStringTagHead: func() string { return op }, - HeadToOnlyHead: func() string { return op }, PtrHeadToHead: func() string { return op }, FieldToEnd: func() string { switch typ { - case "", "Array", "Map", "MapLoad", "Slice", "Struct", "Recursive": + case "", "Array", "Map", "Slice", "Struct", "Recursive": return op } return fmt.Sprintf( @@ -490,11 +371,8 @@ func (t opType) fieldToStringTagField() opType { Op: op, Code: "StructEnd", HeadToPtrHead: func() string { return op }, - HeadToNPtrHead: func() string { return op }, - HeadToAnonymousHead: func() string { return op }, HeadToOmitEmptyHead: func() string { return op }, HeadToStringTagHead: func() string { return op }, - HeadToOnlyHead: func() string { return op }, PtrHeadToHead: func() string { return op }, FieldToEnd: func() string { return op }, FieldToOmitEmptyField: func() string { return op }, diff --git a/compact.go b/compact.go index fa48328..2e568eb 100644 --- a/compact.go +++ b/compact.go @@ -5,6 +5,9 @@ import ( ) func compact(dst *bytes.Buffer, src []byte, escape bool) error { + if len(src) == 0 { + return errUnexpectedEndOfJSON("", 0) + } length := len(src) for cursor := 0; cursor < length; cursor++ { c := src[cursor] diff --git a/cover_array_test.go b/cover_array_test.go new file mode 100644 index 0000000..336ef39 --- /dev/null +++ b/cover_array_test.go @@ -0,0 +1,1859 @@ +package json_test + +import ( + "bytes" + "testing" + + "github.com/goccy/go-json" +) + +func TestCoverArray(t *testing.T) { + type structArray struct { + A [2]int `json:"a"` + } + type structArrayOmitEmpty struct { + A [2]int `json:"a,omitempty"` + } + type structArrayString struct { + A [2]int `json:"a,string"` + } + type structArrayPtr struct { + A *[2]int `json:"a"` + } + type structArrayPtrOmitEmpty struct { + A *[2]int `json:"a,omitempty"` + } + type structArrayPtrString struct { + A *[2]int `json:"a,string"` + } + + type structArrayPtrContent struct { + A [2]*int `json:"a"` + } + type structArrayOmitEmptyPtrContent struct { + A [2]*int `json:"a,omitempty"` + } + type structArrayStringPtrContent struct { + A [2]*int `json:"a,string"` + } + type structArrayPtrPtrContent struct { + A *[2]*int `json:"a"` + } + type structArrayPtrOmitEmptyPtrContent struct { + A *[2]*int `json:"a,omitempty"` + } + type structArrayPtrStringPtrContent struct { + A *[2]*int `json:"a,string"` + } + + tests := []struct { + name string + data interface{} + }{ + // HeadArrayZero + { + name: "HeadArrayZero", + data: struct { + A [2]int `json:"a"` + }{}, + }, + { + name: "HeadArrayZeroOmitEmpty", + data: struct { + A [2]int `json:"a,omitempty"` + }{}, + }, + { + name: "HeadArrayZeroString", + data: struct { + A [2]int `json:"a,string"` + }{}, + }, + + // HeadArray + { + name: "HeadArray", + data: struct { + A [2]int `json:"a"` + }{A: [2]int{-1}}, + }, + { + name: "HeadArrayOmitEmpty", + data: struct { + A [2]int `json:"a,omitempty"` + }{A: [2]int{-1}}, + }, + { + name: "HeadArrayString", + data: struct { + A [2]int `json:"a,string"` + }{A: [2]int{-1}}, + }, + + // HeadArrayPtr + { + name: "HeadArrayPtr", + data: struct { + A *[2]int `json:"a"` + }{A: arrayptr([2]int{-1})}, + }, + { + name: "HeadArrayPtrOmitEmpty", + data: struct { + A *[2]int `json:"a,omitempty"` + }{A: arrayptr([2]int{-1})}, + }, + { + name: "HeadArrayPtrString", + data: struct { + A *[2]int `json:"a,string"` + }{A: arrayptr([2]int{-1})}, + }, + + // HeadArrayPtrNil + { + name: "HeadArrayPtrNil", + data: struct { + A *[2]int `json:"a"` + }{A: nil}, + }, + { + name: "HeadArrayPtrNilOmitEmpty", + data: struct { + A *[2]int `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadArrayPtrNilString", + data: struct { + A *[2]int `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadArrayZero + { + name: "PtrHeadArrayZero", + data: &struct { + A [2]int `json:"a"` + }{}, + }, + { + name: "PtrHeadArrayZeroOmitEmpty", + data: &struct { + A [2]int `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadArrayZeroString", + data: &struct { + A [2]int `json:"a,string"` + }{}, + }, + + // PtrHeadArray + { + name: "PtrHeadArray", + data: &struct { + A [2]int `json:"a"` + }{A: [2]int{-1}}, + }, + { + name: "PtrHeadArrayOmitEmpty", + data: &struct { + A [2]int `json:"a,omitempty"` + }{A: [2]int{-1}}, + }, + { + name: "PtrHeadArrayString", + data: &struct { + A [2]int `json:"a,string"` + }{A: [2]int{-1}}, + }, + + // PtrHeadArrayPtr + { + name: "PtrHeadArrayPtr", + data: &struct { + A *[2]int `json:"a"` + }{A: arrayptr([2]int{-1})}, + }, + { + name: "PtrHeadArrayPtrOmitEmpty", + data: &struct { + A *[2]int `json:"a,omitempty"` + }{A: arrayptr([2]int{-1})}, + }, + { + name: "PtrHeadArrayPtrString", + data: &struct { + A *[2]int `json:"a,string"` + }{A: arrayptr([2]int{-1})}, + }, + + // PtrHeadArrayPtrNil + { + name: "PtrHeadArrayPtrNil", + data: &struct { + A *[2]int `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadArrayPtrNilOmitEmpty", + data: &struct { + A *[2]int `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadArrayPtrNilString", + data: &struct { + A *[2]int `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadArrayNil + { + name: "PtrHeadArrayNil", + data: (*struct { + A *[2]int `json:"a"` + })(nil), + }, + { + name: "PtrHeadArrayNilOmitEmpty", + data: (*struct { + A *[2]int `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadArrayNilString", + data: (*struct { + A *[2]int `json:"a,string"` + })(nil), + }, + + // HeadArrayZeroMultiFields + { + name: "HeadArrayZeroMultiFields", + data: struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + C [2]int `json:"c"` + }{}, + }, + { + name: "HeadArrayZeroMultiFieldsOmitEmpty", + data: struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + C [2]int `json:"c,omitempty"` + }{}, + }, + { + name: "HeadArrayZeroMultiFields", + data: struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + C [2]int `json:"c,string"` + }{}, + }, + + // HeadArrayMultiFields + { + name: "HeadArrayMultiFields", + data: struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + C [2]int `json:"c"` + }{A: [2]int{-1}, B: [2]int{-2}, C: [2]int{-3}}, + }, + { + name: "HeadArrayMultiFieldsOmitEmpty", + data: struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + C [2]int `json:"c,omitempty"` + }{A: [2]int{-1}, B: [2]int{-2}, C: [2]int{-3}}, + }, + { + name: "HeadArrayMultiFieldsString", + data: struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + C [2]int `json:"c,string"` + }{A: [2]int{-1}, B: [2]int{-2}, C: [2]int{-3}}, + }, + + // HeadArrayPtrMultiFields + { + name: "HeadArrayPtrMultiFields", + data: struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + C *[2]int `json:"c"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{-2}), C: arrayptr([2]int{-3})}, + }, + { + name: "HeadArrayPtrMultiFieldsOmitEmpty", + data: struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + C *[2]int `json:"c,omitempty"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{-2}), C: arrayptr([2]int{-3})}, + }, + { + name: "HeadArrayPtrMultiFieldsString", + data: struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + C *[2]int `json:"c,string"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{-2}), C: arrayptr([2]int{-3})}, + }, + + // HeadArrayPtrNilMultiFields + { + name: "HeadArrayPtrNilMultiFields", + data: struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + C *[2]int `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadArrayPtrNilMultiFieldsOmitEmpty", + data: struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + C *[2]int `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadArrayPtrNilMultiFieldsString", + data: struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + C *[2]int `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + + // PtrHeadArrayZeroMultiFields + { + name: "PtrHeadArrayZeroMultiFields", + data: &struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + }{}, + }, + { + name: "PtrHeadArrayZeroMultiFieldsOmitEmpty", + data: &struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadArrayZeroMultiFieldsString", + data: &struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + }{}, + }, + + // PtrHeadArrayMultiFields + { + name: "PtrHeadArrayMultiFields", + data: &struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + }{A: [2]int{-1}, B: [2]int{1}}, + }, + { + name: "PtrHeadArrayMultiFieldsOmitEmpty", + data: &struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + }{A: [2]int{-1}, B: [2]int{1}}, + }, + { + name: "PtrHeadArrayMultiFieldsString", + data: &struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + }{A: [2]int{-1}, B: [2]int{1}}, + }, + + // PtrHeadArrayPtrMultiFields + { + name: "PtrHeadArrayPtrMultiFields", + data: &struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{-2})}, + }, + { + name: "PtrHeadArrayPtrMultiFieldsOmitEmpty", + data: &struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{-2})}, + }, + { + name: "PtrHeadArrayPtrMultiFieldsString", + data: &struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{-2})}, + }, + + // PtrHeadArrayPtrNilMultiFields + { + name: "PtrHeadArrayPtrNilMultiFields", + data: &struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayPtrNilMultiFieldsOmitEmpty", + data: &struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayPtrNilMultiFieldsString", + data: &struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + }{A: nil, B: nil}, + }, + + // PtrHeadArrayNilMultiFields + { + name: "PtrHeadArrayNilMultiFields", + data: (*struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + })(nil), + }, + { + name: "PtrHeadArrayNilMultiFieldsOmitEmpty", + data: (*struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadArrayNilMultiFieldsString", + data: (*struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + })(nil), + }, + + // PtrHeadArrayNilMultiFields + { + name: "PtrHeadArrayNilMultiFields", + data: (*struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + })(nil), + }, + { + name: "PtrHeadArrayNilMultiFieldsOmitEmpty", + data: (*struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadArrayNilMultiFieldsString", + data: (*struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + })(nil), + }, + + // HeadArrayZeroNotRoot + { + name: "HeadArrayZeroNotRoot", + data: struct { + A struct { + A [2]int `json:"a"` + } + }{}, + }, + { + name: "HeadArrayZeroNotRootOmitEmpty", + data: struct { + A struct { + A [2]int `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadArrayZeroNotRootString", + data: struct { + A struct { + A [2]int `json:"a,string"` + } + }{}, + }, + + // HeadArrayNotRoot + { + name: "HeadArrayNotRoot", + data: struct { + A struct { + A [2]int `json:"a"` + } + }{A: struct { + A [2]int `json:"a"` + }{A: [2]int{-1}}}, + }, + { + name: "HeadArrayNotRootOmitEmpty", + data: struct { + A struct { + A [2]int `json:"a,omitempty"` + } + }{A: struct { + A [2]int `json:"a,omitempty"` + }{A: [2]int{-1}}}, + }, + { + name: "HeadArrayNotRootString", + data: struct { + A struct { + A [2]int `json:"a,string"` + } + }{A: struct { + A [2]int `json:"a,string"` + }{A: [2]int{-1}}}, + }, + + // HeadArrayPtrNotRoot + { + name: "HeadArrayPtrNotRoot", + data: struct { + A struct { + A *[2]int `json:"a"` + } + }{A: struct { + A *[2]int `json:"a"` + }{arrayptr([2]int{-1})}}, + }, + { + name: "HeadArrayPtrNotRootOmitEmpty", + data: struct { + A struct { + A *[2]int `json:"a,omitempty"` + } + }{A: struct { + A *[2]int `json:"a,omitempty"` + }{arrayptr([2]int{-1})}}, + }, + { + name: "HeadArrayPtrNotRootString", + data: struct { + A struct { + A *[2]int `json:"a,string"` + } + }{A: struct { + A *[2]int `json:"a,string"` + }{arrayptr([2]int{-1})}}, + }, + + // HeadArrayPtrNilNotRoot + { + name: "HeadArrayPtrNilNotRoot", + data: struct { + A struct { + A *[2]int `json:"a"` + } + }{}, + }, + { + name: "HeadArrayPtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *[2]int `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadArrayPtrNilNotRootString", + data: struct { + A struct { + A *[2]int `json:"a,string"` + } + }{}, + }, + + // PtrHeadArrayZeroNotRoot + { + name: "PtrHeadArrayZeroNotRoot", + data: struct { + A *struct { + A [2]int `json:"a"` + } + }{A: new(struct { + A [2]int `json:"a"` + })}, + }, + { + name: "PtrHeadArrayZeroNotRootOmitEmpty", + data: struct { + A *struct { + A [2]int `json:"a,omitempty"` + } + }{A: new(struct { + A [2]int `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadArrayZeroNotRootString", + data: struct { + A *struct { + A [2]int `json:"a,string"` + } + }{A: new(struct { + A [2]int `json:"a,string"` + })}, + }, + + // PtrHeadArrayNotRoot + { + name: "PtrHeadArrayNotRoot", + data: struct { + A *struct { + A [2]int `json:"a"` + } + }{A: &(struct { + A [2]int `json:"a"` + }{A: [2]int{-1}})}, + }, + { + name: "PtrHeadArrayNotRootOmitEmpty", + data: struct { + A *struct { + A [2]int `json:"a,omitempty"` + } + }{A: &(struct { + A [2]int `json:"a,omitempty"` + }{A: [2]int{-1}})}, + }, + { + name: "PtrHeadArrayNotRootString", + data: struct { + A *struct { + A [2]int `json:"a,string"` + } + }{A: &(struct { + A [2]int `json:"a,string"` + }{A: [2]int{-1}})}, + }, + + // PtrHeadArrayPtrNotRoot + { + name: "PtrHeadArrayPtrNotRoot", + data: struct { + A *struct { + A *[2]int `json:"a"` + } + }{A: &(struct { + A *[2]int `json:"a"` + }{A: arrayptr([2]int{-1})})}, + }, + { + name: "PtrHeadArrayPtrNotRootOmitEmpty", + data: struct { + A *struct { + A *[2]int `json:"a,omitempty"` + } + }{A: &(struct { + A *[2]int `json:"a,omitempty"` + }{A: arrayptr([2]int{-1})})}, + }, + { + name: "PtrHeadArrayPtrNotRootString", + data: struct { + A *struct { + A *[2]int `json:"a,string"` + } + }{A: &(struct { + A *[2]int `json:"a,string"` + }{A: arrayptr([2]int{-1})})}, + }, + + // PtrHeadArrayPtrNilNotRoot + { + name: "PtrHeadArrayPtrNilNotRoot", + data: struct { + A *struct { + A *[2]int `json:"a"` + } + }{A: &(struct { + A *[2]int `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadArrayPtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *[2]int `json:"a,omitempty"` + } + }{A: &(struct { + A *[2]int `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadArrayPtrNilNotRootString", + data: struct { + A *struct { + A *[2]int `json:"a,string"` + } + }{A: &(struct { + A *[2]int `json:"a,string"` + }{A: nil})}, + }, + + // PtrHeadArrayNilNotRoot + { + name: "PtrHeadArrayNilNotRoot", + data: struct { + A *struct { + A *[2]int `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadArrayNilNotRootOmitEmpty", + data: struct { + A *struct { + A *[2]int `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadArrayNilNotRootString", + data: struct { + A *struct { + A *[2]int `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + + // HeadArrayZeroMultiFieldsNotRoot + { + name: "HeadArrayZeroMultiFieldsNotRoot", + data: struct { + A struct { + A [2]int `json:"a"` + } + B struct { + B [2]int `json:"b"` + } + }{}, + }, + { + name: "HeadArrayZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A [2]int `json:"a,omitempty"` + } + B struct { + B [2]int `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadArrayZeroMultiFieldsNotRootString", + data: struct { + A struct { + A [2]int `json:"a,string"` + } + B struct { + B [2]int `json:"b,string"` + } + }{}, + }, + + // HeadArrayMultiFieldsNotRoot + { + name: "HeadArrayMultiFieldsNotRoot", + data: struct { + A struct { + A [2]int `json:"a"` + } + B struct { + B [2]int `json:"b"` + } + }{A: struct { + A [2]int `json:"a"` + }{A: [2]int{-1}}, B: struct { + B [2]int `json:"b"` + }{B: [2]int{0}}}, + }, + { + name: "HeadArrayMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A [2]int `json:"a,omitempty"` + } + B struct { + B [2]int `json:"b,omitempty"` + } + }{A: struct { + A [2]int `json:"a,omitempty"` + }{A: [2]int{-1}}, B: struct { + B [2]int `json:"b,omitempty"` + }{B: [2]int{1}}}, + }, + { + name: "HeadArrayMultiFieldsNotRootString", + data: struct { + A struct { + A [2]int `json:"a,string"` + } + B struct { + B [2]int `json:"b,string"` + } + }{A: struct { + A [2]int `json:"a,string"` + }{A: [2]int{-1}}, B: struct { + B [2]int `json:"b,string"` + }{B: [2]int{1}}}, + }, + + // HeadArrayPtrMultiFieldsNotRoot + { + name: "HeadArrayPtrMultiFieldsNotRoot", + data: struct { + A struct { + A *[2]int `json:"a"` + } + B struct { + B *[2]int `json:"b"` + } + }{A: struct { + A *[2]int `json:"a"` + }{A: arrayptr([2]int{-1})}, B: struct { + B *[2]int `json:"b"` + }{B: arrayptr([2]int{1})}}, + }, + { + name: "HeadArrayPtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *[2]int `json:"a,omitempty"` + } + B struct { + B *[2]int `json:"b,omitempty"` + } + }{A: struct { + A *[2]int `json:"a,omitempty"` + }{A: arrayptr([2]int{-1})}, B: struct { + B *[2]int `json:"b,omitempty"` + }{B: arrayptr([2]int{1})}}, + }, + { + name: "HeadArrayPtrMultiFieldsNotRootString", + data: struct { + A struct { + A *[2]int `json:"a,string"` + } + B struct { + B *[2]int `json:"b,string"` + } + }{A: struct { + A *[2]int `json:"a,string"` + }{A: arrayptr([2]int{-1})}, B: struct { + B *[2]int `json:"b,string"` + }{B: arrayptr([2]int{1})}}, + }, + + // HeadArrayPtrNilMultiFieldsNotRoot + { + name: "HeadArrayPtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *[2]int `json:"a"` + } + B struct { + B *[2]int `json:"b"` + } + }{A: struct { + A *[2]int `json:"a"` + }{A: nil}, B: struct { + B *[2]int `json:"b"` + }{B: nil}}, + }, + { + name: "HeadArrayPtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *[2]int `json:"a,omitempty"` + } + B struct { + B *[2]int `json:"b,omitempty"` + } + }{A: struct { + A *[2]int `json:"a,omitempty"` + }{A: nil}, B: struct { + B *[2]int `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadArrayPtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *[2]int `json:"a,string"` + } + B struct { + B *[2]int `json:"b,string"` + } + }{A: struct { + A *[2]int `json:"a,string"` + }{A: nil}, B: struct { + B *[2]int `json:"b,string"` + }{B: nil}}, + }, + + // PtrHeadArrayZeroMultiFieldsNotRoot + { + name: "PtrHeadArrayZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A [2]int `json:"a"` + } + B struct { + B [2]int `json:"b"` + } + }{}, + }, + { + name: "PtrHeadArrayZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A [2]int `json:"a,omitempty"` + } + B struct { + B [2]int `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadArrayZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A [2]int `json:"a,string"` + } + B struct { + B [2]int `json:"b,string"` + } + }{}, + }, + + // PtrHeadArrayMultiFieldsNotRoot + { + name: "PtrHeadArrayMultiFieldsNotRoot", + data: &struct { + A struct { + A [2]int `json:"a"` + } + B struct { + B [2]int `json:"b"` + } + }{A: struct { + A [2]int `json:"a"` + }{A: [2]int{-1}}, B: struct { + B [2]int `json:"b"` + }{B: [2]int{1}}}, + }, + { + name: "PtrHeadArrayMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A [2]int `json:"a,omitempty"` + } + B struct { + B [2]int `json:"b,omitempty"` + } + }{A: struct { + A [2]int `json:"a,omitempty"` + }{A: [2]int{-1}}, B: struct { + B [2]int `json:"b,omitempty"` + }{B: [2]int{1}}}, + }, + { + name: "PtrHeadArrayMultiFieldsNotRootString", + data: &struct { + A struct { + A [2]int `json:"a,string"` + } + B struct { + B [2]int `json:"b,string"` + } + }{A: struct { + A [2]int `json:"a,string"` + }{A: [2]int{-1}}, B: struct { + B [2]int `json:"b,string"` + }{B: [2]int{1}}}, + }, + + // PtrHeadArrayPtrMultiFieldsNotRoot + { + name: "PtrHeadArrayPtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[2]int `json:"a"` + } + B *struct { + B *[2]int `json:"b"` + } + }{A: &(struct { + A *[2]int `json:"a"` + }{A: arrayptr([2]int{-1})}), B: &(struct { + B *[2]int `json:"b"` + }{B: arrayptr([2]int{1})})}, + }, + { + name: "PtrHeadArrayPtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[2]int `json:"a,omitempty"` + } + B *struct { + B *[2]int `json:"b,omitempty"` + } + }{A: &(struct { + A *[2]int `json:"a,omitempty"` + }{A: arrayptr([2]int{-1})}), B: &(struct { + B *[2]int `json:"b,omitempty"` + }{B: arrayptr([2]int{1})})}, + }, + { + name: "PtrHeadArrayPtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[2]int `json:"a,string"` + } + B *struct { + B *[2]int `json:"b,string"` + } + }{A: &(struct { + A *[2]int `json:"a,string"` + }{A: arrayptr([2]int{-1})}), B: &(struct { + B *[2]int `json:"b,string"` + }{B: arrayptr([2]int{1})})}, + }, + + // PtrHeadArrayPtrNilMultiFieldsNotRoot + { + name: "PtrHeadArrayPtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[2]int `json:"a"` + } + B *struct { + B *[2]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayPtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[2]int `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *[2]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayPtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[2]int `json:"a,string"` + } `json:",string"` + B *struct { + B *[2]int `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + + // PtrHeadArrayNilMultiFieldsNotRoot + { + name: "PtrHeadArrayNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *[2]int `json:"a"` + } + B *struct { + B *[2]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadArrayNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *[2]int `json:"a,omitempty"` + } + B *struct { + B *[2]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadArrayNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *[2]int `json:"a,string"` + } + B *struct { + B *[2]int `json:"b,string"` + } + })(nil), + }, + + // PtrHeadArrayDoubleMultiFieldsNotRoot + { + name: "PtrHeadArrayDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + } + B *struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + } + }{A: &(struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + }{A: [2]int{-1}, B: [2]int{1}}), B: &(struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + }{A: [2]int{-1}, B: [2]int{1}})}, + }, + { + name: "PtrHeadArrayDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + } + B *struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + } + }{A: &(struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + }{A: [2]int{-1}, B: [2]int{1}}), B: &(struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + }{A: [2]int{-1}, B: [2]int{1}})}, + }, + { + name: "PtrHeadArrayDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + } + B *struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + } + }{A: &(struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + }{A: [2]int{-1}, B: [2]int{1}}), B: &(struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + }{A: [2]int{-1}, B: [2]int{1}})}, + }, + + // PtrHeadArrayNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadArrayNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + } + B *struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + } + B *struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadArrayNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadArrayNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + } + B *struct { + A [2]int `json:"a"` + B [2]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadArrayNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + } + B *struct { + A [2]int `json:"a,omitempty"` + B [2]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadArrayNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + } + B *struct { + A [2]int `json:"a,string"` + B [2]int `json:"b,string"` + } + })(nil), + }, + + // PtrHeadArrayPtrDoubleMultiFieldsNotRoot + { + name: "PtrHeadArrayPtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + } + B *struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + } + }{A: &(struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{1})}), B: &(struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadArrayPtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + } + B *struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + } + }{A: &(struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{1})}), B: &(struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadArrayPtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + } + B *struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + } + }{A: &(struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + }{A: arrayptr([2]int{-1}), B: arrayptr([2]int{1})}), B: &(struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + }{A: nil, B: nil})}, + }, + + // PtrHeadArrayPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadArrayPtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + } + B *struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadArrayPtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + } + B *struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadArrayPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadArrayPtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + } + B *struct { + A *[2]int `json:"a"` + B *[2]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadArrayPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + } + B *struct { + A *[2]int `json:"a,omitempty"` + B *[2]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadArrayPtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + } + B *struct { + A *[2]int `json:"a,string"` + B *[2]int `json:"b,string"` + } + })(nil), + }, + + // AnonymousHeadArray + { + name: "AnonymousHeadArray", + data: struct { + structArray + B [2]int `json:"b"` + }{ + structArray: structArray{A: [2]int{-1}}, + B: [2]int{1}, + }, + }, + { + name: "AnonymousHeadArrayOmitEmpty", + data: struct { + structArrayOmitEmpty + B [2]int `json:"b,omitempty"` + }{ + structArrayOmitEmpty: structArrayOmitEmpty{A: [2]int{-1}}, + B: [2]int{1}, + }, + }, + { + name: "AnonymousHeadArrayString", + data: struct { + structArrayString + B [2]int `json:"b,string"` + }{ + structArrayString: structArrayString{A: [2]int{-1}}, + B: [2]int{1}, + }, + }, + + // PtrAnonymousHeadArray + { + name: "PtrAnonymousHeadArray", + data: struct { + *structArray + B [2]int `json:"b"` + }{ + structArray: &structArray{A: [2]int{-1}}, + B: [2]int{1}, + }, + }, + { + name: "PtrAnonymousHeadArrayOmitEmpty", + data: struct { + *structArrayOmitEmpty + B [2]int `json:"b,omitempty"` + }{ + structArrayOmitEmpty: &structArrayOmitEmpty{A: [2]int{-1}}, + B: [2]int{1}, + }, + }, + { + name: "PtrAnonymousHeadArrayString", + data: struct { + *structArrayString + B [2]int `json:"b,string"` + }{ + structArrayString: &structArrayString{A: [2]int{-1}}, + B: [2]int{1}, + }, + }, + + // PtrAnonymousHeadArrayNil + { + name: "PtrAnonymousHeadArrayNil", + data: struct { + *structArray + B [2]int `json:"b"` + }{ + structArray: &structArray{A: [2]int{1}}, + B: [2]int{1}, + }, + }, + { + name: "PtrAnonymousHeadArrayNilOmitEmpty", + data: struct { + *structArrayOmitEmpty + B [2]int `json:"b,omitempty"` + }{ + structArrayOmitEmpty: &structArrayOmitEmpty{A: [2]int{1}}, + B: [2]int{1}, + }, + }, + { + name: "PtrAnonymousHeadArrayNilString", + data: struct { + *structArrayString + B [2]int `json:"b,string"` + }{ + structArrayString: &structArrayString{A: [2]int{1}}, + B: [2]int{1}, + }, + }, + + // NilPtrAnonymousHeadArray + { + name: "NilPtrAnonymousHeadArray", + data: struct { + *structArray + B [2]int `json:"b"` + }{ + structArray: nil, + B: [2]int{-1}, + }, + }, + { + name: "NilPtrAnonymousHeadArrayOmitEmpty", + data: struct { + *structArrayOmitEmpty + B [2]int `json:"b,omitempty"` + }{ + structArrayOmitEmpty: nil, + B: [2]int{-1}, + }, + }, + { + name: "NilPtrAnonymousHeadArrayString", + data: struct { + *structArrayString + B [2]int `json:"b,string"` + }{ + structArrayString: nil, + B: [2]int{-1}, + }, + }, + + // AnonymousHeadArrayPtr + { + name: "AnonymousHeadArrayPtr", + data: struct { + structArrayPtr + B *[2]int `json:"b"` + }{ + structArrayPtr: structArrayPtr{A: arrayptr([2]int{-1})}, + B: nil, + }, + }, + { + name: "AnonymousHeadArrayPtrOmitEmpty", + data: struct { + structArrayPtrOmitEmpty + B *[2]int `json:"b,omitempty"` + }{ + structArrayPtrOmitEmpty: structArrayPtrOmitEmpty{A: arrayptr([2]int{-1})}, + B: nil, + }, + }, + { + name: "AnonymousHeadArrayPtrString", + data: struct { + structArrayPtrString + B *[2]int `json:"b,string"` + }{ + structArrayPtrString: structArrayPtrString{A: arrayptr([2]int{-1})}, + B: nil, + }, + }, + + // AnonymousHeadArrayPtrNil + { + name: "AnonymousHeadArrayPtrNil", + data: struct { + structArrayPtr + B *[2]int `json:"b"` + }{ + structArrayPtr: structArrayPtr{A: nil}, + B: arrayptr([2]int{-1}), + }, + }, + { + name: "AnonymousHeadArrayPtrNilOmitEmpty", + data: struct { + structArrayPtrOmitEmpty + B *[2]int `json:"b,omitempty"` + }{ + structArrayPtrOmitEmpty: structArrayPtrOmitEmpty{A: nil}, + B: arrayptr([2]int{-1}), + }, + }, + { + name: "AnonymousHeadArrayPtrNilString", + data: struct { + structArrayPtrString + B *[2]int `json:"b,string"` + }{ + structArrayPtrString: structArrayPtrString{A: nil}, + B: arrayptr([2]int{-1}), + }, + }, + + // PtrAnonymousHeadArrayPtr + { + name: "PtrAnonymousHeadArrayPtr", + data: struct { + *structArrayPtr + B *[2]int `json:"b"` + }{ + structArrayPtr: &structArrayPtr{A: arrayptr([2]int{-1})}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadArrayPtrOmitEmpty", + data: struct { + *structArrayPtrOmitEmpty + B *[2]int `json:"b,omitempty"` + }{ + structArrayPtrOmitEmpty: &structArrayPtrOmitEmpty{A: arrayptr([2]int{-1})}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadArrayPtrString", + data: struct { + *structArrayPtrString + B *[2]int `json:"b,string"` + }{ + structArrayPtrString: &structArrayPtrString{A: arrayptr([2]int{-1})}, + B: nil, + }, + }, + + // NilPtrAnonymousHeadArrayPtr + { + name: "NilPtrAnonymousHeadArrayPtr", + data: struct { + *structArrayPtr + B *[2]int `json:"b"` + }{ + structArrayPtr: nil, + B: arrayptr([2]int{-1}), + }, + }, + { + name: "NilPtrAnonymousHeadArrayPtrOmitEmpty", + data: struct { + *structArrayPtrOmitEmpty + B *[2]int `json:"b,omitempty"` + }{ + structArrayPtrOmitEmpty: nil, + B: arrayptr([2]int{-1}), + }, + }, + { + name: "NilPtrAnonymousHeadArrayPtrString", + data: struct { + *structArrayPtrString + B *[2]int `json:"b,string"` + }{ + structArrayPtrString: nil, + B: arrayptr([2]int{-1}), + }, + }, + + // AnonymousHeadArrayOnly + { + name: "AnonymousHeadArrayOnly", + data: struct { + structArray + }{ + structArray: structArray{A: [2]int{-1}}, + }, + }, + { + name: "AnonymousHeadArrayOnlyOmitEmpty", + data: struct { + structArrayOmitEmpty + }{ + structArrayOmitEmpty: structArrayOmitEmpty{A: [2]int{-1}}, + }, + }, + { + name: "AnonymousHeadArrayOnlyString", + data: struct { + structArrayString + }{ + structArrayString: structArrayString{A: [2]int{-1}}, + }, + }, + + // PtrAnonymousHeadArrayOnly + { + name: "PtrAnonymousHeadArrayOnly", + data: struct { + *structArray + }{ + structArray: &structArray{A: [2]int{-1}}, + }, + }, + { + name: "PtrAnonymousHeadArrayOnlyOmitEmpty", + data: struct { + *structArrayOmitEmpty + }{ + structArrayOmitEmpty: &structArrayOmitEmpty{A: [2]int{-1}}, + }, + }, + { + name: "PtrAnonymousHeadArrayOnlyString", + data: struct { + *structArrayString + }{ + structArrayString: &structArrayString{A: [2]int{-1}}, + }, + }, + + // NilPtrAnonymousHeadArrayOnly + { + name: "NilPtrAnonymousHeadArrayOnly", + data: struct { + *structArray + }{ + structArray: nil, + }, + }, + { + name: "NilPtrAnonymousHeadArrayOnlyOmitEmpty", + data: struct { + *structArrayOmitEmpty + }{ + structArrayOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadArrayOnlyString", + data: struct { + *structArrayString + }{ + structArrayString: nil, + }, + }, + + // AnonymousHeadArrayPtrOnly + { + name: "AnonymousHeadArrayPtrOnly", + data: struct { + structArrayPtr + }{ + structArrayPtr: structArrayPtr{A: arrayptr([2]int{-1})}, + }, + }, + { + name: "AnonymousHeadArrayPtrOnlyOmitEmpty", + data: struct { + structArrayPtrOmitEmpty + }{ + structArrayPtrOmitEmpty: structArrayPtrOmitEmpty{A: arrayptr([2]int{-1})}, + }, + }, + { + name: "AnonymousHeadArrayPtrOnlyString", + data: struct { + structArrayPtrString + }{ + structArrayPtrString: structArrayPtrString{A: arrayptr([2]int{-1})}, + }, + }, + + // AnonymousHeadArrayPtrNilOnly + { + name: "AnonymousHeadArrayPtrNilOnly", + data: struct { + structArrayPtr + }{ + structArrayPtr: structArrayPtr{A: nil}, + }, + }, + { + name: "AnonymousHeadArrayPtrNilOnlyOmitEmpty", + data: struct { + structArrayPtrOmitEmpty + }{ + structArrayPtrOmitEmpty: structArrayPtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadArrayPtrNilOnlyString", + data: struct { + structArrayPtrString + }{ + structArrayPtrString: structArrayPtrString{A: nil}, + }, + }, + + // PtrAnonymousHeadArrayPtrOnly + { + name: "PtrAnonymousHeadArrayPtrOnly", + data: struct { + *structArrayPtr + }{ + structArrayPtr: &structArrayPtr{A: arrayptr([2]int{-1})}, + }, + }, + { + name: "PtrAnonymousHeadArrayPtrOnlyOmitEmpty", + data: struct { + *structArrayPtrOmitEmpty + }{ + structArrayPtrOmitEmpty: &structArrayPtrOmitEmpty{A: arrayptr([2]int{-1})}, + }, + }, + { + name: "PtrAnonymousHeadArrayPtrOnlyString", + data: struct { + *structArrayPtrString + }{ + structArrayPtrString: &structArrayPtrString{A: arrayptr([2]int{-1})}, + }, + }, + + // NilPtrAnonymousHeadArrayPtrOnly + { + name: "NilPtrAnonymousHeadArrayPtrOnly", + data: struct { + *structArrayPtr + }{ + structArrayPtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadArrayPtrOnlyOmitEmpty", + data: struct { + *structArrayPtrOmitEmpty + }{ + structArrayPtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadArrayPtrOnlyString", + data: struct { + *structArrayPtrString + }{ + structArrayPtrString: nil, + }, + }, + } + for _, test := range tests { + for _, indent := range []bool{true, false} { + for _, htmlEscape := range []bool{true, false} { + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + enc.SetEscapeHTML(htmlEscape) + if indent { + enc.SetIndent("", " ") + } + if err := enc.Encode(test.data); err != nil { + 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:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String()) + } + } + } + } +} diff --git a/cover_bool_test.go b/cover_bool_test.go index 4a901f8..fcf8342 100644 --- a/cover_bool_test.go +++ b/cover_bool_test.go @@ -1774,11 +1774,11 @@ func TestCoverBool(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/cover_helper_test.go b/cover_helper_test.go index 8094230..107635a 100644 --- a/cover_helper_test.go +++ b/cover_helper_test.go @@ -5,20 +5,23 @@ import ( stdjson "encoding/json" ) -func intptr(v int) *int { return &v } -func int8ptr(v int8) *int8 { return &v } -func int16ptr(v int16) *int16 { return &v } -func int32ptr(v int32) *int32 { return &v } -func int64ptr(v int64) *int64 { return &v } -func uptr(v uint) *uint { return &v } -func uint8ptr(v uint8) *uint8 { return &v } -func uint16ptr(v uint16) *uint16 { return &v } -func uint32ptr(v uint32) *uint32 { return &v } -func uint64ptr(v uint64) *uint64 { return &v } -func float32ptr(v float32) *float32 { return &v } -func float64ptr(v float64) *float64 { return &v } -func stringptr(v string) *string { return &v } -func boolptr(v bool) *bool { return &v } +func intptr(v int) *int { return &v } +func int8ptr(v int8) *int8 { return &v } +func int16ptr(v int16) *int16 { return &v } +func int32ptr(v int32) *int32 { return &v } +func int64ptr(v int64) *int64 { return &v } +func uptr(v uint) *uint { return &v } +func uint8ptr(v uint8) *uint8 { return &v } +func uint16ptr(v uint16) *uint16 { return &v } +func uint32ptr(v uint32) *uint32 { return &v } +func uint64ptr(v uint64) *uint64 { return &v } +func float32ptr(v float32) *float32 { return &v } +func float64ptr(v float64) *float64 { return &v } +func stringptr(v string) *string { return &v } +func boolptr(v bool) *bool { return &v } +func sliceptr(v []int) *[]int { return &v } +func arrayptr(v [2]int) *[2]int { return &v } +func mapptr(v map[string]int) *map[string]int { return &v } func encodeByEncodingJSON(data interface{}, indent, escape bool) string { var buf bytes.Buffer diff --git a/cover_int16_test.go b/cover_int16_test.go index 779e9e7..612f18c 100644 --- a/cover_int16_test.go +++ b/cover_int16_test.go @@ -408,6 +408,29 @@ func TestCoverInt16(t *testing.T) { }{A: nil, B: nil}, }, + // PtrHeadInt16NilMultiFields + { + name: "PtrHeadInt16NilMultiFields", + data: (*struct { + A int16 `json:"a"` + B int16 `json:"b"` + })(nil), + }, + { + name: "PtrHeadInt16NilMultiFieldsOmitEmpty", + data: (*struct { + A int16 `json:"a,omitempty"` + B int16 `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadInt16NilMultiFieldsString", + data: (*struct { + A int16 `json:"a,string"` + B int16 `json:"b,string"` + })(nil), + }, + // PtrHeadInt16NilMultiFields { name: "PtrHeadInt16NilMultiFields", 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/cover_map_test.go b/cover_map_test.go new file mode 100644 index 0000000..92efd82 --- /dev/null +++ b/cover_map_test.go @@ -0,0 +1,1859 @@ +package json_test + +import ( + "bytes" + "testing" + + "github.com/goccy/go-json" +) + +func TestCoverMap(t *testing.T) { + type structMap struct { + A map[string]int `json:"a"` + } + type structMapOmitEmpty struct { + A map[string]int `json:"a,omitempty"` + } + type structMapString struct { + A map[string]int `json:"a,string"` + } + type structMapPtr struct { + A *map[string]int `json:"a"` + } + type structMapPtrOmitEmpty struct { + A *map[string]int `json:"a,omitempty"` + } + type structMapPtrString struct { + A *map[string]int `json:"a,string"` + } + + type structMapPtrContent struct { + A map[string]*int `json:"a"` + } + type structMapOmitEmptyPtrContent struct { + A map[string]*int `json:"a,omitempty"` + } + type structMapStringPtrContent struct { + A map[string]*int `json:"a,string"` + } + type structMapPtrPtrContent struct { + A *map[string]*int `json:"a"` + } + type structMapPtrOmitEmptyPtrContent struct { + A *map[string]*int `json:"a,omitempty"` + } + type structMapPtrStringPtrContent struct { + A *map[string]*int `json:"a,string"` + } + + tests := []struct { + name string + data interface{} + }{ + // HeadMapZero + { + name: "HeadMapZero", + data: struct { + A map[string]int `json:"a"` + }{}, + }, + { + name: "HeadMapZeroOmitEmpty", + data: struct { + A map[string]int `json:"a,omitempty"` + }{}, + }, + { + name: "HeadMapZeroString", + data: struct { + A map[string]int `json:"a,string"` + }{}, + }, + + // HeadMap + { + name: "HeadMap", + data: struct { + A map[string]int `json:"a"` + }{A: map[string]int{"m": -1}}, + }, + { + name: "HeadMapOmitEmpty", + data: struct { + A map[string]int `json:"a,omitempty"` + }{A: map[string]int{"m": -1}}, + }, + { + name: "HeadMapString", + data: struct { + A map[string]int `json:"a,string"` + }{A: map[string]int{"m": -1}}, + }, + + // HeadMapPtr + { + name: "HeadMapPtr", + data: struct { + A *map[string]int `json:"a"` + }{A: mapptr(map[string]int{"m": -1})}, + }, + { + name: "HeadMapPtrOmitEmpty", + data: struct { + A *map[string]int `json:"a,omitempty"` + }{A: mapptr(map[string]int{"m": -1})}, + }, + { + name: "HeadMapPtrString", + data: struct { + A *map[string]int `json:"a,string"` + }{A: mapptr(map[string]int{"m": -1})}, + }, + + // HeadMapPtrNil + { + name: "HeadMapPtrNil", + data: struct { + A *map[string]int `json:"a"` + }{A: nil}, + }, + { + name: "HeadMapPtrNilOmitEmpty", + data: struct { + A *map[string]int `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadMapPtrNilString", + data: struct { + A *map[string]int `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadMapZero + { + name: "PtrHeadMapZero", + data: &struct { + A map[string]int `json:"a"` + }{}, + }, + { + name: "PtrHeadMapZeroOmitEmpty", + data: &struct { + A map[string]int `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadMapZeroString", + data: &struct { + A map[string]int `json:"a,string"` + }{}, + }, + + // PtrHeadMap + { + name: "PtrHeadMap", + data: &struct { + A map[string]int `json:"a"` + }{A: map[string]int{"m": -1}}, + }, + { + name: "PtrHeadMapOmitEmpty", + data: &struct { + A map[string]int `json:"a,omitempty"` + }{A: map[string]int{"m": -1}}, + }, + { + name: "PtrHeadMapString", + data: &struct { + A map[string]int `json:"a,string"` + }{A: map[string]int{"m": -1}}, + }, + + // PtrHeadMapPtr + { + name: "PtrHeadMapPtr", + data: &struct { + A *map[string]int `json:"a"` + }{A: mapptr(map[string]int{"m": -1})}, + }, + { + name: "PtrHeadMapPtrOmitEmpty", + data: &struct { + A *map[string]int `json:"a,omitempty"` + }{A: mapptr(map[string]int{"m": -1})}, + }, + { + name: "PtrHeadMapPtrString", + data: &struct { + A *map[string]int `json:"a,string"` + }{A: mapptr(map[string]int{"m": -1})}, + }, + + // PtrHeadMapPtrNil + { + name: "PtrHeadMapPtrNil", + data: &struct { + A *map[string]int `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadMapPtrNilOmitEmpty", + data: &struct { + A *map[string]int `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadMapPtrNilString", + data: &struct { + A *map[string]int `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadMapNil + { + name: "PtrHeadMapNil", + data: (*struct { + A *map[string]int `json:"a"` + })(nil), + }, + { + name: "PtrHeadMapNilOmitEmpty", + data: (*struct { + A *map[string]int `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadMapNilString", + data: (*struct { + A *map[string]int `json:"a,string"` + })(nil), + }, + + // HeadMapZeroMultiFields + { + name: "HeadMapZeroMultiFields", + data: struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + C map[string]int `json:"c"` + }{}, + }, + { + name: "HeadMapZeroMultiFieldsOmitEmpty", + data: struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + C map[string]int `json:"c,omitempty"` + }{}, + }, + { + name: "HeadMapZeroMultiFields", + data: struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + C map[string]int `json:"c,string"` + }{}, + }, + + // HeadMapMultiFields + { + name: "HeadMapMultiFields", + data: struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + C map[string]int `json:"c"` + }{A: map[string]int{"m": -1}, B: map[string]int{"m": 2}, C: map[string]int{"m": -3}}, + }, + { + name: "HeadMapMultiFieldsOmitEmpty", + data: struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + C map[string]int `json:"c,omitempty"` + }{A: map[string]int{"m": -1}, B: map[string]int{"m": 2}, C: map[string]int{"m": -3}}, + }, + { + name: "HeadMapMultiFieldsString", + data: struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + C map[string]int `json:"c,string"` + }{A: map[string]int{"m": -1}, B: map[string]int{"m": 2}, C: map[string]int{"m": -3}}, + }, + + // HeadMapPtrMultiFields + { + name: "HeadMapPtrMultiFields", + data: struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + C *map[string]int `json:"c"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 2}), C: mapptr(map[string]int{"m": -3})}, + }, + { + name: "HeadMapPtrMultiFieldsOmitEmpty", + data: struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + C *map[string]int `json:"c,omitempty"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 2}), C: mapptr(map[string]int{"m": -3})}, + }, + { + name: "HeadMapPtrMultiFieldsString", + data: struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + C *map[string]int `json:"c,string"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 2}), C: mapptr(map[string]int{"m": -3})}, + }, + + // HeadMapPtrNilMultiFields + { + name: "HeadMapPtrNilMultiFields", + data: struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + C *map[string]int `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadMapPtrNilMultiFieldsOmitEmpty", + data: struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + C *map[string]int `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadMapPtrNilMultiFieldsString", + data: struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + C *map[string]int `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + + // PtrHeadMapZeroMultiFields + { + name: "PtrHeadMapZeroMultiFields", + data: &struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + }{}, + }, + { + name: "PtrHeadMapZeroMultiFieldsOmitEmpty", + data: &struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadMapZeroMultiFieldsString", + data: &struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + }{}, + }, + + // PtrHeadMapMultiFields + { + name: "PtrHeadMapMultiFields", + data: &struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + }{A: map[string]int{"m": -1}, B: nil}, + }, + { + name: "PtrHeadMapMultiFieldsOmitEmpty", + data: &struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + }{A: map[string]int{"m": -1}, B: nil}, + }, + { + name: "PtrHeadMapMultiFieldsString", + data: &struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + }{A: map[string]int{"m": -1}, B: nil}, + }, + + // PtrHeadMapPtrMultiFields + { + name: "PtrHeadMapPtrMultiFields", + data: &struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 2})}, + }, + { + name: "PtrHeadMapPtrMultiFieldsOmitEmpty", + data: &struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 2})}, + }, + { + name: "PtrHeadMapPtrMultiFieldsString", + data: &struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 2})}, + }, + + // PtrHeadMapPtrNilMultiFields + { + name: "PtrHeadMapPtrNilMultiFields", + data: &struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapPtrNilMultiFieldsOmitEmpty", + data: &struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapPtrNilMultiFieldsString", + data: &struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + }{A: nil, B: nil}, + }, + + // PtrHeadMapNilMultiFields + { + name: "PtrHeadMapNilMultiFields", + data: (*struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + })(nil), + }, + { + name: "PtrHeadMapNilMultiFieldsOmitEmpty", + data: (*struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadMapNilMultiFieldsString", + data: (*struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + })(nil), + }, + + // PtrHeadMapNilMultiFields + { + name: "PtrHeadMapNilMultiFields", + data: (*struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + })(nil), + }, + { + name: "PtrHeadMapNilMultiFieldsOmitEmpty", + data: (*struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadMapNilMultiFieldsString", + data: (*struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + })(nil), + }, + + // HeadMapZeroNotRoot + { + name: "HeadMapZeroNotRoot", + data: struct { + A struct { + A map[string]int `json:"a"` + } + }{}, + }, + { + name: "HeadMapZeroNotRootOmitEmpty", + data: struct { + A struct { + A map[string]int `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadMapZeroNotRootString", + data: struct { + A struct { + A map[string]int `json:"a,string"` + } + }{}, + }, + + // HeadMapNotRoot + { + name: "HeadMapNotRoot", + data: struct { + A struct { + A map[string]int `json:"a"` + } + }{A: struct { + A map[string]int `json:"a"` + }{A: map[string]int{"m": -1}}}, + }, + { + name: "HeadMapNotRootOmitEmpty", + data: struct { + A struct { + A map[string]int `json:"a,omitempty"` + } + }{A: struct { + A map[string]int `json:"a,omitempty"` + }{A: map[string]int{"m": -1}}}, + }, + { + name: "HeadMapNotRootString", + data: struct { + A struct { + A map[string]int `json:"a,string"` + } + }{A: struct { + A map[string]int `json:"a,string"` + }{A: map[string]int{"m": -1}}}, + }, + + // HeadMapPtrNotRoot + { + name: "HeadMapPtrNotRoot", + data: struct { + A struct { + A *map[string]int `json:"a"` + } + }{A: struct { + A *map[string]int `json:"a"` + }{mapptr(map[string]int{"m": -1})}}, + }, + { + name: "HeadMapPtrNotRootOmitEmpty", + data: struct { + A struct { + A *map[string]int `json:"a,omitempty"` + } + }{A: struct { + A *map[string]int `json:"a,omitempty"` + }{mapptr(map[string]int{"m": -1})}}, + }, + { + name: "HeadMapPtrNotRootString", + data: struct { + A struct { + A *map[string]int `json:"a,string"` + } + }{A: struct { + A *map[string]int `json:"a,string"` + }{mapptr(map[string]int{"m": -1})}}, + }, + + // HeadMapPtrNilNotRoot + { + name: "HeadMapPtrNilNotRoot", + data: struct { + A struct { + A *map[string]int `json:"a"` + } + }{}, + }, + { + name: "HeadMapPtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *map[string]int `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadMapPtrNilNotRootString", + data: struct { + A struct { + A *map[string]int `json:"a,string"` + } + }{}, + }, + + // PtrHeadMapZeroNotRoot + { + name: "PtrHeadMapZeroNotRoot", + data: struct { + A *struct { + A map[string]int `json:"a"` + } + }{A: new(struct { + A map[string]int `json:"a"` + })}, + }, + { + name: "PtrHeadMapZeroNotRootOmitEmpty", + data: struct { + A *struct { + A map[string]int `json:"a,omitempty"` + } + }{A: new(struct { + A map[string]int `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadMapZeroNotRootString", + data: struct { + A *struct { + A map[string]int `json:"a,string"` + } + }{A: new(struct { + A map[string]int `json:"a,string"` + })}, + }, + + // PtrHeadMapNotRoot + { + name: "PtrHeadMapNotRoot", + data: struct { + A *struct { + A map[string]int `json:"a"` + } + }{A: &(struct { + A map[string]int `json:"a"` + }{A: map[string]int{"m": -1}})}, + }, + { + name: "PtrHeadMapNotRootOmitEmpty", + data: struct { + A *struct { + A map[string]int `json:"a,omitempty"` + } + }{A: &(struct { + A map[string]int `json:"a,omitempty"` + }{A: map[string]int{"m": -1}})}, + }, + { + name: "PtrHeadMapNotRootString", + data: struct { + A *struct { + A map[string]int `json:"a,string"` + } + }{A: &(struct { + A map[string]int `json:"a,string"` + }{A: map[string]int{"m": -1}})}, + }, + + // PtrHeadMapPtrNotRoot + { + name: "PtrHeadMapPtrNotRoot", + data: struct { + A *struct { + A *map[string]int `json:"a"` + } + }{A: &(struct { + A *map[string]int `json:"a"` + }{A: mapptr(map[string]int{"m": -1})})}, + }, + { + name: "PtrHeadMapPtrNotRootOmitEmpty", + data: struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + } + }{A: &(struct { + A *map[string]int `json:"a,omitempty"` + }{A: mapptr(map[string]int{"m": -1})})}, + }, + { + name: "PtrHeadMapPtrNotRootString", + data: struct { + A *struct { + A *map[string]int `json:"a,string"` + } + }{A: &(struct { + A *map[string]int `json:"a,string"` + }{A: mapptr(map[string]int{"m": -1})})}, + }, + + // PtrHeadMapPtrNilNotRoot + { + name: "PtrHeadMapPtrNilNotRoot", + data: struct { + A *struct { + A *map[string]int `json:"a"` + } + }{A: &(struct { + A *map[string]int `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadMapPtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + } + }{A: &(struct { + A *map[string]int `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadMapPtrNilNotRootString", + data: struct { + A *struct { + A *map[string]int `json:"a,string"` + } + }{A: &(struct { + A *map[string]int `json:"a,string"` + }{A: nil})}, + }, + + // PtrHeadMapNilNotRoot + { + name: "PtrHeadMapNilNotRoot", + data: struct { + A *struct { + A *map[string]int `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadMapNilNotRootOmitEmpty", + data: struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadMapNilNotRootString", + data: struct { + A *struct { + A *map[string]int `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + + // HeadMapZeroMultiFieldsNotRoot + { + name: "HeadMapZeroMultiFieldsNotRoot", + data: struct { + A struct { + A map[string]int `json:"a"` + } + B struct { + B map[string]int `json:"b"` + } + }{}, + }, + { + name: "HeadMapZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A map[string]int `json:"a,omitempty"` + } + B struct { + B map[string]int `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadMapZeroMultiFieldsNotRootString", + data: struct { + A struct { + A map[string]int `json:"a,string"` + } + B struct { + B map[string]int `json:"b,string"` + } + }{}, + }, + + // HeadMapMultiFieldsNotRoot + { + name: "HeadMapMultiFieldsNotRoot", + data: struct { + A struct { + A map[string]int `json:"a"` + } + B struct { + B map[string]int `json:"b"` + } + }{A: struct { + A map[string]int `json:"a"` + }{A: map[string]int{"m": -1}}, B: struct { + B map[string]int `json:"b"` + }{B: map[string]int{"m": 0}}}, + }, + { + name: "HeadMapMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A map[string]int `json:"a,omitempty"` + } + B struct { + B map[string]int `json:"b,omitempty"` + } + }{A: struct { + A map[string]int `json:"a,omitempty"` + }{A: map[string]int{"m": -1}}, B: struct { + B map[string]int `json:"b,omitempty"` + }{B: map[string]int{"m": 1}}}, + }, + { + name: "HeadMapMultiFieldsNotRootString", + data: struct { + A struct { + A map[string]int `json:"a,string"` + } + B struct { + B map[string]int `json:"b,string"` + } + }{A: struct { + A map[string]int `json:"a,string"` + }{A: map[string]int{"m": -1}}, B: struct { + B map[string]int `json:"b,string"` + }{B: map[string]int{"m": 1}}}, + }, + + // HeadMapPtrMultiFieldsNotRoot + { + name: "HeadMapPtrMultiFieldsNotRoot", + data: struct { + A struct { + A *map[string]int `json:"a"` + } + B struct { + B *map[string]int `json:"b"` + } + }{A: struct { + A *map[string]int `json:"a"` + }{A: mapptr(map[string]int{"m": -1})}, B: struct { + B *map[string]int `json:"b"` + }{B: mapptr(map[string]int{"m": 1})}}, + }, + { + name: "HeadMapPtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *map[string]int `json:"a,omitempty"` + } + B struct { + B *map[string]int `json:"b,omitempty"` + } + }{A: struct { + A *map[string]int `json:"a,omitempty"` + }{A: mapptr(map[string]int{"m": -1})}, B: struct { + B *map[string]int `json:"b,omitempty"` + }{B: mapptr(map[string]int{"m": 1})}}, + }, + { + name: "HeadMapPtrMultiFieldsNotRootString", + data: struct { + A struct { + A *map[string]int `json:"a,string"` + } + B struct { + B *map[string]int `json:"b,string"` + } + }{A: struct { + A *map[string]int `json:"a,string"` + }{A: mapptr(map[string]int{"m": -1})}, B: struct { + B *map[string]int `json:"b,string"` + }{B: mapptr(map[string]int{"m": 1})}}, + }, + + // HeadMapPtrNilMultiFieldsNotRoot + { + name: "HeadMapPtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *map[string]int `json:"a"` + } + B struct { + B *map[string]int `json:"b"` + } + }{A: struct { + A *map[string]int `json:"a"` + }{A: nil}, B: struct { + B *map[string]int `json:"b"` + }{B: nil}}, + }, + { + name: "HeadMapPtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *map[string]int `json:"a,omitempty"` + } + B struct { + B *map[string]int `json:"b,omitempty"` + } + }{A: struct { + A *map[string]int `json:"a,omitempty"` + }{A: nil}, B: struct { + B *map[string]int `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadMapPtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *map[string]int `json:"a,string"` + } + B struct { + B *map[string]int `json:"b,string"` + } + }{A: struct { + A *map[string]int `json:"a,string"` + }{A: nil}, B: struct { + B *map[string]int `json:"b,string"` + }{B: nil}}, + }, + + // PtrHeadMapZeroMultiFieldsNotRoot + { + name: "PtrHeadMapZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A map[string]int `json:"a"` + } + B struct { + B map[string]int `json:"b"` + } + }{}, + }, + { + name: "PtrHeadMapZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A map[string]int `json:"a,omitempty"` + } + B struct { + B map[string]int `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadMapZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A map[string]int `json:"a,string"` + } + B struct { + B map[string]int `json:"b,string"` + } + }{}, + }, + + // PtrHeadMapMultiFieldsNotRoot + { + name: "PtrHeadMapMultiFieldsNotRoot", + data: &struct { + A struct { + A map[string]int `json:"a"` + } + B struct { + B map[string]int `json:"b"` + } + }{A: struct { + A map[string]int `json:"a"` + }{A: map[string]int{"m": -1}}, B: struct { + B map[string]int `json:"b"` + }{B: map[string]int{"m": 1}}}, + }, + { + name: "PtrHeadMapMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A map[string]int `json:"a,omitempty"` + } + B struct { + B map[string]int `json:"b,omitempty"` + } + }{A: struct { + A map[string]int `json:"a,omitempty"` + }{A: map[string]int{"m": -1}}, B: struct { + B map[string]int `json:"b,omitempty"` + }{B: map[string]int{"m": 1}}}, + }, + { + name: "PtrHeadMapMultiFieldsNotRootString", + data: &struct { + A struct { + A map[string]int `json:"a,string"` + } + B struct { + B map[string]int `json:"b,string"` + } + }{A: struct { + A map[string]int `json:"a,string"` + }{A: map[string]int{"m": -1}}, B: struct { + B map[string]int `json:"b,string"` + }{B: map[string]int{"m": 1}}}, + }, + + // PtrHeadMapPtrMultiFieldsNotRoot + { + name: "PtrHeadMapPtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *map[string]int `json:"a"` + } + B *struct { + B *map[string]int `json:"b"` + } + }{A: &(struct { + A *map[string]int `json:"a"` + }{A: mapptr(map[string]int{"m": -1})}), B: &(struct { + B *map[string]int `json:"b"` + }{B: mapptr(map[string]int{"m": 1})})}, + }, + { + name: "PtrHeadMapPtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + } + B *struct { + B *map[string]int `json:"b,omitempty"` + } + }{A: &(struct { + A *map[string]int `json:"a,omitempty"` + }{A: mapptr(map[string]int{"m": -1})}), B: &(struct { + B *map[string]int `json:"b,omitempty"` + }{B: mapptr(map[string]int{"m": 1})})}, + }, + { + name: "PtrHeadMapPtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *map[string]int `json:"a,string"` + } + B *struct { + B *map[string]int `json:"b,string"` + } + }{A: &(struct { + A *map[string]int `json:"a,string"` + }{A: mapptr(map[string]int{"m": -1})}), B: &(struct { + B *map[string]int `json:"b,string"` + }{B: mapptr(map[string]int{"m": 1})})}, + }, + + // PtrHeadMapPtrNilMultiFieldsNotRoot + { + name: "PtrHeadMapPtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *map[string]int `json:"a"` + } + B *struct { + B *map[string]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapPtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *map[string]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapPtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *map[string]int `json:"a,string"` + } `json:",string"` + B *struct { + B *map[string]int `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + + // PtrHeadMapNilMultiFieldsNotRoot + { + name: "PtrHeadMapNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *map[string]int `json:"a"` + } + B *struct { + B *map[string]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMapNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + } + B *struct { + B *map[string]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMapNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *map[string]int `json:"a,string"` + } + B *struct { + B *map[string]int `json:"b,string"` + } + })(nil), + }, + + // PtrHeadMapDoubleMultiFieldsNotRoot + { + name: "PtrHeadMapDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + } + B *struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + } + }{A: &(struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + }{A: map[string]int{"m": -1}, B: map[string]int{"m": 1}}), B: &(struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + }{A: map[string]int{"m": -1}, B: nil})}, + }, + { + name: "PtrHeadMapDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + } + B *struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + } + }{A: &(struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + }{A: map[string]int{"m": -1}, B: map[string]int{"m": 1}}), B: &(struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + }{A: map[string]int{"m": -1}, B: nil})}, + }, + { + name: "PtrHeadMapDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + } + B *struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + } + }{A: &(struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + }{A: map[string]int{"m": -1}, B: map[string]int{"m": 1}}), B: &(struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + }{A: map[string]int{"m": -1}, B: nil})}, + }, + + // PtrHeadMapNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMapNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + } + B *struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + } + B *struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadMapNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMapNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + } + B *struct { + A map[string]int `json:"a"` + B map[string]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMapNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + } + B *struct { + A map[string]int `json:"a,omitempty"` + B map[string]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMapNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + } + B *struct { + A map[string]int `json:"a,string"` + B map[string]int `json:"b,string"` + } + })(nil), + }, + + // PtrHeadMapPtrDoubleMultiFieldsNotRoot + { + name: "PtrHeadMapPtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + } + B *struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + } + }{A: &(struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 1})}), B: &(struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadMapPtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + } + B *struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + } + }{A: &(struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 1})}), B: &(struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadMapPtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + } + B *struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + } + }{A: &(struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + }{A: mapptr(map[string]int{"m": -1}), B: mapptr(map[string]int{"m": 1})}), B: &(struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + }{A: nil, B: nil})}, + }, + + // PtrHeadMapPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMapPtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + } + B *struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMapPtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + } + B *struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadMapPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMapPtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + } + B *struct { + A *map[string]int `json:"a"` + B *map[string]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMapPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + } + B *struct { + A *map[string]int `json:"a,omitempty"` + B *map[string]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMapPtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + } + B *struct { + A *map[string]int `json:"a,string"` + B *map[string]int `json:"b,string"` + } + })(nil), + }, + + // AnonymousHeadMap + { + name: "AnonymousHeadMap", + data: struct { + structMap + B map[string]int `json:"b"` + }{ + structMap: structMap{A: map[string]int{"m": -1}}, + B: nil, + }, + }, + { + name: "AnonymousHeadMapOmitEmpty", + data: struct { + structMapOmitEmpty + B map[string]int `json:"b,omitempty"` + }{ + structMapOmitEmpty: structMapOmitEmpty{A: map[string]int{"m": -1}}, + B: nil, + }, + }, + { + name: "AnonymousHeadMapString", + data: struct { + structMapString + B map[string]int `json:"b,string"` + }{ + structMapString: structMapString{A: map[string]int{"m": -1}}, + B: nil, + }, + }, + + // PtrAnonymousHeadMap + { + name: "PtrAnonymousHeadMap", + data: struct { + *structMap + B map[string]int `json:"b"` + }{ + structMap: &structMap{A: map[string]int{"m": -1}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMapOmitEmpty", + data: struct { + *structMapOmitEmpty + B map[string]int `json:"b,omitempty"` + }{ + structMapOmitEmpty: &structMapOmitEmpty{A: map[string]int{"m": -1}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMapString", + data: struct { + *structMapString + B map[string]int `json:"b,string"` + }{ + structMapString: &structMapString{A: map[string]int{"m": -1}}, + B: nil, + }, + }, + + // PtrAnonymousHeadMapNil + { + name: "PtrAnonymousHeadMapNil", + data: struct { + *structMap + B map[string]int `json:"b"` + }{ + structMap: &structMap{A: nil}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMapNilOmitEmpty", + data: struct { + *structMapOmitEmpty + B map[string]int `json:"b,omitempty"` + }{ + structMapOmitEmpty: &structMapOmitEmpty{A: nil}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMapNilString", + data: struct { + *structMapString + B map[string]int `json:"b,string"` + }{ + structMapString: &structMapString{A: nil}, + B: nil, + }, + }, + + // NilPtrAnonymousHeadMap + { + name: "NilPtrAnonymousHeadMap", + data: struct { + *structMap + B map[string]int `json:"b"` + }{ + structMap: nil, + B: map[string]int{"m": -1}, + }, + }, + { + name: "NilPtrAnonymousHeadMapOmitEmpty", + data: struct { + *structMapOmitEmpty + B map[string]int `json:"b,omitempty"` + }{ + structMapOmitEmpty: nil, + B: map[string]int{"m": -1}, + }, + }, + { + name: "NilPtrAnonymousHeadMapString", + data: struct { + *structMapString + B map[string]int `json:"b,string"` + }{ + structMapString: nil, + B: map[string]int{"m": -1}, + }, + }, + + // AnonymousHeadMapPtr + { + name: "AnonymousHeadMapPtr", + data: struct { + structMapPtr + B *map[string]int `json:"b"` + }{ + structMapPtr: structMapPtr{A: mapptr(map[string]int{"m": -1})}, + B: nil, + }, + }, + { + name: "AnonymousHeadMapPtrOmitEmpty", + data: struct { + structMapPtrOmitEmpty + B *map[string]int `json:"b,omitempty"` + }{ + structMapPtrOmitEmpty: structMapPtrOmitEmpty{A: mapptr(map[string]int{"m": -1})}, + B: nil, + }, + }, + { + name: "AnonymousHeadMapPtrString", + data: struct { + structMapPtrString + B *map[string]int `json:"b,string"` + }{ + structMapPtrString: structMapPtrString{A: mapptr(map[string]int{"m": -1})}, + B: nil, + }, + }, + + // AnonymousHeadMapPtrNil + { + name: "AnonymousHeadMapPtrNil", + data: struct { + structMapPtr + B *map[string]int `json:"b"` + }{ + structMapPtr: structMapPtr{A: nil}, + B: mapptr(map[string]int{"m": -1}), + }, + }, + { + name: "AnonymousHeadMapPtrNilOmitEmpty", + data: struct { + structMapPtrOmitEmpty + B *map[string]int `json:"b,omitempty"` + }{ + structMapPtrOmitEmpty: structMapPtrOmitEmpty{A: nil}, + B: mapptr(map[string]int{"m": -1}), + }, + }, + { + name: "AnonymousHeadMapPtrNilString", + data: struct { + structMapPtrString + B *map[string]int `json:"b,string"` + }{ + structMapPtrString: structMapPtrString{A: nil}, + B: mapptr(map[string]int{"m": -1}), + }, + }, + + // PtrAnonymousHeadMapPtr + { + name: "PtrAnonymousHeadMapPtr", + data: struct { + *structMapPtr + B *map[string]int `json:"b"` + }{ + structMapPtr: &structMapPtr{A: mapptr(map[string]int{"m": -1})}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMapPtrOmitEmpty", + data: struct { + *structMapPtrOmitEmpty + B *map[string]int `json:"b,omitempty"` + }{ + structMapPtrOmitEmpty: &structMapPtrOmitEmpty{A: mapptr(map[string]int{"m": -1})}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMapPtrString", + data: struct { + *structMapPtrString + B *map[string]int `json:"b,string"` + }{ + structMapPtrString: &structMapPtrString{A: mapptr(map[string]int{"m": -1})}, + B: nil, + }, + }, + + // NilPtrAnonymousHeadMapPtr + { + name: "NilPtrAnonymousHeadMapPtr", + data: struct { + *structMapPtr + B *map[string]int `json:"b"` + }{ + structMapPtr: nil, + B: mapptr(map[string]int{"m": -1}), + }, + }, + { + name: "NilPtrAnonymousHeadMapPtrOmitEmpty", + data: struct { + *structMapPtrOmitEmpty + B *map[string]int `json:"b,omitempty"` + }{ + structMapPtrOmitEmpty: nil, + B: mapptr(map[string]int{"m": -1}), + }, + }, + { + name: "NilPtrAnonymousHeadMapPtrString", + data: struct { + *structMapPtrString + B *map[string]int `json:"b,string"` + }{ + structMapPtrString: nil, + B: mapptr(map[string]int{"m": -1}), + }, + }, + + // AnonymousHeadMapOnly + { + name: "AnonymousHeadMapOnly", + data: struct { + structMap + }{ + structMap: structMap{A: map[string]int{"m": -1}}, + }, + }, + { + name: "AnonymousHeadMapOnlyOmitEmpty", + data: struct { + structMapOmitEmpty + }{ + structMapOmitEmpty: structMapOmitEmpty{A: map[string]int{"m": -1}}, + }, + }, + { + name: "AnonymousHeadMapOnlyString", + data: struct { + structMapString + }{ + structMapString: structMapString{A: map[string]int{"m": -1}}, + }, + }, + + // PtrAnonymousHeadMapOnly + { + name: "PtrAnonymousHeadMapOnly", + data: struct { + *structMap + }{ + structMap: &structMap{A: map[string]int{"m": -1}}, + }, + }, + { + name: "PtrAnonymousHeadMapOnlyOmitEmpty", + data: struct { + *structMapOmitEmpty + }{ + structMapOmitEmpty: &structMapOmitEmpty{A: map[string]int{"m": -1}}, + }, + }, + { + name: "PtrAnonymousHeadMapOnlyString", + data: struct { + *structMapString + }{ + structMapString: &structMapString{A: map[string]int{"m": -1}}, + }, + }, + + // NilPtrAnonymousHeadMapOnly + { + name: "NilPtrAnonymousHeadMapOnly", + data: struct { + *structMap + }{ + structMap: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMapOnlyOmitEmpty", + data: struct { + *structMapOmitEmpty + }{ + structMapOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMapOnlyString", + data: struct { + *structMapString + }{ + structMapString: nil, + }, + }, + + // AnonymousHeadMapPtrOnly + { + name: "AnonymousHeadMapPtrOnly", + data: struct { + structMapPtr + }{ + structMapPtr: structMapPtr{A: mapptr(map[string]int{"m": -1})}, + }, + }, + { + name: "AnonymousHeadMapPtrOnlyOmitEmpty", + data: struct { + structMapPtrOmitEmpty + }{ + structMapPtrOmitEmpty: structMapPtrOmitEmpty{A: mapptr(map[string]int{"m": -1})}, + }, + }, + { + name: "AnonymousHeadMapPtrOnlyString", + data: struct { + structMapPtrString + }{ + structMapPtrString: structMapPtrString{A: mapptr(map[string]int{"m": -1})}, + }, + }, + + // AnonymousHeadMapPtrNilOnly + { + name: "AnonymousHeadMapPtrNilOnly", + data: struct { + structMapPtr + }{ + structMapPtr: structMapPtr{A: nil}, + }, + }, + { + name: "AnonymousHeadMapPtrNilOnlyOmitEmpty", + data: struct { + structMapPtrOmitEmpty + }{ + structMapPtrOmitEmpty: structMapPtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadMapPtrNilOnlyString", + data: struct { + structMapPtrString + }{ + structMapPtrString: structMapPtrString{A: nil}, + }, + }, + + // PtrAnonymousHeadMapPtrOnly + { + name: "PtrAnonymousHeadMapPtrOnly", + data: struct { + *structMapPtr + }{ + structMapPtr: &structMapPtr{A: mapptr(map[string]int{"m": -1})}, + }, + }, + { + name: "PtrAnonymousHeadMapPtrOnlyOmitEmpty", + data: struct { + *structMapPtrOmitEmpty + }{ + structMapPtrOmitEmpty: &structMapPtrOmitEmpty{A: mapptr(map[string]int{"m": -1})}, + }, + }, + { + name: "PtrAnonymousHeadMapPtrOnlyString", + data: struct { + *structMapPtrString + }{ + structMapPtrString: &structMapPtrString{A: mapptr(map[string]int{"m": -1})}, + }, + }, + + // NilPtrAnonymousHeadMapPtrOnly + { + name: "NilPtrAnonymousHeadMapPtrOnly", + data: struct { + *structMapPtr + }{ + structMapPtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMapPtrOnlyOmitEmpty", + data: struct { + *structMapPtrOmitEmpty + }{ + structMapPtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMapPtrOnlyString", + data: struct { + *structMapPtrString + }{ + structMapPtrString: nil, + }, + }, + } + for _, test := range tests { + for _, indent := range []bool{true, false} { + for _, htmlEscape := range []bool{true, false} { + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + enc.SetEscapeHTML(htmlEscape) + if indent { + enc.SetIndent("", " ") + } + if err := enc.Encode(test.data); err != nil { + 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:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String()) + } + } + } + } +} diff --git a/cover_marshal_json_test.go b/cover_marshal_json_test.go new file mode 100644 index 0000000..3935dfc --- /dev/null +++ b/cover_marshal_json_test.go @@ -0,0 +1,3546 @@ +package json_test + +import ( + "bytes" + "testing" + + "github.com/goccy/go-json" +) + +type coverMarshalJSON struct { + A int +} + +func (c coverMarshalJSON) MarshalJSON() ([]byte, error) { + return []byte(`"hello"`), nil +} + +type coverPtrMarshalJSON struct { + B int +} + +func (c *coverPtrMarshalJSON) MarshalJSON() ([]byte, error) { + return []byte(`"hello"`), nil +} + +func TestCoverMarshalJSON(t *testing.T) { + type structMarshalJSON struct { + A coverMarshalJSON `json:"a"` + } + type structMarshalJSONOmitEmpty struct { + A coverMarshalJSON `json:"a,omitempty"` + } + type structMarshalJSONString struct { + A coverMarshalJSON `json:"a,string"` + } + type structPtrMarshalJSON struct { + A coverPtrMarshalJSON `json:"a"` + } + type structPtrMarshalJSONOmitEmpty struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + type structPtrMarshalJSONString struct { + A coverPtrMarshalJSON `json:"a,string"` + } + + type structMarshalJSONPtr struct { + A *coverMarshalJSON `json:"a"` + } + type structMarshalJSONPtrOmitEmpty struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + type structMarshalJSONPtrString struct { + A *coverMarshalJSON `json:"a,string"` + } + type structPtrMarshalJSONPtr struct { + A *coverPtrMarshalJSON `json:"a"` + } + type structPtrMarshalJSONPtrOmitEmpty struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + type structPtrMarshalJSONPtrString struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + + tests := []struct { + name string + data interface{} + }{ + // HeadMarshalJSONZero + { + name: "HeadMarshalJSONZero", + data: struct { + A coverMarshalJSON `json:"a"` + }{}, + }, + { + name: "HeadMarshalJSONZeroOmitEmpty", + data: struct { + A coverMarshalJSON `json:"a,omitempty"` + }{}, + }, + { + name: "HeadMarshalJSONZeroString", + data: struct { + A coverMarshalJSON `json:"a,string"` + }{}, + }, + { + name: "HeadPtrMarshalJSONZero", + data: struct { + A coverPtrMarshalJSON `json:"a"` + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroOmitEmpty", + data: struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroString", + data: struct { + A coverPtrMarshalJSON `json:"a,string"` + }{}, + }, + + // HeadMarshalJSON + { + name: "HeadMarshalJSON", + data: struct { + A coverMarshalJSON `json:"a"` + }{A: coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONOmitEmpty", + data: struct { + A coverMarshalJSON `json:"a,omitempty"` + }{A: coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONString", + data: struct { + A coverMarshalJSON `json:"a,string"` + }{A: coverMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSON", + data: struct { + A coverPtrMarshalJSON `json:"a"` + }{A: coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONOmitEmpty", + data: struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{A: coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONString", + data: struct { + A coverPtrMarshalJSON `json:"a,string"` + }{A: coverPtrMarshalJSON{}}, + }, + + // HeadMarshalJSONPtr + { + name: "HeadMarshalJSONPtr", + data: struct { + A *coverMarshalJSON `json:"a"` + }{A: &coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONPtrOmitEmpty", + data: struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: &coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONPtrString", + data: struct { + A *coverMarshalJSON `json:"a,string"` + }{A: &coverMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONPtr", + data: struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: &coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONPtrOmitEmpty", + data: struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: &coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONPtrString", + data: struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: &coverPtrMarshalJSON{}}, + }, + + // HeadMarshalJSONPtrNil + { + name: "HeadMarshalJSONPtrNil", + data: struct { + A *coverMarshalJSON `json:"a"` + }{A: nil}, + }, + { + name: "HeadMarshalJSONPtrNilOmitEmpty", + data: struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadMarshalJSONPtrNilString", + data: struct { + A *coverMarshalJSON `json:"a,string"` + }{A: nil}, + }, + { + name: "HeadPtrMarshalJSONPtrNil", + data: struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: nil}, + }, + { + name: "HeadPtrMarshalJSONPtrNilOmitEmpty", + data: struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadPtrMarshalJSONPtrNilString", + data: struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadMarshalJSONZero + { + name: "PtrHeadMarshalJSONZero", + data: &struct { + A coverMarshalJSON `json:"a"` + }{}, + }, + { + name: "PtrHeadMarshalJSONZeroOmitEmpty", + data: &struct { + A coverMarshalJSON `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadMarshalJSONZeroString", + data: &struct { + A coverMarshalJSON `json:"a,string"` + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZero", + data: &struct { + A coverPtrMarshalJSON `json:"a"` + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroOmitEmpty", + data: &struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroString", + data: &struct { + A coverPtrMarshalJSON `json:"a,string"` + }{}, + }, + + // PtrHeadMarshalJSON + { + name: "PtrHeadMarshalJSON", + data: &struct { + A coverMarshalJSON `json:"a"` + }{A: coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONOmitEmpty", + data: &struct { + A coverMarshalJSON `json:"a,omitempty"` + }{A: coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONString", + data: &struct { + A coverMarshalJSON `json:"a,string"` + }{A: coverMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSON", + data: &struct { + A coverPtrMarshalJSON `json:"a"` + }{A: coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONOmitEmpty", + data: &struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{A: coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONString", + data: &struct { + A coverPtrMarshalJSON `json:"a,string"` + }{A: coverPtrMarshalJSON{}}, + }, + + // PtrHeadMarshalJSONPtr + { + name: "PtrHeadMarshalJSONPtr", + data: &struct { + A *coverMarshalJSON `json:"a"` + }{A: &coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONPtrOmitEmpty", + data: &struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: &coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONPtrString", + data: &struct { + A *coverMarshalJSON `json:"a,string"` + }{A: &coverMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONPtr", + data: &struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: &coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrOmitEmpty", + data: &struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: &coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrString", + data: &struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: &coverPtrMarshalJSON{}}, + }, + + // PtrHeadMarshalJSONPtrNil + { + name: "PtrHeadMarshalJSONPtrNil", + data: &struct { + A *coverMarshalJSON `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilOmitEmpty", + data: &struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilString", + data: &struct { + A *coverMarshalJSON `json:"a,string"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNil", + data: &struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilOmitEmpty", + data: &struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilString", + data: &struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadMarshalJSONNil + { + name: "PtrHeadMarshalJSONNil", + data: (*struct { + A *coverMarshalJSON `json:"a"` + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilOmitEmpty", + data: (*struct { + A *coverMarshalJSON `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilString", + data: (*struct { + A *coverMarshalJSON `json:"a,string"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNil", + data: (*struct { + A *coverPtrMarshalJSON `json:"a"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilOmitEmpty", + data: (*struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilString", + data: (*struct { + A *coverPtrMarshalJSON `json:"a,string"` + })(nil), + }, + + // HeadMarshalJSONZeroMultiFields + { + name: "HeadMarshalJSONZeroMultiFields", + data: struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + C coverMarshalJSON `json:"c"` + }{}, + }, + { + name: "HeadMarshalJSONZeroMultiFieldsOmitEmpty", + data: struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + C coverMarshalJSON `json:"c,omitempty"` + }{}, + }, + { + name: "HeadMarshalJSONZeroMultiFields", + data: struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + C coverMarshalJSON `json:"c,string"` + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroMultiFields", + data: struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + C coverPtrMarshalJSON `json:"c"` + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroMultiFieldsOmitEmpty", + data: struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + C coverPtrMarshalJSON `json:"c,omitempty"` + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroMultiFields", + data: struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + C coverPtrMarshalJSON `json:"c,string"` + }{}, + }, + + // HeadMarshalJSONMultiFields + { + name: "HeadMarshalJSONMultiFields", + data: struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + C coverMarshalJSON `json:"c"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}, C: coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONMultiFieldsOmitEmpty", + data: struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + C coverMarshalJSON `json:"c,omitempty"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}, C: coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONMultiFieldsString", + data: struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + C coverMarshalJSON `json:"c,string"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}, C: coverMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONMultiFields", + data: struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + C coverPtrMarshalJSON `json:"c"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}, C: coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONMultiFieldsOmitEmpty", + data: struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + C coverPtrMarshalJSON `json:"c,omitempty"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}, C: coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONMultiFieldsString", + data: struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + C coverPtrMarshalJSON `json:"c,string"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}, C: coverPtrMarshalJSON{}}, + }, + + // HeadMarshalJSONPtrMultiFields + { + name: "HeadMarshalJSONPtrMultiFields", + data: struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + C *coverMarshalJSON `json:"c"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}, C: &coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONPtrMultiFieldsOmitEmpty", + data: struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + C *coverMarshalJSON `json:"c,omitempty"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}, C: &coverMarshalJSON{}}, + }, + { + name: "HeadMarshalJSONPtrMultiFieldsString", + data: struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + C *coverMarshalJSON `json:"c,string"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}, C: &coverMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONPtrMultiFields", + data: struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + C *coverPtrMarshalJSON `json:"c"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}, C: &coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONPtrMultiFieldsOmitEmpty", + data: struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + C *coverPtrMarshalJSON `json:"c,omitempty"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}, C: &coverPtrMarshalJSON{}}, + }, + { + name: "HeadPtrMarshalJSONPtrMultiFieldsString", + data: struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + C *coverPtrMarshalJSON `json:"c,string"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}, C: &coverPtrMarshalJSON{}}, + }, + + // HeadMarshalJSONPtrNilMultiFields + { + name: "HeadMarshalJSONPtrNilMultiFields", + data: struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + C *coverMarshalJSON `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadMarshalJSONPtrNilMultiFieldsOmitEmpty", + data: struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + C *coverMarshalJSON `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadMarshalJSONPtrNilMultiFieldsString", + data: struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + C *coverMarshalJSON `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadPtrMarshalJSONPtrNilMultiFields", + data: struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + C *coverPtrMarshalJSON `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadPtrMarshalJSONPtrNilMultiFieldsOmitEmpty", + data: struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + C *coverPtrMarshalJSON `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadPtrMarshalJSONPtrNilMultiFieldsString", + data: struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + C *coverPtrMarshalJSON `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + + // PtrHeadMarshalJSONZeroMultiFields + { + name: "PtrHeadMarshalJSONZeroMultiFields", + data: &struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + }{}, + }, + { + name: "PtrHeadMarshalJSONZeroMultiFieldsOmitEmpty", + data: &struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadMarshalJSONZeroMultiFieldsString", + data: &struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroMultiFields", + data: &struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroMultiFieldsOmitEmpty", + data: &struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroMultiFieldsString", + data: &struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + }{}, + }, + + // PtrHeadMarshalJSONMultiFields + { + name: "PtrHeadMarshalJSONMultiFields", + data: &struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONMultiFieldsOmitEmpty", + data: &struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONMultiFieldsString", + data: &struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONMultiFields", + data: &struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONMultiFieldsOmitEmpty", + data: &struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONMultiFieldsString", + data: &struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}}, + }, + + // PtrHeadMarshalJSONPtrMultiFields + { + name: "PtrHeadMarshalJSONPtrMultiFields", + data: &struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONPtrMultiFieldsOmitEmpty", + data: &struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}}, + }, + { + name: "PtrHeadMarshalJSONPtrMultiFieldsString", + data: &struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrMultiFields", + data: &struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrMultiFieldsOmitEmpty", + data: &struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrMultiFieldsString", + data: &struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}}, + }, + + // PtrHeadMarshalJSONPtrNilMultiFields + { + name: "PtrHeadMarshalJSONPtrNilMultiFields", + data: &struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilMultiFieldsOmitEmpty", + data: &struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilMultiFieldsString", + data: &struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilMultiFields", + data: &struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilMultiFieldsOmitEmpty", + data: &struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilMultiFieldsString", + data: &struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalJSONNilMultiFields + { + name: "PtrHeadMarshalJSONNilMultiFields", + data: (*struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilMultiFieldsOmitEmpty", + data: (*struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilMultiFieldsString", + data: (*struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFields", + data: (*struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFieldsOmitEmpty", + data: (*struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFieldsString", + data: (*struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + })(nil), + }, + + // PtrHeadMarshalJSONNilMultiFields + { + name: "PtrHeadMarshalJSONNilMultiFields", + data: (*struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilMultiFieldsOmitEmpty", + data: (*struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilMultiFieldsString", + data: (*struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFields", + data: (*struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFieldsOmitEmpty", + data: (*struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFieldsString", + data: (*struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + })(nil), + }, + + // HeadMarshalJSONZeroNotRoot + { + name: "HeadMarshalJSONZeroNotRoot", + data: struct { + A struct { + A coverMarshalJSON `json:"a"` + } + }{}, + }, + { + name: "HeadMarshalJSONZeroNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalJSON `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadMarshalJSONZeroNotRootString", + data: struct { + A struct { + A coverMarshalJSON `json:"a,string"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroNotRoot", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroNotRootString", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,string"` + } + }{}, + }, + + // HeadMarshalJSONNotRoot + { + name: "HeadMarshalJSONNotRoot", + data: struct { + A struct { + A coverMarshalJSON `json:"a"` + } + }{A: struct { + A coverMarshalJSON `json:"a"` + }{A: coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalJSON `json:"a,omitempty"` + } + }{A: struct { + A coverMarshalJSON `json:"a,omitempty"` + }{A: coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONNotRootString", + data: struct { + A struct { + A coverMarshalJSON `json:"a,string"` + } + }{A: struct { + A coverMarshalJSON `json:"a,string"` + }{A: coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONNotRoot", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a"` + }{A: coverPtrMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{A: coverPtrMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONNotRootString", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,string"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a,string"` + }{A: coverPtrMarshalJSON{}}}, + }, + + // HeadMarshalJSONPtrNotRoot + { + name: "HeadMarshalJSONPtrNotRoot", + data: struct { + A struct { + A *coverMarshalJSON `json:"a"` + } + }{A: struct { + A *coverMarshalJSON `json:"a"` + }{&coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONPtrNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + }{A: struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{&coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONPtrNotRootString", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,string"` + } + }{A: struct { + A *coverMarshalJSON `json:"a,string"` + }{&coverMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONPtrNotRoot", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a"` + }{&coverPtrMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONPtrNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{&coverPtrMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONPtrNotRootString", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{&coverPtrMarshalJSON{}}}, + }, + + // HeadMarshalJSONPtrNilNotRoot + { + name: "HeadMarshalJSONPtrNilNotRoot", + data: struct { + A struct { + A *coverMarshalJSON `json:"a"` + } + }{}, + }, + { + name: "HeadMarshalJSONPtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadMarshalJSONPtrNilNotRootString", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,string"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONPtrNilNotRoot", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONPtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONPtrNilNotRootString", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + }{}, + }, + + // PtrHeadMarshalJSONZeroNotRoot + { + name: "PtrHeadMarshalJSONZeroNotRoot", + data: struct { + A *struct { + A coverMarshalJSON `json:"a"` + } + }{A: new(struct { + A coverMarshalJSON `json:"a"` + })}, + }, + { + name: "PtrHeadMarshalJSONZeroNotRootOmitEmpty", + data: struct { + A *struct { + A coverMarshalJSON `json:"a,omitempty"` + } + }{A: new(struct { + A coverMarshalJSON `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadMarshalJSONZeroNotRootString", + data: struct { + A *struct { + A coverMarshalJSON `json:"a,string"` + } + }{A: new(struct { + A coverMarshalJSON `json:"a,string"` + })}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroNotRoot", + data: struct { + A *struct { + A coverPtrMarshalJSON `json:"a"` + } + }{A: new(struct { + A coverPtrMarshalJSON `json:"a"` + })}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroNotRootOmitEmpty", + data: struct { + A *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + }{A: new(struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroNotRootString", + data: struct { + A *struct { + A coverPtrMarshalJSON `json:"a,string"` + } + }{A: new(struct { + A coverPtrMarshalJSON `json:"a,string"` + })}, + }, + + // PtrHeadMarshalJSONNotRoot + { + name: "PtrHeadMarshalJSONNotRoot", + data: struct { + A *struct { + A coverMarshalJSON `json:"a"` + } + }{A: &(struct { + A coverMarshalJSON `json:"a"` + }{A: coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONNotRootOmitEmpty", + data: struct { + A *struct { + A coverMarshalJSON `json:"a,omitempty"` + } + }{A: &(struct { + A coverMarshalJSON `json:"a,omitempty"` + }{A: coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONNotRootString", + data: struct { + A *struct { + A coverMarshalJSON `json:"a,string"` + } + }{A: &(struct { + A coverMarshalJSON `json:"a,string"` + }{A: coverMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONNotRoot", + data: struct { + A *struct { + A coverPtrMarshalJSON `json:"a"` + } + }{A: &(struct { + A coverPtrMarshalJSON `json:"a"` + }{A: coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONNotRootOmitEmpty", + data: struct { + A *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + }{A: &(struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{A: coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONNotRootString", + data: struct { + A *struct { + A coverPtrMarshalJSON `json:"a,string"` + } + }{A: &(struct { + A coverPtrMarshalJSON `json:"a,string"` + }{A: coverPtrMarshalJSON{}})}, + }, + + // PtrHeadMarshalJSONPtrNotRoot + { + name: "PtrHeadMarshalJSONPtrNotRoot", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a"` + }{A: &coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONPtrNotRootOmitEmpty", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: &coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONPtrNotRootString", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,string"` + }{A: &coverMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNotRoot", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: &coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNotRootOmitEmpty", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: &coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNotRootString", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: &coverPtrMarshalJSON{}})}, + }, + + // PtrHeadMarshalJSONPtrNilNotRoot + { + name: "PtrHeadMarshalJSONPtrNilNotRoot", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadMarshalJSONPtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadMarshalJSONPtrNilNotRootString", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,string"` + }{A: nil})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilNotRoot", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilNotRootString", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: nil})}, + }, + + // PtrHeadMarshalJSONNilNotRoot + { + name: "PtrHeadMarshalJSONNilNotRoot", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadMarshalJSONNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadMarshalJSONNilNotRootString", + data: struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONNilNotRoot", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONNilNotRootString", + data: struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + + // HeadMarshalJSONZeroMultiFieldsNotRoot + { + name: "HeadMarshalJSONZeroMultiFieldsNotRoot", + data: struct { + A struct { + A coverMarshalJSON `json:"a"` + } + B struct { + B coverMarshalJSON `json:"b"` + } + }{}, + }, + { + name: "HeadMarshalJSONZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverMarshalJSON `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadMarshalJSONZeroMultiFieldsNotRootString", + data: struct { + A struct { + A coverMarshalJSON `json:"a,string"` + } + B struct { + B coverMarshalJSON `json:"b,string"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroMultiFieldsNotRoot", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a"` + } + B struct { + B coverPtrMarshalJSON `json:"b"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalJSON `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadPtrMarshalJSONZeroMultiFieldsNotRootString", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,string"` + } + B struct { + B coverPtrMarshalJSON `json:"b,string"` + } + }{}, + }, + + // HeadMarshalJSONMultiFieldsNotRoot + { + name: "HeadMarshalJSONMultiFieldsNotRoot", + data: struct { + A struct { + A coverMarshalJSON `json:"a"` + } + B struct { + B coverMarshalJSON `json:"b"` + } + }{A: struct { + A coverMarshalJSON `json:"a"` + }{A: coverMarshalJSON{}}, B: struct { + B coverMarshalJSON `json:"b"` + }{B: coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A coverMarshalJSON `json:"a,omitempty"` + }{A: coverMarshalJSON{}}, B: struct { + B coverMarshalJSON `json:"b,omitempty"` + }{B: coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONMultiFieldsNotRootString", + data: struct { + A struct { + A coverMarshalJSON `json:"a,string"` + } + B struct { + B coverMarshalJSON `json:"b,string"` + } + }{A: struct { + A coverMarshalJSON `json:"a,string"` + }{A: coverMarshalJSON{}}, B: struct { + B coverMarshalJSON `json:"b,string"` + }{B: coverMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONMultiFieldsNotRoot", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a"` + } + B struct { + B coverPtrMarshalJSON `json:"b"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a"` + }{A: coverPtrMarshalJSON{}}, B: struct { + B coverPtrMarshalJSON `json:"b"` + }{B: coverPtrMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{A: coverPtrMarshalJSON{}}, B: struct { + B coverPtrMarshalJSON `json:"b,omitempty"` + }{B: coverPtrMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONMultiFieldsNotRootString", + data: struct { + A struct { + A coverPtrMarshalJSON `json:"a,string"` + } + B struct { + B coverPtrMarshalJSON `json:"b,string"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a,string"` + }{A: coverPtrMarshalJSON{}}, B: struct { + B coverPtrMarshalJSON `json:"b,string"` + }{B: coverPtrMarshalJSON{}}}, + }, + + // HeadMarshalJSONPtrMultiFieldsNotRoot + { + name: "HeadMarshalJSONPtrMultiFieldsNotRoot", + data: struct { + A struct { + A *coverMarshalJSON `json:"a"` + } + B struct { + B *coverMarshalJSON `json:"b"` + } + }{A: struct { + A *coverMarshalJSON `json:"a"` + }{A: &coverMarshalJSON{}}, B: struct { + B *coverMarshalJSON `json:"b"` + }{B: &coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONPtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + B struct { + B *coverMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: &coverMarshalJSON{}}, B: struct { + B *coverMarshalJSON `json:"b,omitempty"` + }{B: &coverMarshalJSON{}}}, + }, + { + name: "HeadMarshalJSONPtrMultiFieldsNotRootString", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,string"` + } + B struct { + B *coverMarshalJSON `json:"b,string"` + } + }{A: struct { + A *coverMarshalJSON `json:"a,string"` + }{A: &coverMarshalJSON{}}, B: struct { + B *coverMarshalJSON `json:"b,string"` + }{B: &coverMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONPtrMultiFieldsNotRoot", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a"` + } + B struct { + B *coverPtrMarshalJSON `json:"b"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: &coverPtrMarshalJSON{}}, B: struct { + B *coverPtrMarshalJSON `json:"b"` + }{B: &coverPtrMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONPtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + B struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: &coverPtrMarshalJSON{}}, B: struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{B: &coverPtrMarshalJSON{}}}, + }, + { + name: "HeadPtrMarshalJSONPtrMultiFieldsNotRootString", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + B struct { + B *coverPtrMarshalJSON `json:"b,string"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: &coverPtrMarshalJSON{}}, B: struct { + B *coverPtrMarshalJSON `json:"b,string"` + }{B: &coverPtrMarshalJSON{}}}, + }, + + // HeadMarshalJSONPtrNilMultiFieldsNotRoot + { + name: "HeadMarshalJSONPtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *coverMarshalJSON `json:"a"` + } + B struct { + B *coverMarshalJSON `json:"b"` + } + }{A: struct { + A *coverMarshalJSON `json:"a"` + }{A: nil}, B: struct { + B *coverMarshalJSON `json:"b"` + }{B: nil}}, + }, + { + name: "HeadMarshalJSONPtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + B struct { + B *coverMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: nil}, B: struct { + B *coverMarshalJSON `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadMarshalJSONPtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *coverMarshalJSON `json:"a,string"` + } + B struct { + B *coverMarshalJSON `json:"b,string"` + } + }{A: struct { + A *coverMarshalJSON `json:"a,string"` + }{A: nil}, B: struct { + B *coverMarshalJSON `json:"b,string"` + }{B: nil}}, + }, + { + name: "HeadPtrMarshalJSONPtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a"` + } + B struct { + B *coverPtrMarshalJSON `json:"b"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: nil}, B: struct { + B *coverPtrMarshalJSON `json:"b"` + }{B: nil}}, + }, + { + name: "HeadPtrMarshalJSONPtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + B struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: nil}, B: struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadPtrMarshalJSONPtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + B struct { + B *coverPtrMarshalJSON `json:"b,string"` + } + }{A: struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: nil}, B: struct { + B *coverPtrMarshalJSON `json:"b,string"` + }{B: nil}}, + }, + + // PtrHeadMarshalJSONZeroMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A coverMarshalJSON `json:"a"` + } + B struct { + B coverMarshalJSON `json:"b"` + } + }{}, + }, + { + name: "PtrHeadMarshalJSONZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverMarshalJSON `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadMarshalJSONZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A coverMarshalJSON `json:"a,string"` + } + B struct { + B coverMarshalJSON `json:"b,string"` + } + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A coverPtrMarshalJSON `json:"a"` + } + B struct { + B coverPtrMarshalJSON `json:"b"` + } + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalJSON `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadPtrMarshalJSONZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A coverPtrMarshalJSON `json:"a,string"` + } + B struct { + B coverPtrMarshalJSON `json:"b,string"` + } + }{}, + }, + + // PtrHeadMarshalJSONMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONMultiFieldsNotRoot", + data: &struct { + A struct { + A coverMarshalJSON `json:"a"` + } + B struct { + B coverMarshalJSON `json:"b"` + } + }{A: struct { + A coverMarshalJSON `json:"a"` + }{A: coverMarshalJSON{}}, B: struct { + B coverMarshalJSON `json:"b"` + }{B: coverMarshalJSON{}}}, + }, + { + name: "PtrHeadMarshalJSONMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A coverMarshalJSON `json:"a,omitempty"` + }{A: coverMarshalJSON{}}, B: struct { + B coverMarshalJSON `json:"b,omitempty"` + }{B: coverMarshalJSON{}}}, + }, + { + name: "PtrHeadMarshalJSONMultiFieldsNotRootString", + data: &struct { + A struct { + A coverMarshalJSON `json:"a,string"` + } + B struct { + B coverMarshalJSON `json:"b,string"` + } + }{A: struct { + A coverMarshalJSON `json:"a,string"` + }{A: coverMarshalJSON{}}, B: struct { + B coverMarshalJSON `json:"b,string"` + }{B: coverMarshalJSON{}}}, + }, + { + name: "PtrHeadPtrMarshalJSONMultiFieldsNotRoot", + data: &struct { + A struct { + A coverPtrMarshalJSON `json:"a"` + } + B struct { + B coverPtrMarshalJSON `json:"b"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a"` + }{A: coverPtrMarshalJSON{}}, B: struct { + B coverPtrMarshalJSON `json:"b"` + }{B: coverPtrMarshalJSON{}}}, + }, + { + name: "PtrHeadPtrMarshalJSONMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalJSON `json:"b,omitempty"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + }{A: coverPtrMarshalJSON{}}, B: struct { + B coverPtrMarshalJSON `json:"b,omitempty"` + }{B: coverPtrMarshalJSON{}}}, + }, + { + name: "PtrHeadPtrMarshalJSONMultiFieldsNotRootString", + data: &struct { + A struct { + A coverPtrMarshalJSON `json:"a,string"` + } + B struct { + B coverPtrMarshalJSON `json:"b,string"` + } + }{A: struct { + A coverPtrMarshalJSON `json:"a,string"` + }{A: coverPtrMarshalJSON{}}, B: struct { + B coverPtrMarshalJSON `json:"b,string"` + }{B: coverPtrMarshalJSON{}}}, + }, + + // PtrHeadMarshalJSONPtrMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONPtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a"` + } + B *struct { + B *coverMarshalJSON `json:"b"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a"` + }{A: &coverMarshalJSON{}}), B: &(struct { + B *coverMarshalJSON `json:"b"` + }{B: &coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONPtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + B *struct { + B *coverMarshalJSON `json:"b,omitempty"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,omitempty"` + }{A: &coverMarshalJSON{}}), B: &(struct { + B *coverMarshalJSON `json:"b,omitempty"` + }{B: &coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONPtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + } + B *struct { + B *coverMarshalJSON `json:"b,string"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,string"` + }{A: &coverMarshalJSON{}}), B: &(struct { + B *coverMarshalJSON `json:"b,string"` + }{B: &coverMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + } + B *struct { + B *coverPtrMarshalJSON `json:"b"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a"` + }{A: &coverPtrMarshalJSON{}}), B: &(struct { + B *coverPtrMarshalJSON `json:"b"` + }{B: &coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + B *struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + }{A: &coverPtrMarshalJSON{}}), B: &(struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{B: &coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + B *struct { + B *coverPtrMarshalJSON `json:"b,string"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,string"` + }{A: &coverPtrMarshalJSON{}}), B: &(struct { + B *coverPtrMarshalJSON `json:"b,string"` + }{B: &coverPtrMarshalJSON{}})}, + }, + + // PtrHeadMarshalJSONPtrNilMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONPtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a"` + } + B *struct { + B *coverMarshalJSON `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *coverMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + } `json:",string"` + B *struct { + B *coverMarshalJSON `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + } + B *struct { + B *coverPtrMarshalJSON `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + } `json:",string"` + B *struct { + B *coverPtrMarshalJSON `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalJSONNilMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverMarshalJSON `json:"a"` + } + B *struct { + B *coverMarshalJSON `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + } + B *struct { + B *coverMarshalJSON `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + } + B *struct { + B *coverMarshalJSON `json:"b,string"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + } + B *struct { + B *coverPtrMarshalJSON `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + } + B *struct { + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + } + B *struct { + B *coverPtrMarshalJSON `json:"b,string"` + } + })(nil), + }, + + // PtrHeadMarshalJSONDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + } + B *struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + } + }{A: &(struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}}), B: &(struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + } + B *struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + } + }{A: &(struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}}), B: &(struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}})}, + }, + { + name: "PtrHeadMarshalJSONDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + } + B *struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + } + }{A: &(struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}}), B: &(struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + }{A: coverMarshalJSON{}, B: coverMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + } + B *struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + } + }{A: &(struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}}), B: &(struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + } + B *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + } + }{A: &(struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}}), B: &(struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}})}, + }, + { + name: "PtrHeadPtrMarshalJSONDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + } + B *struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + } + }{A: &(struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}}), B: &(struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + }{A: coverPtrMarshalJSON{}, B: coverPtrMarshalJSON{}})}, + }, + + // PtrHeadMarshalJSONNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + } + B *struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + } + B *struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + } + B *struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + } + B *struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalJSONNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + } + B *struct { + A coverMarshalJSON `json:"a"` + B coverMarshalJSON `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + } + B *struct { + A coverMarshalJSON `json:"a,omitempty"` + B coverMarshalJSON `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMarshalJSONNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + } + B *struct { + A coverMarshalJSON `json:"a,string"` + B coverMarshalJSON `json:"b,string"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + } + B *struct { + A coverPtrMarshalJSON `json:"a"` + B coverPtrMarshalJSON `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + } + B *struct { + A coverPtrMarshalJSON `json:"a,omitempty"` + B coverPtrMarshalJSON `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + } + B *struct { + A coverPtrMarshalJSON `json:"a,string"` + B coverPtrMarshalJSON `json:"b,string"` + } + })(nil), + }, + + // PtrHeadMarshalJSONPtrDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONPtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + } + B *struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}}), B: &(struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadMarshalJSONPtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + } + B *struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}}), B: &(struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadMarshalJSONPtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + } + B *struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + } + }{A: &(struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + }{A: &coverMarshalJSON{}, B: &coverMarshalJSON{}}), B: &(struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}}), B: &(struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}}), B: &(struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + } + }{A: &(struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + }{A: &coverPtrMarshalJSON{}, B: &coverPtrMarshalJSON{}}), B: &(struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + }{A: nil, B: nil})}, + }, + + // PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + } + B *struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + } + B *struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + } + B *struct { + A *coverMarshalJSON `json:"a"` + B *coverMarshalJSON `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + } + B *struct { + A *coverMarshalJSON `json:"a,omitempty"` + B *coverMarshalJSON `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMarshalJSONPtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + } + B *struct { + A *coverMarshalJSON `json:"a,string"` + B *coverMarshalJSON `json:"b,string"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a"` + B *coverPtrMarshalJSON `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a,omitempty"` + B *coverPtrMarshalJSON `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalJSONPtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + } + B *struct { + A *coverPtrMarshalJSON `json:"a,string"` + B *coverPtrMarshalJSON `json:"b,string"` + } + })(nil), + }, + + // AnonymousHeadMarshalJSON + { + name: "AnonymousHeadMarshalJSON", + data: struct { + structMarshalJSON + B coverMarshalJSON `json:"b"` + }{ + structMarshalJSON: structMarshalJSON{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadMarshalJSONOmitEmpty", + data: struct { + structMarshalJSONOmitEmpty + B coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONOmitEmpty: structMarshalJSONOmitEmpty{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadMarshalJSONString", + data: struct { + structMarshalJSONString + B coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONString: structMarshalJSONString{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSON", + data: struct { + structPtrMarshalJSON + B coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSON: structPtrMarshalJSON{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONOmitEmpty", + data: struct { + structPtrMarshalJSONOmitEmpty + B coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONOmitEmpty: structPtrMarshalJSONOmitEmpty{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONString", + data: struct { + structPtrMarshalJSONString + B coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONString: structPtrMarshalJSONString{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + + // PtrAnonymousHeadMarshalJSON + { + name: "PtrAnonymousHeadMarshalJSON", + data: struct { + *structMarshalJSON + B coverMarshalJSON `json:"b"` + }{ + structMarshalJSON: &structMarshalJSON{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONOmitEmpty", + data: struct { + *structMarshalJSONOmitEmpty + B coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONOmitEmpty: &structMarshalJSONOmitEmpty{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONString", + data: struct { + *structMarshalJSONString + B coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONString: &structMarshalJSONString{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSON", + data: struct { + *structPtrMarshalJSON + B coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSON: &structPtrMarshalJSON{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONOmitEmpty", + data: struct { + *structPtrMarshalJSONOmitEmpty + B coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONOmitEmpty: &structPtrMarshalJSONOmitEmpty{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONString", + data: struct { + *structPtrMarshalJSONString + B coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONString: &structPtrMarshalJSONString{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + + // PtrAnonymousHeadMarshalJSONNil + { + name: "PtrAnonymousHeadMarshalJSONNil", + data: struct { + *structMarshalJSON + B coverMarshalJSON `json:"b"` + }{ + structMarshalJSON: &structMarshalJSON{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONNilOmitEmpty", + data: struct { + *structMarshalJSONOmitEmpty + B coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONOmitEmpty: &structMarshalJSONOmitEmpty{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONNilString", + data: struct { + *structMarshalJSONString + B coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONString: &structMarshalJSONString{A: coverMarshalJSON{}}, + B: coverMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONNil", + data: struct { + *structPtrMarshalJSON + B coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSON: &structPtrMarshalJSON{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONNilOmitEmpty", + data: struct { + *structPtrMarshalJSONOmitEmpty + B coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONOmitEmpty: &structPtrMarshalJSONOmitEmpty{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONNilString", + data: struct { + *structPtrMarshalJSONString + B coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONString: &structPtrMarshalJSONString{A: coverPtrMarshalJSON{}}, + B: coverPtrMarshalJSON{}, + }, + }, + + // NilPtrAnonymousHeadMarshalJSON + { + name: "NilPtrAnonymousHeadMarshalJSON", + data: struct { + *structMarshalJSON + B coverMarshalJSON `json:"b"` + }{ + structMarshalJSON: nil, + B: coverMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONOmitEmpty", + data: struct { + *structMarshalJSONOmitEmpty + B coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONOmitEmpty: nil, + B: coverMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONString", + data: struct { + *structMarshalJSONString + B coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONString: nil, + B: coverMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSON", + data: struct { + *structPtrMarshalJSON + B coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSON: nil, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONOmitEmpty", + data: struct { + *structPtrMarshalJSONOmitEmpty + B coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONOmitEmpty: nil, + B: coverPtrMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONString", + data: struct { + *structPtrMarshalJSONString + B coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONString: nil, + B: coverPtrMarshalJSON{}, + }, + }, + + // AnonymousHeadMarshalJSONPtr + { + name: "AnonymousHeadMarshalJSONPtr", + data: struct { + structMarshalJSONPtr + B *coverMarshalJSON `json:"b"` + }{ + structMarshalJSONPtr: structMarshalJSONPtr{A: &coverMarshalJSON{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrOmitEmpty", + data: struct { + structMarshalJSONPtrOmitEmpty + B *coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONPtrOmitEmpty: structMarshalJSONPtrOmitEmpty{A: &coverMarshalJSON{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrString", + data: struct { + structMarshalJSONPtrString + B *coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONPtrString: structMarshalJSONPtrString{A: &coverMarshalJSON{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtr", + data: struct { + structPtrMarshalJSONPtr + B *coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSONPtr: structPtrMarshalJSONPtr{A: &coverPtrMarshalJSON{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrOmitEmpty", + data: struct { + structPtrMarshalJSONPtrOmitEmpty + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONPtrOmitEmpty: structPtrMarshalJSONPtrOmitEmpty{A: &coverPtrMarshalJSON{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrString", + data: struct { + structPtrMarshalJSONPtrString + B *coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONPtrString: structPtrMarshalJSONPtrString{A: &coverPtrMarshalJSON{}}, + B: nil, + }, + }, + + // AnonymousHeadMarshalJSONPtrNil + { + name: "AnonymousHeadMarshalJSONPtrNil", + data: struct { + structMarshalJSONPtr + B *coverMarshalJSON `json:"b"` + }{ + structMarshalJSONPtr: structMarshalJSONPtr{A: nil}, + B: &coverMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrNilOmitEmpty", + data: struct { + structMarshalJSONPtrOmitEmpty + B *coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONPtrOmitEmpty: structMarshalJSONPtrOmitEmpty{A: nil}, + B: &coverMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrNilString", + data: struct { + structMarshalJSONPtrString + B *coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONPtrString: structMarshalJSONPtrString{A: nil}, + B: &coverMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrNil", + data: struct { + structPtrMarshalJSONPtr + B *coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSONPtr: structPtrMarshalJSONPtr{A: nil}, + B: &coverPtrMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrNilOmitEmpty", + data: struct { + structPtrMarshalJSONPtrOmitEmpty + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONPtrOmitEmpty: structPtrMarshalJSONPtrOmitEmpty{A: nil}, + B: &coverPtrMarshalJSON{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrNilString", + data: struct { + structPtrMarshalJSONPtrString + B *coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONPtrString: structPtrMarshalJSONPtrString{A: nil}, + B: &coverPtrMarshalJSON{}, + }, + }, + + // PtrAnonymousHeadMarshalJSONPtr + { + name: "PtrAnonymousHeadMarshalJSONPtr", + data: struct { + *structMarshalJSONPtr + B *coverMarshalJSON `json:"b"` + }{ + structMarshalJSONPtr: &structMarshalJSONPtr{A: &coverMarshalJSON{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONPtrOmitEmpty", + data: struct { + *structMarshalJSONPtrOmitEmpty + B *coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONPtrOmitEmpty: &structMarshalJSONPtrOmitEmpty{A: &coverMarshalJSON{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONPtrString", + data: struct { + *structMarshalJSONPtrString + B *coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONPtrString: &structMarshalJSONPtrString{A: &coverMarshalJSON{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONPtr", + data: struct { + *structPtrMarshalJSONPtr + B *coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSONPtr: &structPtrMarshalJSONPtr{A: &coverPtrMarshalJSON{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONPtrOmitEmpty", + data: struct { + *structPtrMarshalJSONPtrOmitEmpty + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONPtrOmitEmpty: &structPtrMarshalJSONPtrOmitEmpty{A: &coverPtrMarshalJSON{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONPtrString", + data: struct { + *structPtrMarshalJSONPtrString + B *coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONPtrString: &structPtrMarshalJSONPtrString{A: &coverPtrMarshalJSON{}}, + B: nil, + }, + }, + + // NilPtrAnonymousHeadMarshalJSONPtr + { + name: "NilPtrAnonymousHeadMarshalJSONPtr", + data: struct { + *structMarshalJSONPtr + B *coverMarshalJSON `json:"b"` + }{ + structMarshalJSONPtr: nil, + B: &coverMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONPtrOmitEmpty", + data: struct { + *structMarshalJSONPtrOmitEmpty + B *coverMarshalJSON `json:"b,omitempty"` + }{ + structMarshalJSONPtrOmitEmpty: nil, + B: &coverMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONPtrString", + data: struct { + *structMarshalJSONPtrString + B *coverMarshalJSON `json:"b,string"` + }{ + structMarshalJSONPtrString: nil, + B: &coverMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONPtr", + data: struct { + *structPtrMarshalJSONPtr + B *coverPtrMarshalJSON `json:"b"` + }{ + structPtrMarshalJSONPtr: nil, + B: &coverPtrMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONPtrOmitEmpty", + data: struct { + *structPtrMarshalJSONPtrOmitEmpty + B *coverPtrMarshalJSON `json:"b,omitempty"` + }{ + structPtrMarshalJSONPtrOmitEmpty: nil, + B: &coverPtrMarshalJSON{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONPtrString", + data: struct { + *structPtrMarshalJSONPtrString + B *coverPtrMarshalJSON `json:"b,string"` + }{ + structPtrMarshalJSONPtrString: nil, + B: &coverPtrMarshalJSON{}, + }, + }, + + // AnonymousHeadMarshalJSONOnly + { + name: "AnonymousHeadMarshalJSONOnly", + data: struct { + structMarshalJSON + }{ + structMarshalJSON: structMarshalJSON{A: coverMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadMarshalJSONOnlyOmitEmpty", + data: struct { + structMarshalJSONOmitEmpty + }{ + structMarshalJSONOmitEmpty: structMarshalJSONOmitEmpty{A: coverMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadMarshalJSONOnlyString", + data: struct { + structMarshalJSONString + }{ + structMarshalJSONString: structMarshalJSONString{A: coverMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONOnly", + data: struct { + structPtrMarshalJSON + }{ + structPtrMarshalJSON: structPtrMarshalJSON{A: coverPtrMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONOnlyOmitEmpty", + data: struct { + structPtrMarshalJSONOmitEmpty + }{ + structPtrMarshalJSONOmitEmpty: structPtrMarshalJSONOmitEmpty{A: coverPtrMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONOnlyString", + data: struct { + structPtrMarshalJSONString + }{ + structPtrMarshalJSONString: structPtrMarshalJSONString{A: coverPtrMarshalJSON{}}, + }, + }, + + // PtrAnonymousHeadMarshalJSONOnly + { + name: "PtrAnonymousHeadMarshalJSONOnly", + data: struct { + *structMarshalJSON + }{ + structMarshalJSON: &structMarshalJSON{A: coverMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONOnlyOmitEmpty", + data: struct { + *structMarshalJSONOmitEmpty + }{ + structMarshalJSONOmitEmpty: &structMarshalJSONOmitEmpty{A: coverMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONOnlyString", + data: struct { + *structMarshalJSONString + }{ + structMarshalJSONString: &structMarshalJSONString{A: coverMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONOnly", + data: struct { + *structPtrMarshalJSON + }{ + structPtrMarshalJSON: &structPtrMarshalJSON{A: coverPtrMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONOnlyOmitEmpty", + data: struct { + *structPtrMarshalJSONOmitEmpty + }{ + structPtrMarshalJSONOmitEmpty: &structPtrMarshalJSONOmitEmpty{A: coverPtrMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONOnlyString", + data: struct { + *structPtrMarshalJSONString + }{ + structPtrMarshalJSONString: &structPtrMarshalJSONString{A: coverPtrMarshalJSON{}}, + }, + }, + + // NilPtrAnonymousHeadMarshalJSONOnly + { + name: "NilPtrAnonymousHeadMarshalJSONOnly", + data: struct { + *structMarshalJSON + }{ + structMarshalJSON: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONOnlyOmitEmpty", + data: struct { + *structMarshalJSONOmitEmpty + }{ + structMarshalJSONOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONOnlyString", + data: struct { + *structMarshalJSONString + }{ + structMarshalJSONString: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONOnly", + data: struct { + *structPtrMarshalJSON + }{ + structPtrMarshalJSON: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONOnlyOmitEmpty", + data: struct { + *structPtrMarshalJSONOmitEmpty + }{ + structPtrMarshalJSONOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONOnlyString", + data: struct { + *structPtrMarshalJSONString + }{ + structPtrMarshalJSONString: nil, + }, + }, + + // AnonymousHeadMarshalJSONPtrOnly + { + name: "AnonymousHeadMarshalJSONPtrOnly", + data: struct { + structMarshalJSONPtr + }{ + structMarshalJSONPtr: structMarshalJSONPtr{A: &coverMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrOnlyOmitEmpty", + data: struct { + structMarshalJSONPtrOmitEmpty + }{ + structMarshalJSONPtrOmitEmpty: structMarshalJSONPtrOmitEmpty{A: &coverMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrOnlyString", + data: struct { + structMarshalJSONPtrString + }{ + structMarshalJSONPtrString: structMarshalJSONPtrString{A: &coverMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrOnly", + data: struct { + structPtrMarshalJSONPtr + }{ + structPtrMarshalJSONPtr: structPtrMarshalJSONPtr{A: &coverPtrMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrOnlyOmitEmpty", + data: struct { + structPtrMarshalJSONPtrOmitEmpty + }{ + structPtrMarshalJSONPtrOmitEmpty: structPtrMarshalJSONPtrOmitEmpty{A: &coverPtrMarshalJSON{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrOnlyString", + data: struct { + structPtrMarshalJSONPtrString + }{ + structPtrMarshalJSONPtrString: structPtrMarshalJSONPtrString{A: &coverPtrMarshalJSON{}}, + }, + }, + + // AnonymousHeadMarshalJSONPtrNilOnly + { + name: "AnonymousHeadMarshalJSONPtrNilOnly", + data: struct { + structMarshalJSONPtr + }{ + structMarshalJSONPtr: structMarshalJSONPtr{A: nil}, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrNilOnlyOmitEmpty", + data: struct { + structMarshalJSONPtrOmitEmpty + }{ + structMarshalJSONPtrOmitEmpty: structMarshalJSONPtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadMarshalJSONPtrNilOnlyString", + data: struct { + structMarshalJSONPtrString + }{ + structMarshalJSONPtrString: structMarshalJSONPtrString{A: nil}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrNilOnly", + data: struct { + structPtrMarshalJSONPtr + }{ + structPtrMarshalJSONPtr: structPtrMarshalJSONPtr{A: nil}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrNilOnlyOmitEmpty", + data: struct { + structPtrMarshalJSONPtrOmitEmpty + }{ + structPtrMarshalJSONPtrOmitEmpty: structPtrMarshalJSONPtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadPtrMarshalJSONPtrNilOnlyString", + data: struct { + structPtrMarshalJSONPtrString + }{ + structPtrMarshalJSONPtrString: structPtrMarshalJSONPtrString{A: nil}, + }, + }, + + // PtrAnonymousHeadMarshalJSONPtrOnly + { + name: "PtrAnonymousHeadMarshalJSONPtrOnly", + data: struct { + *structMarshalJSONPtr + }{ + structMarshalJSONPtr: &structMarshalJSONPtr{A: &coverMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONPtrOnlyOmitEmpty", + data: struct { + *structMarshalJSONPtrOmitEmpty + }{ + structMarshalJSONPtrOmitEmpty: &structMarshalJSONPtrOmitEmpty{A: &coverMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalJSONPtrOnlyString", + data: struct { + *structMarshalJSONPtrString + }{ + structMarshalJSONPtrString: &structMarshalJSONPtrString{A: &coverMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONPtrOnly", + data: struct { + *structPtrMarshalJSONPtr + }{ + structPtrMarshalJSONPtr: &structPtrMarshalJSONPtr{A: &coverPtrMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONPtrOnlyOmitEmpty", + data: struct { + *structPtrMarshalJSONPtrOmitEmpty + }{ + structPtrMarshalJSONPtrOmitEmpty: &structPtrMarshalJSONPtrOmitEmpty{A: &coverPtrMarshalJSON{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalJSONPtrOnlyString", + data: struct { + *structPtrMarshalJSONPtrString + }{ + structPtrMarshalJSONPtrString: &structPtrMarshalJSONPtrString{A: &coverPtrMarshalJSON{}}, + }, + }, + + // NilPtrAnonymousHeadMarshalJSONPtrOnly + { + name: "NilPtrAnonymousHeadMarshalJSONPtrOnly", + data: struct { + *structMarshalJSONPtr + }{ + structMarshalJSONPtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONPtrOnlyOmitEmpty", + data: struct { + *structMarshalJSONPtrOmitEmpty + }{ + structMarshalJSONPtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalJSONPtrOnlyString", + data: struct { + *structMarshalJSONPtrString + }{ + structMarshalJSONPtrString: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONPtrOnly", + data: struct { + *structPtrMarshalJSONPtr + }{ + structPtrMarshalJSONPtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONPtrOnlyOmitEmpty", + data: struct { + *structPtrMarshalJSONPtrOmitEmpty + }{ + structPtrMarshalJSONPtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalJSONPtrOnlyString", + data: struct { + *structPtrMarshalJSONPtrString + }{ + structPtrMarshalJSONPtrString: nil, + }, + }, + } + for _, test := range tests { + for _, indent := range []bool{true, false} { + for _, htmlEscape := range []bool{true, false} { + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + enc.SetEscapeHTML(htmlEscape) + if indent { + enc.SetIndent("", " ") + } + if err := enc.Encode(test.data); err != nil { + 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:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String()) + } + } + } + } +} diff --git a/cover_marshal_text_test.go b/cover_marshal_text_test.go new file mode 100644 index 0000000..62022ae --- /dev/null +++ b/cover_marshal_text_test.go @@ -0,0 +1,3546 @@ +package json_test + +import ( + "bytes" + "testing" + + "github.com/goccy/go-json" +) + +type coverMarshalText struct { + A int +} + +func (c coverMarshalText) MarshalText() ([]byte, error) { + return []byte(`"hello"`), nil +} + +type coverPtrMarshalText struct { + B int +} + +func (c *coverPtrMarshalText) MarshalText() ([]byte, error) { + return []byte(`"hello"`), nil +} + +func TestCoverMarshalText(t *testing.T) { + type structMarshalText struct { + A coverMarshalText `json:"a"` + } + type structMarshalTextOmitEmpty struct { + A coverMarshalText `json:"a,omitempty"` + } + type structMarshalTextString struct { + A coverMarshalText `json:"a,string"` + } + type structPtrMarshalText struct { + A coverPtrMarshalText `json:"a"` + } + type structPtrMarshalTextOmitEmpty struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + type structPtrMarshalTextString struct { + A coverPtrMarshalText `json:"a,string"` + } + + type structMarshalTextPtr struct { + A *coverMarshalText `json:"a"` + } + type structMarshalTextPtrOmitEmpty struct { + A *coverMarshalText `json:"a,omitempty"` + } + type structMarshalTextPtrString struct { + A *coverMarshalText `json:"a,string"` + } + type structPtrMarshalTextPtr struct { + A *coverPtrMarshalText `json:"a"` + } + type structPtrMarshalTextPtrOmitEmpty struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + type structPtrMarshalTextPtrString struct { + A *coverPtrMarshalText `json:"a,string"` + } + + tests := []struct { + name string + data interface{} + }{ + // HeadMarshalTextZero + { + name: "HeadMarshalTextZero", + data: struct { + A coverMarshalText `json:"a"` + }{}, + }, + { + name: "HeadMarshalTextZeroOmitEmpty", + data: struct { + A coverMarshalText `json:"a,omitempty"` + }{}, + }, + { + name: "HeadMarshalTextZeroString", + data: struct { + A coverMarshalText `json:"a,string"` + }{}, + }, + { + name: "HeadPtrMarshalTextZero", + data: struct { + A coverPtrMarshalText `json:"a"` + }{}, + }, + { + name: "HeadPtrMarshalTextZeroOmitEmpty", + data: struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{}, + }, + { + name: "HeadPtrMarshalTextZeroString", + data: struct { + A coverPtrMarshalText `json:"a,string"` + }{}, + }, + + // HeadMarshalText + { + name: "HeadMarshalText", + data: struct { + A coverMarshalText `json:"a"` + }{A: coverMarshalText{}}, + }, + { + name: "HeadMarshalTextOmitEmpty", + data: struct { + A coverMarshalText `json:"a,omitempty"` + }{A: coverMarshalText{}}, + }, + { + name: "HeadMarshalTextString", + data: struct { + A coverMarshalText `json:"a,string"` + }{A: coverMarshalText{}}, + }, + { + name: "HeadPtrMarshalText", + data: struct { + A coverPtrMarshalText `json:"a"` + }{A: coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextOmitEmpty", + data: struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{A: coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextString", + data: struct { + A coverPtrMarshalText `json:"a,string"` + }{A: coverPtrMarshalText{}}, + }, + + // HeadMarshalTextPtr + { + name: "HeadMarshalTextPtr", + data: struct { + A *coverMarshalText `json:"a"` + }{A: &coverMarshalText{}}, + }, + { + name: "HeadMarshalTextPtrOmitEmpty", + data: struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: &coverMarshalText{}}, + }, + { + name: "HeadMarshalTextPtrString", + data: struct { + A *coverMarshalText `json:"a,string"` + }{A: &coverMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextPtr", + data: struct { + A *coverPtrMarshalText `json:"a"` + }{A: &coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextPtrOmitEmpty", + data: struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: &coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextPtrString", + data: struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: &coverPtrMarshalText{}}, + }, + + // HeadMarshalTextPtrNil + { + name: "HeadMarshalTextPtrNil", + data: struct { + A *coverMarshalText `json:"a"` + }{A: nil}, + }, + { + name: "HeadMarshalTextPtrNilOmitEmpty", + data: struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadMarshalTextPtrNilString", + data: struct { + A *coverMarshalText `json:"a,string"` + }{A: nil}, + }, + { + name: "HeadPtrMarshalTextPtrNil", + data: struct { + A *coverPtrMarshalText `json:"a"` + }{A: nil}, + }, + { + name: "HeadPtrMarshalTextPtrNilOmitEmpty", + data: struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadPtrMarshalTextPtrNilString", + data: struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadMarshalTextZero + { + name: "PtrHeadMarshalTextZero", + data: &struct { + A coverMarshalText `json:"a"` + }{}, + }, + { + name: "PtrHeadMarshalTextZeroOmitEmpty", + data: &struct { + A coverMarshalText `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadMarshalTextZeroString", + data: &struct { + A coverMarshalText `json:"a,string"` + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZero", + data: &struct { + A coverPtrMarshalText `json:"a"` + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroOmitEmpty", + data: &struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroString", + data: &struct { + A coverPtrMarshalText `json:"a,string"` + }{}, + }, + + // PtrHeadMarshalText + { + name: "PtrHeadMarshalText", + data: &struct { + A coverMarshalText `json:"a"` + }{A: coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextOmitEmpty", + data: &struct { + A coverMarshalText `json:"a,omitempty"` + }{A: coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextString", + data: &struct { + A coverMarshalText `json:"a,string"` + }{A: coverMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalText", + data: &struct { + A coverPtrMarshalText `json:"a"` + }{A: coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextOmitEmpty", + data: &struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{A: coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextString", + data: &struct { + A coverPtrMarshalText `json:"a,string"` + }{A: coverPtrMarshalText{}}, + }, + + // PtrHeadMarshalTextPtr + { + name: "PtrHeadMarshalTextPtr", + data: &struct { + A *coverMarshalText `json:"a"` + }{A: &coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextPtrOmitEmpty", + data: &struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: &coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextPtrString", + data: &struct { + A *coverMarshalText `json:"a,string"` + }{A: &coverMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextPtr", + data: &struct { + A *coverPtrMarshalText `json:"a"` + }{A: &coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextPtrOmitEmpty", + data: &struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: &coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextPtrString", + data: &struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: &coverPtrMarshalText{}}, + }, + + // PtrHeadMarshalTextPtrNil + { + name: "PtrHeadMarshalTextPtrNil", + data: &struct { + A *coverMarshalText `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilOmitEmpty", + data: &struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilString", + data: &struct { + A *coverMarshalText `json:"a,string"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNil", + data: &struct { + A *coverPtrMarshalText `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilOmitEmpty", + data: &struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilString", + data: &struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadMarshalTextNil + { + name: "PtrHeadMarshalTextNil", + data: (*struct { + A *coverMarshalText `json:"a"` + })(nil), + }, + { + name: "PtrHeadMarshalTextNilOmitEmpty", + data: (*struct { + A *coverMarshalText `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadMarshalTextNilString", + data: (*struct { + A *coverMarshalText `json:"a,string"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNil", + data: (*struct { + A *coverPtrMarshalText `json:"a"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilOmitEmpty", + data: (*struct { + A *coverPtrMarshalText `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilString", + data: (*struct { + A *coverPtrMarshalText `json:"a,string"` + })(nil), + }, + + // HeadMarshalTextZeroMultiFields + { + name: "HeadMarshalTextZeroMultiFields", + data: struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + C coverMarshalText `json:"c"` + }{}, + }, + { + name: "HeadMarshalTextZeroMultiFieldsOmitEmpty", + data: struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + C coverMarshalText `json:"c,omitempty"` + }{}, + }, + { + name: "HeadMarshalTextZeroMultiFields", + data: struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + C coverMarshalText `json:"c,string"` + }{}, + }, + { + name: "HeadPtrMarshalTextZeroMultiFields", + data: struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + C coverPtrMarshalText `json:"c"` + }{}, + }, + { + name: "HeadPtrMarshalTextZeroMultiFieldsOmitEmpty", + data: struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + C coverPtrMarshalText `json:"c,omitempty"` + }{}, + }, + { + name: "HeadPtrMarshalTextZeroMultiFields", + data: struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + C coverPtrMarshalText `json:"c,string"` + }{}, + }, + + // HeadMarshalTextMultiFields + { + name: "HeadMarshalTextMultiFields", + data: struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + C coverMarshalText `json:"c"` + }{A: coverMarshalText{}, B: coverMarshalText{}, C: coverMarshalText{}}, + }, + { + name: "HeadMarshalTextMultiFieldsOmitEmpty", + data: struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + C coverMarshalText `json:"c,omitempty"` + }{A: coverMarshalText{}, B: coverMarshalText{}, C: coverMarshalText{}}, + }, + { + name: "HeadMarshalTextMultiFieldsString", + data: struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + C coverMarshalText `json:"c,string"` + }{A: coverMarshalText{}, B: coverMarshalText{}, C: coverMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextMultiFields", + data: struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + C coverPtrMarshalText `json:"c"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}, C: coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextMultiFieldsOmitEmpty", + data: struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + C coverPtrMarshalText `json:"c,omitempty"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}, C: coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextMultiFieldsString", + data: struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + C coverPtrMarshalText `json:"c,string"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}, C: coverPtrMarshalText{}}, + }, + + // HeadMarshalTextPtrMultiFields + { + name: "HeadMarshalTextPtrMultiFields", + data: struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + C *coverMarshalText `json:"c"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}, C: &coverMarshalText{}}, + }, + { + name: "HeadMarshalTextPtrMultiFieldsOmitEmpty", + data: struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + C *coverMarshalText `json:"c,omitempty"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}, C: &coverMarshalText{}}, + }, + { + name: "HeadMarshalTextPtrMultiFieldsString", + data: struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + C *coverMarshalText `json:"c,string"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}, C: &coverMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextPtrMultiFields", + data: struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + C *coverPtrMarshalText `json:"c"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}, C: &coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextPtrMultiFieldsOmitEmpty", + data: struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + C *coverPtrMarshalText `json:"c,omitempty"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}, C: &coverPtrMarshalText{}}, + }, + { + name: "HeadPtrMarshalTextPtrMultiFieldsString", + data: struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + C *coverPtrMarshalText `json:"c,string"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}, C: &coverPtrMarshalText{}}, + }, + + // HeadMarshalTextPtrNilMultiFields + { + name: "HeadMarshalTextPtrNilMultiFields", + data: struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + C *coverMarshalText `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadMarshalTextPtrNilMultiFieldsOmitEmpty", + data: struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + C *coverMarshalText `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadMarshalTextPtrNilMultiFieldsString", + data: struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + C *coverMarshalText `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadPtrMarshalTextPtrNilMultiFields", + data: struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + C *coverPtrMarshalText `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadPtrMarshalTextPtrNilMultiFieldsOmitEmpty", + data: struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + C *coverPtrMarshalText `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadPtrMarshalTextPtrNilMultiFieldsString", + data: struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + C *coverPtrMarshalText `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + + // PtrHeadMarshalTextZeroMultiFields + { + name: "PtrHeadMarshalTextZeroMultiFields", + data: &struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + }{}, + }, + { + name: "PtrHeadMarshalTextZeroMultiFieldsOmitEmpty", + data: &struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadMarshalTextZeroMultiFieldsString", + data: &struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroMultiFields", + data: &struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroMultiFieldsOmitEmpty", + data: &struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroMultiFieldsString", + data: &struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + }{}, + }, + + // PtrHeadMarshalTextMultiFields + { + name: "PtrHeadMarshalTextMultiFields", + data: &struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + }{A: coverMarshalText{}, B: coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextMultiFieldsOmitEmpty", + data: &struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + }{A: coverMarshalText{}, B: coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextMultiFieldsString", + data: &struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + }{A: coverMarshalText{}, B: coverMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextMultiFields", + data: &struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextMultiFieldsOmitEmpty", + data: &struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextMultiFieldsString", + data: &struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}}, + }, + + // PtrHeadMarshalTextPtrMultiFields + { + name: "PtrHeadMarshalTextPtrMultiFields", + data: &struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextPtrMultiFieldsOmitEmpty", + data: &struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}}, + }, + { + name: "PtrHeadMarshalTextPtrMultiFieldsString", + data: &struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextPtrMultiFields", + data: &struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextPtrMultiFieldsOmitEmpty", + data: &struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}}, + }, + { + name: "PtrHeadPtrMarshalTextPtrMultiFieldsString", + data: &struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}}, + }, + + // PtrHeadMarshalTextPtrNilMultiFields + { + name: "PtrHeadMarshalTextPtrNilMultiFields", + data: &struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilMultiFieldsOmitEmpty", + data: &struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilMultiFieldsString", + data: &struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilMultiFields", + data: &struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilMultiFieldsOmitEmpty", + data: &struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilMultiFieldsString", + data: &struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalTextNilMultiFields + { + name: "PtrHeadMarshalTextNilMultiFields", + data: (*struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + })(nil), + }, + { + name: "PtrHeadMarshalTextNilMultiFieldsOmitEmpty", + data: (*struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadMarshalTextNilMultiFieldsString", + data: (*struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFields", + data: (*struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFieldsOmitEmpty", + data: (*struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFieldsString", + data: (*struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + })(nil), + }, + + // PtrHeadMarshalTextNilMultiFields + { + name: "PtrHeadMarshalTextNilMultiFields", + data: (*struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + })(nil), + }, + { + name: "PtrHeadMarshalTextNilMultiFieldsOmitEmpty", + data: (*struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadMarshalTextNilMultiFieldsString", + data: (*struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFields", + data: (*struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFieldsOmitEmpty", + data: (*struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFieldsString", + data: (*struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + })(nil), + }, + + // HeadMarshalTextZeroNotRoot + { + name: "HeadMarshalTextZeroNotRoot", + data: struct { + A struct { + A coverMarshalText `json:"a"` + } + }{}, + }, + { + name: "HeadMarshalTextZeroNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalText `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadMarshalTextZeroNotRootString", + data: struct { + A struct { + A coverMarshalText `json:"a,string"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextZeroNotRoot", + data: struct { + A struct { + A coverPtrMarshalText `json:"a"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextZeroNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextZeroNotRootString", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,string"` + } + }{}, + }, + + // HeadMarshalTextNotRoot + { + name: "HeadMarshalTextNotRoot", + data: struct { + A struct { + A coverMarshalText `json:"a"` + } + }{A: struct { + A coverMarshalText `json:"a"` + }{A: coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalText `json:"a,omitempty"` + } + }{A: struct { + A coverMarshalText `json:"a,omitempty"` + }{A: coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextNotRootString", + data: struct { + A struct { + A coverMarshalText `json:"a,string"` + } + }{A: struct { + A coverMarshalText `json:"a,string"` + }{A: coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextNotRoot", + data: struct { + A struct { + A coverPtrMarshalText `json:"a"` + } + }{A: struct { + A coverPtrMarshalText `json:"a"` + }{A: coverPtrMarshalText{}}}, + }, + { + name: "HeadMarshalTextNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + }{A: struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{A: coverPtrMarshalText{}}}, + }, + { + name: "HeadMarshalTextNotRootString", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,string"` + } + }{A: struct { + A coverPtrMarshalText `json:"a,string"` + }{A: coverPtrMarshalText{}}}, + }, + + // HeadMarshalTextPtrNotRoot + { + name: "HeadMarshalTextPtrNotRoot", + data: struct { + A struct { + A *coverMarshalText `json:"a"` + } + }{A: struct { + A *coverMarshalText `json:"a"` + }{&coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextPtrNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalText `json:"a,omitempty"` + } + }{A: struct { + A *coverMarshalText `json:"a,omitempty"` + }{&coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextPtrNotRootString", + data: struct { + A struct { + A *coverMarshalText `json:"a,string"` + } + }{A: struct { + A *coverMarshalText `json:"a,string"` + }{&coverMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextPtrNotRoot", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a"` + }{&coverPtrMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextPtrNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{&coverPtrMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextPtrNotRootString", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,string"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a,string"` + }{&coverPtrMarshalText{}}}, + }, + + // HeadMarshalTextPtrNilNotRoot + { + name: "HeadMarshalTextPtrNilNotRoot", + data: struct { + A struct { + A *coverMarshalText `json:"a"` + } + }{}, + }, + { + name: "HeadMarshalTextPtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalText `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadMarshalTextPtrNilNotRootString", + data: struct { + A struct { + A *coverMarshalText `json:"a,string"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextPtrNilNotRoot", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextPtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextPtrNilNotRootString", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,string"` + } + }{}, + }, + + // PtrHeadMarshalTextZeroNotRoot + { + name: "PtrHeadMarshalTextZeroNotRoot", + data: struct { + A *struct { + A coverMarshalText `json:"a"` + } + }{A: new(struct { + A coverMarshalText `json:"a"` + })}, + }, + { + name: "PtrHeadMarshalTextZeroNotRootOmitEmpty", + data: struct { + A *struct { + A coverMarshalText `json:"a,omitempty"` + } + }{A: new(struct { + A coverMarshalText `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadMarshalTextZeroNotRootString", + data: struct { + A *struct { + A coverMarshalText `json:"a,string"` + } + }{A: new(struct { + A coverMarshalText `json:"a,string"` + })}, + }, + { + name: "PtrHeadPtrMarshalTextZeroNotRoot", + data: struct { + A *struct { + A coverPtrMarshalText `json:"a"` + } + }{A: new(struct { + A coverPtrMarshalText `json:"a"` + })}, + }, + { + name: "PtrHeadPtrMarshalTextZeroNotRootOmitEmpty", + data: struct { + A *struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + }{A: new(struct { + A coverPtrMarshalText `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadPtrMarshalTextZeroNotRootString", + data: struct { + A *struct { + A coverPtrMarshalText `json:"a,string"` + } + }{A: new(struct { + A coverPtrMarshalText `json:"a,string"` + })}, + }, + + // PtrHeadMarshalTextNotRoot + { + name: "PtrHeadMarshalTextNotRoot", + data: struct { + A *struct { + A coverMarshalText `json:"a"` + } + }{A: &(struct { + A coverMarshalText `json:"a"` + }{A: coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextNotRootOmitEmpty", + data: struct { + A *struct { + A coverMarshalText `json:"a,omitempty"` + } + }{A: &(struct { + A coverMarshalText `json:"a,omitempty"` + }{A: coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextNotRootString", + data: struct { + A *struct { + A coverMarshalText `json:"a,string"` + } + }{A: &(struct { + A coverMarshalText `json:"a,string"` + }{A: coverMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextNotRoot", + data: struct { + A *struct { + A coverPtrMarshalText `json:"a"` + } + }{A: &(struct { + A coverPtrMarshalText `json:"a"` + }{A: coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextNotRootOmitEmpty", + data: struct { + A *struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + }{A: &(struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{A: coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextNotRootString", + data: struct { + A *struct { + A coverPtrMarshalText `json:"a,string"` + } + }{A: &(struct { + A coverPtrMarshalText `json:"a,string"` + }{A: coverPtrMarshalText{}})}, + }, + + // PtrHeadMarshalTextPtrNotRoot + { + name: "PtrHeadMarshalTextPtrNotRoot", + data: struct { + A *struct { + A *coverMarshalText `json:"a"` + } + }{A: &(struct { + A *coverMarshalText `json:"a"` + }{A: &coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextPtrNotRootOmitEmpty", + data: struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: &coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextPtrNotRootString", + data: struct { + A *struct { + A *coverMarshalText `json:"a,string"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,string"` + }{A: &coverMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNotRoot", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a"` + }{A: &coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNotRootOmitEmpty", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: &coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNotRootString", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: &coverPtrMarshalText{}})}, + }, + + // PtrHeadMarshalTextPtrNilNotRoot + { + name: "PtrHeadMarshalTextPtrNilNotRoot", + data: struct { + A *struct { + A *coverMarshalText `json:"a"` + } + }{A: &(struct { + A *coverMarshalText `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadMarshalTextPtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadMarshalTextPtrNilNotRootString", + data: struct { + A *struct { + A *coverMarshalText `json:"a,string"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,string"` + }{A: nil})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilNotRoot", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilNotRootString", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: nil})}, + }, + + // PtrHeadMarshalTextNilNotRoot + { + name: "PtrHeadMarshalTextNilNotRoot", + data: struct { + A *struct { + A *coverMarshalText `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadMarshalTextNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadMarshalTextNilNotRootString", + data: struct { + A *struct { + A *coverMarshalText `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalTextNilNotRoot", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalTextNilNotRootOmitEmpty", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadPtrMarshalTextNilNotRootString", + data: struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + + // HeadMarshalTextZeroMultiFieldsNotRoot + { + name: "HeadMarshalTextZeroMultiFieldsNotRoot", + data: struct { + A struct { + A coverMarshalText `json:"a"` + } + B struct { + B coverMarshalText `json:"b"` + } + }{}, + }, + { + name: "HeadMarshalTextZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalText `json:"a,omitempty"` + } + B struct { + B coverMarshalText `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadMarshalTextZeroMultiFieldsNotRootString", + data: struct { + A struct { + A coverMarshalText `json:"a,string"` + } + B struct { + B coverMarshalText `json:"b,string"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextZeroMultiFieldsNotRoot", + data: struct { + A struct { + A coverPtrMarshalText `json:"a"` + } + B struct { + B coverPtrMarshalText `json:"b"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalText `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadPtrMarshalTextZeroMultiFieldsNotRootString", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,string"` + } + B struct { + B coverPtrMarshalText `json:"b,string"` + } + }{}, + }, + + // HeadMarshalTextMultiFieldsNotRoot + { + name: "HeadMarshalTextMultiFieldsNotRoot", + data: struct { + A struct { + A coverMarshalText `json:"a"` + } + B struct { + B coverMarshalText `json:"b"` + } + }{A: struct { + A coverMarshalText `json:"a"` + }{A: coverMarshalText{}}, B: struct { + B coverMarshalText `json:"b"` + }{B: coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverMarshalText `json:"a,omitempty"` + } + B struct { + B coverMarshalText `json:"b,omitempty"` + } + }{A: struct { + A coverMarshalText `json:"a,omitempty"` + }{A: coverMarshalText{}}, B: struct { + B coverMarshalText `json:"b,omitempty"` + }{B: coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextMultiFieldsNotRootString", + data: struct { + A struct { + A coverMarshalText `json:"a,string"` + } + B struct { + B coverMarshalText `json:"b,string"` + } + }{A: struct { + A coverMarshalText `json:"a,string"` + }{A: coverMarshalText{}}, B: struct { + B coverMarshalText `json:"b,string"` + }{B: coverMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextMultiFieldsNotRoot", + data: struct { + A struct { + A coverPtrMarshalText `json:"a"` + } + B struct { + B coverPtrMarshalText `json:"b"` + } + }{A: struct { + A coverPtrMarshalText `json:"a"` + }{A: coverPtrMarshalText{}}, B: struct { + B coverPtrMarshalText `json:"b"` + }{B: coverPtrMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalText `json:"b,omitempty"` + } + }{A: struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{A: coverPtrMarshalText{}}, B: struct { + B coverPtrMarshalText `json:"b,omitempty"` + }{B: coverPtrMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextMultiFieldsNotRootString", + data: struct { + A struct { + A coverPtrMarshalText `json:"a,string"` + } + B struct { + B coverPtrMarshalText `json:"b,string"` + } + }{A: struct { + A coverPtrMarshalText `json:"a,string"` + }{A: coverPtrMarshalText{}}, B: struct { + B coverPtrMarshalText `json:"b,string"` + }{B: coverPtrMarshalText{}}}, + }, + + // HeadMarshalTextPtrMultiFieldsNotRoot + { + name: "HeadMarshalTextPtrMultiFieldsNotRoot", + data: struct { + A struct { + A *coverMarshalText `json:"a"` + } + B struct { + B *coverMarshalText `json:"b"` + } + }{A: struct { + A *coverMarshalText `json:"a"` + }{A: &coverMarshalText{}}, B: struct { + B *coverMarshalText `json:"b"` + }{B: &coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextPtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalText `json:"a,omitempty"` + } + B struct { + B *coverMarshalText `json:"b,omitempty"` + } + }{A: struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: &coverMarshalText{}}, B: struct { + B *coverMarshalText `json:"b,omitempty"` + }{B: &coverMarshalText{}}}, + }, + { + name: "HeadMarshalTextPtrMultiFieldsNotRootString", + data: struct { + A struct { + A *coverMarshalText `json:"a,string"` + } + B struct { + B *coverMarshalText `json:"b,string"` + } + }{A: struct { + A *coverMarshalText `json:"a,string"` + }{A: &coverMarshalText{}}, B: struct { + B *coverMarshalText `json:"b,string"` + }{B: &coverMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextPtrMultiFieldsNotRoot", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a"` + } + B struct { + B *coverPtrMarshalText `json:"b"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a"` + }{A: &coverPtrMarshalText{}}, B: struct { + B *coverPtrMarshalText `json:"b"` + }{B: &coverPtrMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextPtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + B struct { + B *coverPtrMarshalText `json:"b,omitempty"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: &coverPtrMarshalText{}}, B: struct { + B *coverPtrMarshalText `json:"b,omitempty"` + }{B: &coverPtrMarshalText{}}}, + }, + { + name: "HeadPtrMarshalTextPtrMultiFieldsNotRootString", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,string"` + } + B struct { + B *coverPtrMarshalText `json:"b,string"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: &coverPtrMarshalText{}}, B: struct { + B *coverPtrMarshalText `json:"b,string"` + }{B: &coverPtrMarshalText{}}}, + }, + + // HeadMarshalTextPtrNilMultiFieldsNotRoot + { + name: "HeadMarshalTextPtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *coverMarshalText `json:"a"` + } + B struct { + B *coverMarshalText `json:"b"` + } + }{A: struct { + A *coverMarshalText `json:"a"` + }{A: nil}, B: struct { + B *coverMarshalText `json:"b"` + }{B: nil}}, + }, + { + name: "HeadMarshalTextPtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverMarshalText `json:"a,omitempty"` + } + B struct { + B *coverMarshalText `json:"b,omitempty"` + } + }{A: struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: nil}, B: struct { + B *coverMarshalText `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadMarshalTextPtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *coverMarshalText `json:"a,string"` + } + B struct { + B *coverMarshalText `json:"b,string"` + } + }{A: struct { + A *coverMarshalText `json:"a,string"` + }{A: nil}, B: struct { + B *coverMarshalText `json:"b,string"` + }{B: nil}}, + }, + { + name: "HeadPtrMarshalTextPtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a"` + } + B struct { + B *coverPtrMarshalText `json:"b"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a"` + }{A: nil}, B: struct { + B *coverPtrMarshalText `json:"b"` + }{B: nil}}, + }, + { + name: "HeadPtrMarshalTextPtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + B struct { + B *coverPtrMarshalText `json:"b,omitempty"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: nil}, B: struct { + B *coverPtrMarshalText `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadPtrMarshalTextPtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *coverPtrMarshalText `json:"a,string"` + } + B struct { + B *coverPtrMarshalText `json:"b,string"` + } + }{A: struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: nil}, B: struct { + B *coverPtrMarshalText `json:"b,string"` + }{B: nil}}, + }, + + // PtrHeadMarshalTextZeroMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A coverMarshalText `json:"a"` + } + B struct { + B coverMarshalText `json:"b"` + } + }{}, + }, + { + name: "PtrHeadMarshalTextZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverMarshalText `json:"a,omitempty"` + } + B struct { + B coverMarshalText `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadMarshalTextZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A coverMarshalText `json:"a,string"` + } + B struct { + B coverMarshalText `json:"b,string"` + } + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A coverPtrMarshalText `json:"a"` + } + B struct { + B coverPtrMarshalText `json:"b"` + } + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalText `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadPtrMarshalTextZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A coverPtrMarshalText `json:"a,string"` + } + B struct { + B coverPtrMarshalText `json:"b,string"` + } + }{}, + }, + + // PtrHeadMarshalTextMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextMultiFieldsNotRoot", + data: &struct { + A struct { + A coverMarshalText `json:"a"` + } + B struct { + B coverMarshalText `json:"b"` + } + }{A: struct { + A coverMarshalText `json:"a"` + }{A: coverMarshalText{}}, B: struct { + B coverMarshalText `json:"b"` + }{B: coverMarshalText{}}}, + }, + { + name: "PtrHeadMarshalTextMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverMarshalText `json:"a,omitempty"` + } + B struct { + B coverMarshalText `json:"b,omitempty"` + } + }{A: struct { + A coverMarshalText `json:"a,omitempty"` + }{A: coverMarshalText{}}, B: struct { + B coverMarshalText `json:"b,omitempty"` + }{B: coverMarshalText{}}}, + }, + { + name: "PtrHeadMarshalTextMultiFieldsNotRootString", + data: &struct { + A struct { + A coverMarshalText `json:"a,string"` + } + B struct { + B coverMarshalText `json:"b,string"` + } + }{A: struct { + A coverMarshalText `json:"a,string"` + }{A: coverMarshalText{}}, B: struct { + B coverMarshalText `json:"b,string"` + }{B: coverMarshalText{}}}, + }, + { + name: "PtrHeadPtrMarshalTextMultiFieldsNotRoot", + data: &struct { + A struct { + A coverPtrMarshalText `json:"a"` + } + B struct { + B coverPtrMarshalText `json:"b"` + } + }{A: struct { + A coverPtrMarshalText `json:"a"` + }{A: coverPtrMarshalText{}}, B: struct { + B coverPtrMarshalText `json:"b"` + }{B: coverPtrMarshalText{}}}, + }, + { + name: "PtrHeadPtrMarshalTextMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A coverPtrMarshalText `json:"a,omitempty"` + } + B struct { + B coverPtrMarshalText `json:"b,omitempty"` + } + }{A: struct { + A coverPtrMarshalText `json:"a,omitempty"` + }{A: coverPtrMarshalText{}}, B: struct { + B coverPtrMarshalText `json:"b,omitempty"` + }{B: coverPtrMarshalText{}}}, + }, + { + name: "PtrHeadPtrMarshalTextMultiFieldsNotRootString", + data: &struct { + A struct { + A coverPtrMarshalText `json:"a,string"` + } + B struct { + B coverPtrMarshalText `json:"b,string"` + } + }{A: struct { + A coverPtrMarshalText `json:"a,string"` + }{A: coverPtrMarshalText{}}, B: struct { + B coverPtrMarshalText `json:"b,string"` + }{B: coverPtrMarshalText{}}}, + }, + + // PtrHeadMarshalTextPtrMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextPtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalText `json:"a"` + } + B *struct { + B *coverMarshalText `json:"b"` + } + }{A: &(struct { + A *coverMarshalText `json:"a"` + }{A: &coverMarshalText{}}), B: &(struct { + B *coverMarshalText `json:"b"` + }{B: &coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextPtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + } + B *struct { + B *coverMarshalText `json:"b,omitempty"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,omitempty"` + }{A: &coverMarshalText{}}), B: &(struct { + B *coverMarshalText `json:"b,omitempty"` + }{B: &coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextPtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,string"` + } + B *struct { + B *coverMarshalText `json:"b,string"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,string"` + }{A: &coverMarshalText{}}), B: &(struct { + B *coverMarshalText `json:"b,string"` + }{B: &coverMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + } + B *struct { + B *coverPtrMarshalText `json:"b"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a"` + }{A: &coverPtrMarshalText{}}), B: &(struct { + B *coverPtrMarshalText `json:"b"` + }{B: &coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + B *struct { + B *coverPtrMarshalText `json:"b,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,omitempty"` + }{A: &coverPtrMarshalText{}}), B: &(struct { + B *coverPtrMarshalText `json:"b,omitempty"` + }{B: &coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + } + B *struct { + B *coverPtrMarshalText `json:"b,string"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,string"` + }{A: &coverPtrMarshalText{}}), B: &(struct { + B *coverPtrMarshalText `json:"b,string"` + }{B: &coverPtrMarshalText{}})}, + }, + + // PtrHeadMarshalTextPtrNilMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextPtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalText `json:"a"` + } + B *struct { + B *coverMarshalText `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *coverMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,string"` + } `json:",string"` + B *struct { + B *coverMarshalText `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + } + B *struct { + B *coverPtrMarshalText `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *coverPtrMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + } `json:",string"` + B *struct { + B *coverPtrMarshalText `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalTextNilMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverMarshalText `json:"a"` + } + B *struct { + B *coverMarshalText `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMarshalTextNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + } + B *struct { + B *coverMarshalText `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMarshalTextNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverMarshalText `json:"a,string"` + } + B *struct { + B *coverMarshalText `json:"b,string"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + } + B *struct { + B *coverPtrMarshalText `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + } + B *struct { + B *coverPtrMarshalText `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + } + B *struct { + B *coverPtrMarshalText `json:"b,string"` + } + })(nil), + }, + + // PtrHeadMarshalTextDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + } + B *struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + } + }{A: &(struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + }{A: coverMarshalText{}, B: coverMarshalText{}}), B: &(struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + }{A: coverMarshalText{}, B: coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + } + B *struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + } + }{A: &(struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + }{A: coverMarshalText{}, B: coverMarshalText{}}), B: &(struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + }{A: coverMarshalText{}, B: coverMarshalText{}})}, + }, + { + name: "PtrHeadMarshalTextDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + } + B *struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + } + }{A: &(struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + }{A: coverMarshalText{}, B: coverMarshalText{}}), B: &(struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + }{A: coverMarshalText{}, B: coverMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + } + B *struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + } + }{A: &(struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}}), B: &(struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + } + B *struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + } + }{A: &(struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}}), B: &(struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}})}, + }, + { + name: "PtrHeadPtrMarshalTextDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + } + B *struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + } + }{A: &(struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}}), B: &(struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + }{A: coverPtrMarshalText{}, B: coverPtrMarshalText{}})}, + }, + + // PtrHeadMarshalTextNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + } + B *struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + } + B *struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + } + B *struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + } + B *struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalTextNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + } + B *struct { + A coverMarshalText `json:"a"` + B coverMarshalText `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMarshalTextNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + } + B *struct { + A coverMarshalText `json:"a,omitempty"` + B coverMarshalText `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMarshalTextNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + } + B *struct { + A coverMarshalText `json:"a,string"` + B coverMarshalText `json:"b,string"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + } + B *struct { + A coverPtrMarshalText `json:"a"` + B coverPtrMarshalText `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + } + B *struct { + A coverPtrMarshalText `json:"a,omitempty"` + B coverPtrMarshalText `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + } + B *struct { + A coverPtrMarshalText `json:"a,string"` + B coverPtrMarshalText `json:"b,string"` + } + })(nil), + }, + + // PtrHeadMarshalTextPtrDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextPtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + } + B *struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + } + }{A: &(struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}}), B: &(struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadMarshalTextPtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + } + B *struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}}), B: &(struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadMarshalTextPtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + } + B *struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + } + }{A: &(struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + }{A: &coverMarshalText{}, B: &coverMarshalText{}}), B: &(struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + } + B *struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}}), B: &(struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + } + B *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}}), B: &(struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadPtrMarshalTextPtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + } + B *struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + } + }{A: &(struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + }{A: &coverPtrMarshalText{}, B: &coverPtrMarshalText{}}), B: &(struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + }{A: nil, B: nil})}, + }, + + // PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + } + B *struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + } + B *struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + } + B *struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadPtrMarshalTextPtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + } + B *struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + } + B *struct { + A *coverMarshalText `json:"a"` + B *coverMarshalText `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + } + B *struct { + A *coverMarshalText `json:"a,omitempty"` + B *coverMarshalText `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadMarshalTextPtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + } + B *struct { + A *coverMarshalText `json:"a,string"` + B *coverMarshalText `json:"b,string"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextPtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + } + B *struct { + A *coverPtrMarshalText `json:"a"` + B *coverPtrMarshalText `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + } + B *struct { + A *coverPtrMarshalText `json:"a,omitempty"` + B *coverPtrMarshalText `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadPtrMarshalTextPtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + } + B *struct { + A *coverPtrMarshalText `json:"a,string"` + B *coverPtrMarshalText `json:"b,string"` + } + })(nil), + }, + + // AnonymousHeadMarshalText + { + name: "AnonymousHeadMarshalText", + data: struct { + structMarshalText + B coverMarshalText `json:"b"` + }{ + structMarshalText: structMarshalText{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "AnonymousHeadMarshalTextOmitEmpty", + data: struct { + structMarshalTextOmitEmpty + B coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextOmitEmpty: structMarshalTextOmitEmpty{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "AnonymousHeadMarshalTextString", + data: struct { + structMarshalTextString + B coverMarshalText `json:"b,string"` + }{ + structMarshalTextString: structMarshalTextString{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalText", + data: struct { + structPtrMarshalText + B coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalText: structPtrMarshalText{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextOmitEmpty", + data: struct { + structPtrMarshalTextOmitEmpty + B coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextOmitEmpty: structPtrMarshalTextOmitEmpty{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextString", + data: struct { + structPtrMarshalTextString + B coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextString: structPtrMarshalTextString{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + + // PtrAnonymousHeadMarshalText + { + name: "PtrAnonymousHeadMarshalText", + data: struct { + *structMarshalText + B coverMarshalText `json:"b"` + }{ + structMarshalText: &structMarshalText{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextOmitEmpty", + data: struct { + *structMarshalTextOmitEmpty + B coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextOmitEmpty: &structMarshalTextOmitEmpty{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextString", + data: struct { + *structMarshalTextString + B coverMarshalText `json:"b,string"` + }{ + structMarshalTextString: &structMarshalTextString{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalText", + data: struct { + *structPtrMarshalText + B coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalText: &structPtrMarshalText{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextOmitEmpty", + data: struct { + *structPtrMarshalTextOmitEmpty + B coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextOmitEmpty: &structPtrMarshalTextOmitEmpty{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextString", + data: struct { + *structPtrMarshalTextString + B coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextString: &structPtrMarshalTextString{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + + // PtrAnonymousHeadMarshalTextNil + { + name: "PtrAnonymousHeadMarshalTextNil", + data: struct { + *structMarshalText + B coverMarshalText `json:"b"` + }{ + structMarshalText: &structMarshalText{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextNilOmitEmpty", + data: struct { + *structMarshalTextOmitEmpty + B coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextOmitEmpty: &structMarshalTextOmitEmpty{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextNilString", + data: struct { + *structMarshalTextString + B coverMarshalText `json:"b,string"` + }{ + structMarshalTextString: &structMarshalTextString{A: coverMarshalText{}}, + B: coverMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextNil", + data: struct { + *structPtrMarshalText + B coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalText: &structPtrMarshalText{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextNilOmitEmpty", + data: struct { + *structPtrMarshalTextOmitEmpty + B coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextOmitEmpty: &structPtrMarshalTextOmitEmpty{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextNilString", + data: struct { + *structPtrMarshalTextString + B coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextString: &structPtrMarshalTextString{A: coverPtrMarshalText{}}, + B: coverPtrMarshalText{}, + }, + }, + + // NilPtrAnonymousHeadMarshalText + { + name: "NilPtrAnonymousHeadMarshalText", + data: struct { + *structMarshalText + B coverMarshalText `json:"b"` + }{ + structMarshalText: nil, + B: coverMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextOmitEmpty", + data: struct { + *structMarshalTextOmitEmpty + B coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextOmitEmpty: nil, + B: coverMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextString", + data: struct { + *structMarshalTextString + B coverMarshalText `json:"b,string"` + }{ + structMarshalTextString: nil, + B: coverMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalText", + data: struct { + *structPtrMarshalText + B coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalText: nil, + B: coverPtrMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextOmitEmpty", + data: struct { + *structPtrMarshalTextOmitEmpty + B coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextOmitEmpty: nil, + B: coverPtrMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextString", + data: struct { + *structPtrMarshalTextString + B coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextString: nil, + B: coverPtrMarshalText{}, + }, + }, + + // AnonymousHeadMarshalTextPtr + { + name: "AnonymousHeadMarshalTextPtr", + data: struct { + structMarshalTextPtr + B *coverMarshalText `json:"b"` + }{ + structMarshalTextPtr: structMarshalTextPtr{A: &coverMarshalText{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrOmitEmpty", + data: struct { + structMarshalTextPtrOmitEmpty + B *coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextPtrOmitEmpty: structMarshalTextPtrOmitEmpty{A: &coverMarshalText{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrString", + data: struct { + structMarshalTextPtrString + B *coverMarshalText `json:"b,string"` + }{ + structMarshalTextPtrString: structMarshalTextPtrString{A: &coverMarshalText{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtr", + data: struct { + structPtrMarshalTextPtr + B *coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalTextPtr: structPtrMarshalTextPtr{A: &coverPtrMarshalText{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrOmitEmpty", + data: struct { + structPtrMarshalTextPtrOmitEmpty + B *coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextPtrOmitEmpty: structPtrMarshalTextPtrOmitEmpty{A: &coverPtrMarshalText{}}, + B: nil, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrString", + data: struct { + structPtrMarshalTextPtrString + B *coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextPtrString: structPtrMarshalTextPtrString{A: &coverPtrMarshalText{}}, + B: nil, + }, + }, + + // AnonymousHeadMarshalTextPtrNil + { + name: "AnonymousHeadMarshalTextPtrNil", + data: struct { + structMarshalTextPtr + B *coverMarshalText `json:"b"` + }{ + structMarshalTextPtr: structMarshalTextPtr{A: nil}, + B: &coverMarshalText{}, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrNilOmitEmpty", + data: struct { + structMarshalTextPtrOmitEmpty + B *coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextPtrOmitEmpty: structMarshalTextPtrOmitEmpty{A: nil}, + B: &coverMarshalText{}, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrNilString", + data: struct { + structMarshalTextPtrString + B *coverMarshalText `json:"b,string"` + }{ + structMarshalTextPtrString: structMarshalTextPtrString{A: nil}, + B: &coverMarshalText{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrNil", + data: struct { + structPtrMarshalTextPtr + B *coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalTextPtr: structPtrMarshalTextPtr{A: nil}, + B: &coverPtrMarshalText{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrNilOmitEmpty", + data: struct { + structPtrMarshalTextPtrOmitEmpty + B *coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextPtrOmitEmpty: structPtrMarshalTextPtrOmitEmpty{A: nil}, + B: &coverPtrMarshalText{}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrNilString", + data: struct { + structPtrMarshalTextPtrString + B *coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextPtrString: structPtrMarshalTextPtrString{A: nil}, + B: &coverPtrMarshalText{}, + }, + }, + + // PtrAnonymousHeadMarshalTextPtr + { + name: "PtrAnonymousHeadMarshalTextPtr", + data: struct { + *structMarshalTextPtr + B *coverMarshalText `json:"b"` + }{ + structMarshalTextPtr: &structMarshalTextPtr{A: &coverMarshalText{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextPtrOmitEmpty", + data: struct { + *structMarshalTextPtrOmitEmpty + B *coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextPtrOmitEmpty: &structMarshalTextPtrOmitEmpty{A: &coverMarshalText{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextPtrString", + data: struct { + *structMarshalTextPtrString + B *coverMarshalText `json:"b,string"` + }{ + structMarshalTextPtrString: &structMarshalTextPtrString{A: &coverMarshalText{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextPtr", + data: struct { + *structPtrMarshalTextPtr + B *coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalTextPtr: &structPtrMarshalTextPtr{A: &coverPtrMarshalText{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextPtrOmitEmpty", + data: struct { + *structPtrMarshalTextPtrOmitEmpty + B *coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextPtrOmitEmpty: &structPtrMarshalTextPtrOmitEmpty{A: &coverPtrMarshalText{}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextPtrString", + data: struct { + *structPtrMarshalTextPtrString + B *coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextPtrString: &structPtrMarshalTextPtrString{A: &coverPtrMarshalText{}}, + B: nil, + }, + }, + + // NilPtrAnonymousHeadMarshalTextPtr + { + name: "NilPtrAnonymousHeadMarshalTextPtr", + data: struct { + *structMarshalTextPtr + B *coverMarshalText `json:"b"` + }{ + structMarshalTextPtr: nil, + B: &coverMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextPtrOmitEmpty", + data: struct { + *structMarshalTextPtrOmitEmpty + B *coverMarshalText `json:"b,omitempty"` + }{ + structMarshalTextPtrOmitEmpty: nil, + B: &coverMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextPtrString", + data: struct { + *structMarshalTextPtrString + B *coverMarshalText `json:"b,string"` + }{ + structMarshalTextPtrString: nil, + B: &coverMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextPtr", + data: struct { + *structPtrMarshalTextPtr + B *coverPtrMarshalText `json:"b"` + }{ + structPtrMarshalTextPtr: nil, + B: &coverPtrMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextPtrOmitEmpty", + data: struct { + *structPtrMarshalTextPtrOmitEmpty + B *coverPtrMarshalText `json:"b,omitempty"` + }{ + structPtrMarshalTextPtrOmitEmpty: nil, + B: &coverPtrMarshalText{}, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextPtrString", + data: struct { + *structPtrMarshalTextPtrString + B *coverPtrMarshalText `json:"b,string"` + }{ + structPtrMarshalTextPtrString: nil, + B: &coverPtrMarshalText{}, + }, + }, + + // AnonymousHeadMarshalTextOnly + { + name: "AnonymousHeadMarshalTextOnly", + data: struct { + structMarshalText + }{ + structMarshalText: structMarshalText{A: coverMarshalText{}}, + }, + }, + { + name: "AnonymousHeadMarshalTextOnlyOmitEmpty", + data: struct { + structMarshalTextOmitEmpty + }{ + structMarshalTextOmitEmpty: structMarshalTextOmitEmpty{A: coverMarshalText{}}, + }, + }, + { + name: "AnonymousHeadMarshalTextOnlyString", + data: struct { + structMarshalTextString + }{ + structMarshalTextString: structMarshalTextString{A: coverMarshalText{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextOnly", + data: struct { + structPtrMarshalText + }{ + structPtrMarshalText: structPtrMarshalText{A: coverPtrMarshalText{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextOnlyOmitEmpty", + data: struct { + structPtrMarshalTextOmitEmpty + }{ + structPtrMarshalTextOmitEmpty: structPtrMarshalTextOmitEmpty{A: coverPtrMarshalText{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextOnlyString", + data: struct { + structPtrMarshalTextString + }{ + structPtrMarshalTextString: structPtrMarshalTextString{A: coverPtrMarshalText{}}, + }, + }, + + // PtrAnonymousHeadMarshalTextOnly + { + name: "PtrAnonymousHeadMarshalTextOnly", + data: struct { + *structMarshalText + }{ + structMarshalText: &structMarshalText{A: coverMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextOnlyOmitEmpty", + data: struct { + *structMarshalTextOmitEmpty + }{ + structMarshalTextOmitEmpty: &structMarshalTextOmitEmpty{A: coverMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextOnlyString", + data: struct { + *structMarshalTextString + }{ + structMarshalTextString: &structMarshalTextString{A: coverMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextOnly", + data: struct { + *structPtrMarshalText + }{ + structPtrMarshalText: &structPtrMarshalText{A: coverPtrMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextOnlyOmitEmpty", + data: struct { + *structPtrMarshalTextOmitEmpty + }{ + structPtrMarshalTextOmitEmpty: &structPtrMarshalTextOmitEmpty{A: coverPtrMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextOnlyString", + data: struct { + *structPtrMarshalTextString + }{ + structPtrMarshalTextString: &structPtrMarshalTextString{A: coverPtrMarshalText{}}, + }, + }, + + // NilPtrAnonymousHeadMarshalTextOnly + { + name: "NilPtrAnonymousHeadMarshalTextOnly", + data: struct { + *structMarshalText + }{ + structMarshalText: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextOnlyOmitEmpty", + data: struct { + *structMarshalTextOmitEmpty + }{ + structMarshalTextOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextOnlyString", + data: struct { + *structMarshalTextString + }{ + structMarshalTextString: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextOnly", + data: struct { + *structPtrMarshalText + }{ + structPtrMarshalText: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextOnlyOmitEmpty", + data: struct { + *structPtrMarshalTextOmitEmpty + }{ + structPtrMarshalTextOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextOnlyString", + data: struct { + *structPtrMarshalTextString + }{ + structPtrMarshalTextString: nil, + }, + }, + + // AnonymousHeadMarshalTextPtrOnly + { + name: "AnonymousHeadMarshalTextPtrOnly", + data: struct { + structMarshalTextPtr + }{ + structMarshalTextPtr: structMarshalTextPtr{A: &coverMarshalText{}}, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrOnlyOmitEmpty", + data: struct { + structMarshalTextPtrOmitEmpty + }{ + structMarshalTextPtrOmitEmpty: structMarshalTextPtrOmitEmpty{A: &coverMarshalText{}}, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrOnlyString", + data: struct { + structMarshalTextPtrString + }{ + structMarshalTextPtrString: structMarshalTextPtrString{A: &coverMarshalText{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrOnly", + data: struct { + structPtrMarshalTextPtr + }{ + structPtrMarshalTextPtr: structPtrMarshalTextPtr{A: &coverPtrMarshalText{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrOnlyOmitEmpty", + data: struct { + structPtrMarshalTextPtrOmitEmpty + }{ + structPtrMarshalTextPtrOmitEmpty: structPtrMarshalTextPtrOmitEmpty{A: &coverPtrMarshalText{}}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrOnlyString", + data: struct { + structPtrMarshalTextPtrString + }{ + structPtrMarshalTextPtrString: structPtrMarshalTextPtrString{A: &coverPtrMarshalText{}}, + }, + }, + + // AnonymousHeadMarshalTextPtrNilOnly + { + name: "AnonymousHeadMarshalTextPtrNilOnly", + data: struct { + structMarshalTextPtr + }{ + structMarshalTextPtr: structMarshalTextPtr{A: nil}, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrNilOnlyOmitEmpty", + data: struct { + structMarshalTextPtrOmitEmpty + }{ + structMarshalTextPtrOmitEmpty: structMarshalTextPtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadMarshalTextPtrNilOnlyString", + data: struct { + structMarshalTextPtrString + }{ + structMarshalTextPtrString: structMarshalTextPtrString{A: nil}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrNilOnly", + data: struct { + structPtrMarshalTextPtr + }{ + structPtrMarshalTextPtr: structPtrMarshalTextPtr{A: nil}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrNilOnlyOmitEmpty", + data: struct { + structPtrMarshalTextPtrOmitEmpty + }{ + structPtrMarshalTextPtrOmitEmpty: structPtrMarshalTextPtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadPtrMarshalTextPtrNilOnlyString", + data: struct { + structPtrMarshalTextPtrString + }{ + structPtrMarshalTextPtrString: structPtrMarshalTextPtrString{A: nil}, + }, + }, + + // PtrAnonymousHeadMarshalTextPtrOnly + { + name: "PtrAnonymousHeadMarshalTextPtrOnly", + data: struct { + *structMarshalTextPtr + }{ + structMarshalTextPtr: &structMarshalTextPtr{A: &coverMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextPtrOnlyOmitEmpty", + data: struct { + *structMarshalTextPtrOmitEmpty + }{ + structMarshalTextPtrOmitEmpty: &structMarshalTextPtrOmitEmpty{A: &coverMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadMarshalTextPtrOnlyString", + data: struct { + *structMarshalTextPtrString + }{ + structMarshalTextPtrString: &structMarshalTextPtrString{A: &coverMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextPtrOnly", + data: struct { + *structPtrMarshalTextPtr + }{ + structPtrMarshalTextPtr: &structPtrMarshalTextPtr{A: &coverPtrMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextPtrOnlyOmitEmpty", + data: struct { + *structPtrMarshalTextPtrOmitEmpty + }{ + structPtrMarshalTextPtrOmitEmpty: &structPtrMarshalTextPtrOmitEmpty{A: &coverPtrMarshalText{}}, + }, + }, + { + name: "PtrAnonymousHeadPtrMarshalTextPtrOnlyString", + data: struct { + *structPtrMarshalTextPtrString + }{ + structPtrMarshalTextPtrString: &structPtrMarshalTextPtrString{A: &coverPtrMarshalText{}}, + }, + }, + + // NilPtrAnonymousHeadMarshalTextPtrOnly + { + name: "NilPtrAnonymousHeadMarshalTextPtrOnly", + data: struct { + *structMarshalTextPtr + }{ + structMarshalTextPtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextPtrOnlyOmitEmpty", + data: struct { + *structMarshalTextPtrOmitEmpty + }{ + structMarshalTextPtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadMarshalTextPtrOnlyString", + data: struct { + *structMarshalTextPtrString + }{ + structMarshalTextPtrString: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextPtrOnly", + data: struct { + *structPtrMarshalTextPtr + }{ + structPtrMarshalTextPtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextPtrOnlyOmitEmpty", + data: struct { + *structPtrMarshalTextPtrOmitEmpty + }{ + structPtrMarshalTextPtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadPtrMarshalTextPtrOnlyString", + data: struct { + *structPtrMarshalTextPtrString + }{ + structPtrMarshalTextPtrString: nil, + }, + }, + } + for _, test := range tests { + for _, indent := range []bool{true, false} { + for _, htmlEscape := range []bool{true, false} { + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + enc.SetEscapeHTML(htmlEscape) + if indent { + enc.SetIndent("", " ") + } + if err := enc.Encode(test.data); err != nil { + 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:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String()) + } + } + } + } +} diff --git a/cover_slice_test.go b/cover_slice_test.go new file mode 100644 index 0000000..2728da5 --- /dev/null +++ b/cover_slice_test.go @@ -0,0 +1,1859 @@ +package json_test + +import ( + "bytes" + "testing" + + "github.com/goccy/go-json" +) + +func TestCoverSlice(t *testing.T) { + type structSlice struct { + A []int `json:"a"` + } + type structSliceOmitEmpty struct { + A []int `json:"a,omitempty"` + } + type structSliceString struct { + A []int `json:"a,string"` + } + type structSlicePtr struct { + A *[]int `json:"a"` + } + type structSlicePtrOmitEmpty struct { + A *[]int `json:"a,omitempty"` + } + type structSlicePtrString struct { + A *[]int `json:"a,string"` + } + + type structSlicePtrContent struct { + A []*int `json:"a"` + } + type structSliceOmitEmptyPtrContent struct { + A []*int `json:"a,omitempty"` + } + type structSliceStringPtrContent struct { + A []*int `json:"a,string"` + } + type structSlicePtrPtrContent struct { + A *[]*int `json:"a"` + } + type structSlicePtrOmitEmptyPtrContent struct { + A *[]*int `json:"a,omitempty"` + } + type structSlicePtrStringPtrContent struct { + A *[]*int `json:"a,string"` + } + + tests := []struct { + name string + data interface{} + }{ + // HeadSliceZero + { + name: "HeadSliceZero", + data: struct { + A []int `json:"a"` + }{}, + }, + { + name: "HeadSliceZeroOmitEmpty", + data: struct { + A []int `json:"a,omitempty"` + }{}, + }, + { + name: "HeadSliceZeroString", + data: struct { + A []int `json:"a,string"` + }{}, + }, + + // HeadSlice + { + name: "HeadSlice", + data: struct { + A []int `json:"a"` + }{A: []int{-1}}, + }, + { + name: "HeadSliceOmitEmpty", + data: struct { + A []int `json:"a,omitempty"` + }{A: []int{-1}}, + }, + { + name: "HeadSliceString", + data: struct { + A []int `json:"a,string"` + }{A: []int{-1}}, + }, + + // HeadSlicePtr + { + name: "HeadSlicePtr", + data: struct { + A *[]int `json:"a"` + }{A: sliceptr([]int{-1})}, + }, + { + name: "HeadSlicePtrOmitEmpty", + data: struct { + A *[]int `json:"a,omitempty"` + }{A: sliceptr([]int{-1})}, + }, + { + name: "HeadSlicePtrString", + data: struct { + A *[]int `json:"a,string"` + }{A: sliceptr([]int{-1})}, + }, + + // HeadSlicePtrNil + { + name: "HeadSlicePtrNil", + data: struct { + A *[]int `json:"a"` + }{A: nil}, + }, + { + name: "HeadSlicePtrNilOmitEmpty", + data: struct { + A *[]int `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadSlicePtrNilString", + data: struct { + A *[]int `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadSliceZero + { + name: "PtrHeadSliceZero", + data: &struct { + A []int `json:"a"` + }{}, + }, + { + name: "PtrHeadSliceZeroOmitEmpty", + data: &struct { + A []int `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadSliceZeroString", + data: &struct { + A []int `json:"a,string"` + }{}, + }, + + // PtrHeadSlice + { + name: "PtrHeadSlice", + data: &struct { + A []int `json:"a"` + }{A: []int{-1}}, + }, + { + name: "PtrHeadSliceOmitEmpty", + data: &struct { + A []int `json:"a,omitempty"` + }{A: []int{-1}}, + }, + { + name: "PtrHeadSliceString", + data: &struct { + A []int `json:"a,string"` + }{A: []int{-1}}, + }, + + // PtrHeadSlicePtr + { + name: "PtrHeadSlicePtr", + data: &struct { + A *[]int `json:"a"` + }{A: sliceptr([]int{-1})}, + }, + { + name: "PtrHeadSlicePtrOmitEmpty", + data: &struct { + A *[]int `json:"a,omitempty"` + }{A: sliceptr([]int{-1})}, + }, + { + name: "PtrHeadSlicePtrString", + data: &struct { + A *[]int `json:"a,string"` + }{A: sliceptr([]int{-1})}, + }, + + // PtrHeadSlicePtrNil + { + name: "PtrHeadSlicePtrNil", + data: &struct { + A *[]int `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadSlicePtrNilOmitEmpty", + data: &struct { + A *[]int `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadSlicePtrNilString", + data: &struct { + A *[]int `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadSliceNil + { + name: "PtrHeadSliceNil", + data: (*struct { + A *[]int `json:"a"` + })(nil), + }, + { + name: "PtrHeadSliceNilOmitEmpty", + data: (*struct { + A *[]int `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadSliceNilString", + data: (*struct { + A *[]int `json:"a,string"` + })(nil), + }, + + // HeadSliceZeroMultiFields + { + name: "HeadSliceZeroMultiFields", + data: struct { + A []int `json:"a"` + B []int `json:"b"` + C []int `json:"c"` + }{}, + }, + { + name: "HeadSliceZeroMultiFieldsOmitEmpty", + data: struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + C []int `json:"c,omitempty"` + }{}, + }, + { + name: "HeadSliceZeroMultiFields", + data: struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + C []int `json:"c,string"` + }{}, + }, + + // HeadSliceMultiFields + { + name: "HeadSliceMultiFields", + data: struct { + A []int `json:"a"` + B []int `json:"b"` + C []int `json:"c"` + }{A: []int{-1}, B: []int{-2}, C: []int{-3}}, + }, + { + name: "HeadSliceMultiFieldsOmitEmpty", + data: struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + C []int `json:"c,omitempty"` + }{A: []int{-1}, B: []int{-2}, C: []int{-3}}, + }, + { + name: "HeadSliceMultiFieldsString", + data: struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + C []int `json:"c,string"` + }{A: []int{-1}, B: []int{-2}, C: []int{-3}}, + }, + + // HeadSlicePtrMultiFields + { + name: "HeadSlicePtrMultiFields", + data: struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + C *[]int `json:"c"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})}, + }, + { + name: "HeadSlicePtrMultiFieldsOmitEmpty", + data: struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + C *[]int `json:"c,omitempty"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})}, + }, + { + name: "HeadSlicePtrMultiFieldsString", + data: struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + C *[]int `json:"c,string"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})}, + }, + + // HeadSlicePtrNilMultiFields + { + name: "HeadSlicePtrNilMultiFields", + data: struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + C *[]int `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadSlicePtrNilMultiFieldsOmitEmpty", + data: struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + C *[]int `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadSlicePtrNilMultiFieldsString", + data: struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + C *[]int `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + + // PtrHeadSliceZeroMultiFields + { + name: "PtrHeadSliceZeroMultiFields", + data: &struct { + A []int `json:"a"` + B []int `json:"b"` + }{}, + }, + { + name: "PtrHeadSliceZeroMultiFieldsOmitEmpty", + data: &struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadSliceZeroMultiFieldsString", + data: &struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + }{}, + }, + + // PtrHeadSliceMultiFields + { + name: "PtrHeadSliceMultiFields", + data: &struct { + A []int `json:"a"` + B []int `json:"b"` + }{A: []int{-1}, B: nil}, + }, + { + name: "PtrHeadSliceMultiFieldsOmitEmpty", + data: &struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + }{A: []int{-1}, B: nil}, + }, + { + name: "PtrHeadSliceMultiFieldsString", + data: &struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + }{A: []int{-1}, B: nil}, + }, + + // PtrHeadSlicePtrMultiFields + { + name: "PtrHeadSlicePtrMultiFields", + data: &struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})}, + }, + { + name: "PtrHeadSlicePtrMultiFieldsOmitEmpty", + data: &struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})}, + }, + { + name: "PtrHeadSlicePtrMultiFieldsString", + data: &struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})}, + }, + + // PtrHeadSlicePtrNilMultiFields + { + name: "PtrHeadSlicePtrNilMultiFields", + data: &struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSlicePtrNilMultiFieldsOmitEmpty", + data: &struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSlicePtrNilMultiFieldsString", + data: &struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + }{A: nil, B: nil}, + }, + + // PtrHeadSliceNilMultiFields + { + name: "PtrHeadSliceNilMultiFields", + data: (*struct { + A []int `json:"a"` + B []int `json:"b"` + })(nil), + }, + { + name: "PtrHeadSliceNilMultiFieldsOmitEmpty", + data: (*struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadSliceNilMultiFieldsString", + data: (*struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + })(nil), + }, + + // PtrHeadSliceNilMultiFields + { + name: "PtrHeadSliceNilMultiFields", + data: (*struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + })(nil), + }, + { + name: "PtrHeadSliceNilMultiFieldsOmitEmpty", + data: (*struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadSliceNilMultiFieldsString", + data: (*struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + })(nil), + }, + + // HeadSliceZeroNotRoot + { + name: "HeadSliceZeroNotRoot", + data: struct { + A struct { + A []int `json:"a"` + } + }{}, + }, + { + name: "HeadSliceZeroNotRootOmitEmpty", + data: struct { + A struct { + A []int `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadSliceZeroNotRootString", + data: struct { + A struct { + A []int `json:"a,string"` + } + }{}, + }, + + // HeadSliceNotRoot + { + name: "HeadSliceNotRoot", + data: struct { + A struct { + A []int `json:"a"` + } + }{A: struct { + A []int `json:"a"` + }{A: []int{-1}}}, + }, + { + name: "HeadSliceNotRootOmitEmpty", + data: struct { + A struct { + A []int `json:"a,omitempty"` + } + }{A: struct { + A []int `json:"a,omitempty"` + }{A: []int{-1}}}, + }, + { + name: "HeadSliceNotRootString", + data: struct { + A struct { + A []int `json:"a,string"` + } + }{A: struct { + A []int `json:"a,string"` + }{A: []int{-1}}}, + }, + + // HeadSlicePtrNotRoot + { + name: "HeadSlicePtrNotRoot", + data: struct { + A struct { + A *[]int `json:"a"` + } + }{A: struct { + A *[]int `json:"a"` + }{sliceptr([]int{-1})}}, + }, + { + name: "HeadSlicePtrNotRootOmitEmpty", + data: struct { + A struct { + A *[]int `json:"a,omitempty"` + } + }{A: struct { + A *[]int `json:"a,omitempty"` + }{sliceptr([]int{-1})}}, + }, + { + name: "HeadSlicePtrNotRootString", + data: struct { + A struct { + A *[]int `json:"a,string"` + } + }{A: struct { + A *[]int `json:"a,string"` + }{sliceptr([]int{-1})}}, + }, + + // HeadSlicePtrNilNotRoot + { + name: "HeadSlicePtrNilNotRoot", + data: struct { + A struct { + A *[]int `json:"a"` + } + }{}, + }, + { + name: "HeadSlicePtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *[]int `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadSlicePtrNilNotRootString", + data: struct { + A struct { + A *[]int `json:"a,string"` + } + }{}, + }, + + // PtrHeadSliceZeroNotRoot + { + name: "PtrHeadSliceZeroNotRoot", + data: struct { + A *struct { + A []int `json:"a"` + } + }{A: new(struct { + A []int `json:"a"` + })}, + }, + { + name: "PtrHeadSliceZeroNotRootOmitEmpty", + data: struct { + A *struct { + A []int `json:"a,omitempty"` + } + }{A: new(struct { + A []int `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadSliceZeroNotRootString", + data: struct { + A *struct { + A []int `json:"a,string"` + } + }{A: new(struct { + A []int `json:"a,string"` + })}, + }, + + // PtrHeadSliceNotRoot + { + name: "PtrHeadSliceNotRoot", + data: struct { + A *struct { + A []int `json:"a"` + } + }{A: &(struct { + A []int `json:"a"` + }{A: []int{-1}})}, + }, + { + name: "PtrHeadSliceNotRootOmitEmpty", + data: struct { + A *struct { + A []int `json:"a,omitempty"` + } + }{A: &(struct { + A []int `json:"a,omitempty"` + }{A: []int{-1}})}, + }, + { + name: "PtrHeadSliceNotRootString", + data: struct { + A *struct { + A []int `json:"a,string"` + } + }{A: &(struct { + A []int `json:"a,string"` + }{A: []int{-1}})}, + }, + + // PtrHeadSlicePtrNotRoot + { + name: "PtrHeadSlicePtrNotRoot", + data: struct { + A *struct { + A *[]int `json:"a"` + } + }{A: &(struct { + A *[]int `json:"a"` + }{A: sliceptr([]int{-1})})}, + }, + { + name: "PtrHeadSlicePtrNotRootOmitEmpty", + data: struct { + A *struct { + A *[]int `json:"a,omitempty"` + } + }{A: &(struct { + A *[]int `json:"a,omitempty"` + }{A: sliceptr([]int{-1})})}, + }, + { + name: "PtrHeadSlicePtrNotRootString", + data: struct { + A *struct { + A *[]int `json:"a,string"` + } + }{A: &(struct { + A *[]int `json:"a,string"` + }{A: sliceptr([]int{-1})})}, + }, + + // PtrHeadSlicePtrNilNotRoot + { + name: "PtrHeadSlicePtrNilNotRoot", + data: struct { + A *struct { + A *[]int `json:"a"` + } + }{A: &(struct { + A *[]int `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadSlicePtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *[]int `json:"a,omitempty"` + } + }{A: &(struct { + A *[]int `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadSlicePtrNilNotRootString", + data: struct { + A *struct { + A *[]int `json:"a,string"` + } + }{A: &(struct { + A *[]int `json:"a,string"` + }{A: nil})}, + }, + + // PtrHeadSliceNilNotRoot + { + name: "PtrHeadSliceNilNotRoot", + data: struct { + A *struct { + A *[]int `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadSliceNilNotRootOmitEmpty", + data: struct { + A *struct { + A *[]int `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadSliceNilNotRootString", + data: struct { + A *struct { + A *[]int `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + + // HeadSliceZeroMultiFieldsNotRoot + { + name: "HeadSliceZeroMultiFieldsNotRoot", + data: struct { + A struct { + A []int `json:"a"` + } + B struct { + B []int `json:"b"` + } + }{}, + }, + { + name: "HeadSliceZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A []int `json:"a,omitempty"` + } + B struct { + B []int `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadSliceZeroMultiFieldsNotRootString", + data: struct { + A struct { + A []int `json:"a,string"` + } + B struct { + B []int `json:"b,string"` + } + }{}, + }, + + // HeadSliceMultiFieldsNotRoot + { + name: "HeadSliceMultiFieldsNotRoot", + data: struct { + A struct { + A []int `json:"a"` + } + B struct { + B []int `json:"b"` + } + }{A: struct { + A []int `json:"a"` + }{A: []int{-1}}, B: struct { + B []int `json:"b"` + }{B: []int{0}}}, + }, + { + name: "HeadSliceMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A []int `json:"a,omitempty"` + } + B struct { + B []int `json:"b,omitempty"` + } + }{A: struct { + A []int `json:"a,omitempty"` + }{A: []int{-1}}, B: struct { + B []int `json:"b,omitempty"` + }{B: []int{1}}}, + }, + { + name: "HeadSliceMultiFieldsNotRootString", + data: struct { + A struct { + A []int `json:"a,string"` + } + B struct { + B []int `json:"b,string"` + } + }{A: struct { + A []int `json:"a,string"` + }{A: []int{-1}}, B: struct { + B []int `json:"b,string"` + }{B: []int{1}}}, + }, + + // HeadSlicePtrMultiFieldsNotRoot + { + name: "HeadSlicePtrMultiFieldsNotRoot", + data: struct { + A struct { + A *[]int `json:"a"` + } + B struct { + B *[]int `json:"b"` + } + }{A: struct { + A *[]int `json:"a"` + }{A: sliceptr([]int{-1})}, B: struct { + B *[]int `json:"b"` + }{B: sliceptr([]int{1})}}, + }, + { + name: "HeadSlicePtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *[]int `json:"a,omitempty"` + } + B struct { + B *[]int `json:"b,omitempty"` + } + }{A: struct { + A *[]int `json:"a,omitempty"` + }{A: sliceptr([]int{-1})}, B: struct { + B *[]int `json:"b,omitempty"` + }{B: sliceptr([]int{1})}}, + }, + { + name: "HeadSlicePtrMultiFieldsNotRootString", + data: struct { + A struct { + A *[]int `json:"a,string"` + } + B struct { + B *[]int `json:"b,string"` + } + }{A: struct { + A *[]int `json:"a,string"` + }{A: sliceptr([]int{-1})}, B: struct { + B *[]int `json:"b,string"` + }{B: sliceptr([]int{1})}}, + }, + + // HeadSlicePtrNilMultiFieldsNotRoot + { + name: "HeadSlicePtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *[]int `json:"a"` + } + B struct { + B *[]int `json:"b"` + } + }{A: struct { + A *[]int `json:"a"` + }{A: nil}, B: struct { + B *[]int `json:"b"` + }{B: nil}}, + }, + { + name: "HeadSlicePtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *[]int `json:"a,omitempty"` + } + B struct { + B *[]int `json:"b,omitempty"` + } + }{A: struct { + A *[]int `json:"a,omitempty"` + }{A: nil}, B: struct { + B *[]int `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadSlicePtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *[]int `json:"a,string"` + } + B struct { + B *[]int `json:"b,string"` + } + }{A: struct { + A *[]int `json:"a,string"` + }{A: nil}, B: struct { + B *[]int `json:"b,string"` + }{B: nil}}, + }, + + // PtrHeadSliceZeroMultiFieldsNotRoot + { + name: "PtrHeadSliceZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A []int `json:"a"` + } + B struct { + B []int `json:"b"` + } + }{}, + }, + { + name: "PtrHeadSliceZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A []int `json:"a,omitempty"` + } + B struct { + B []int `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadSliceZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A []int `json:"a,string"` + } + B struct { + B []int `json:"b,string"` + } + }{}, + }, + + // PtrHeadSliceMultiFieldsNotRoot + { + name: "PtrHeadSliceMultiFieldsNotRoot", + data: &struct { + A struct { + A []int `json:"a"` + } + B struct { + B []int `json:"b"` + } + }{A: struct { + A []int `json:"a"` + }{A: []int{-1}}, B: struct { + B []int `json:"b"` + }{B: []int{1}}}, + }, + { + name: "PtrHeadSliceMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A []int `json:"a,omitempty"` + } + B struct { + B []int `json:"b,omitempty"` + } + }{A: struct { + A []int `json:"a,omitempty"` + }{A: []int{-1}}, B: struct { + B []int `json:"b,omitempty"` + }{B: []int{1}}}, + }, + { + name: "PtrHeadSliceMultiFieldsNotRootString", + data: &struct { + A struct { + A []int `json:"a,string"` + } + B struct { + B []int `json:"b,string"` + } + }{A: struct { + A []int `json:"a,string"` + }{A: []int{-1}}, B: struct { + B []int `json:"b,string"` + }{B: []int{1}}}, + }, + + // PtrHeadSlicePtrMultiFieldsNotRoot + { + name: "PtrHeadSlicePtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[]int `json:"a"` + } + B *struct { + B *[]int `json:"b"` + } + }{A: &(struct { + A *[]int `json:"a"` + }{A: sliceptr([]int{-1})}), B: &(struct { + B *[]int `json:"b"` + }{B: sliceptr([]int{1})})}, + }, + { + name: "PtrHeadSlicePtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[]int `json:"a,omitempty"` + } + B *struct { + B *[]int `json:"b,omitempty"` + } + }{A: &(struct { + A *[]int `json:"a,omitempty"` + }{A: sliceptr([]int{-1})}), B: &(struct { + B *[]int `json:"b,omitempty"` + }{B: sliceptr([]int{1})})}, + }, + { + name: "PtrHeadSlicePtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[]int `json:"a,string"` + } + B *struct { + B *[]int `json:"b,string"` + } + }{A: &(struct { + A *[]int `json:"a,string"` + }{A: sliceptr([]int{-1})}), B: &(struct { + B *[]int `json:"b,string"` + }{B: sliceptr([]int{1})})}, + }, + + // PtrHeadSlicePtrNilMultiFieldsNotRoot + { + name: "PtrHeadSlicePtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[]int `json:"a"` + } + B *struct { + B *[]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSlicePtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[]int `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *[]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSlicePtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[]int `json:"a,string"` + } `json:",string"` + B *struct { + B *[]int `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + + // PtrHeadSliceNilMultiFieldsNotRoot + { + name: "PtrHeadSliceNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *[]int `json:"a"` + } + B *struct { + B *[]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadSliceNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *[]int `json:"a,omitempty"` + } + B *struct { + B *[]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadSliceNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *[]int `json:"a,string"` + } + B *struct { + B *[]int `json:"b,string"` + } + })(nil), + }, + + // PtrHeadSliceDoubleMultiFieldsNotRoot + { + name: "PtrHeadSliceDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A []int `json:"a"` + B []int `json:"b"` + } + B *struct { + A []int `json:"a"` + B []int `json:"b"` + } + }{A: &(struct { + A []int `json:"a"` + B []int `json:"b"` + }{A: []int{-1}, B: []int{1}}), B: &(struct { + A []int `json:"a"` + B []int `json:"b"` + }{A: []int{-1}, B: nil})}, + }, + { + name: "PtrHeadSliceDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + } + B *struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + } + }{A: &(struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + }{A: []int{-1}, B: []int{1}}), B: &(struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + }{A: []int{-1}, B: nil})}, + }, + { + name: "PtrHeadSliceDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + } + B *struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + } + }{A: &(struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + }{A: []int{-1}, B: []int{1}}), B: &(struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + }{A: []int{-1}, B: nil})}, + }, + + // PtrHeadSliceNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadSliceNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A []int `json:"a"` + B []int `json:"b"` + } + B *struct { + A []int `json:"a"` + B []int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSliceNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSliceNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + } + B *struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadSliceNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadSliceNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A []int `json:"a"` + B []int `json:"b"` + } + B *struct { + A []int `json:"a"` + B []int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadSliceNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + } + B *struct { + A []int `json:"a,omitempty"` + B []int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadSliceNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + } + B *struct { + A []int `json:"a,string"` + B []int `json:"b,string"` + } + })(nil), + }, + + // PtrHeadSlicePtrDoubleMultiFieldsNotRoot + { + name: "PtrHeadSlicePtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + } + B *struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + } + }{A: &(struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadSlicePtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + } + B *struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + } + }{A: &(struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + }{A: nil, B: nil})}, + }, + { + name: "PtrHeadSlicePtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + } + B *struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + } + }{A: &(struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + }{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + }{A: nil, B: nil})}, + }, + + // PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + } + B *struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + } + B *struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + } + B *struct { + A *[]int `json:"a"` + B *[]int `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + } + B *struct { + A *[]int `json:"a,omitempty"` + B *[]int `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + } + B *struct { + A *[]int `json:"a,string"` + B *[]int `json:"b,string"` + } + })(nil), + }, + + // AnonymousHeadSlice + { + name: "AnonymousHeadSlice", + data: struct { + structSlice + B []int `json:"b"` + }{ + structSlice: structSlice{A: []int{-1}}, + B: nil, + }, + }, + { + name: "AnonymousHeadSliceOmitEmpty", + data: struct { + structSliceOmitEmpty + B []int `json:"b,omitempty"` + }{ + structSliceOmitEmpty: structSliceOmitEmpty{A: []int{-1}}, + B: nil, + }, + }, + { + name: "AnonymousHeadSliceString", + data: struct { + structSliceString + B []int `json:"b,string"` + }{ + structSliceString: structSliceString{A: []int{-1}}, + B: nil, + }, + }, + + // PtrAnonymousHeadSlice + { + name: "PtrAnonymousHeadSlice", + data: struct { + *structSlice + B []int `json:"b"` + }{ + structSlice: &structSlice{A: []int{-1}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadSliceOmitEmpty", + data: struct { + *structSliceOmitEmpty + B []int `json:"b,omitempty"` + }{ + structSliceOmitEmpty: &structSliceOmitEmpty{A: []int{-1}}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadSliceString", + data: struct { + *structSliceString + B []int `json:"b,string"` + }{ + structSliceString: &structSliceString{A: []int{-1}}, + B: nil, + }, + }, + + // PtrAnonymousHeadSliceNil + { + name: "PtrAnonymousHeadSliceNil", + data: struct { + *structSlice + B []int `json:"b"` + }{ + structSlice: &structSlice{A: nil}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadSliceNilOmitEmpty", + data: struct { + *structSliceOmitEmpty + B []int `json:"b,omitempty"` + }{ + structSliceOmitEmpty: &structSliceOmitEmpty{A: nil}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadSliceNilString", + data: struct { + *structSliceString + B []int `json:"b,string"` + }{ + structSliceString: &structSliceString{A: nil}, + B: nil, + }, + }, + + // NilPtrAnonymousHeadSlice + { + name: "NilPtrAnonymousHeadSlice", + data: struct { + *structSlice + B []int `json:"b"` + }{ + structSlice: nil, + B: []int{-1}, + }, + }, + { + name: "NilPtrAnonymousHeadSliceOmitEmpty", + data: struct { + *structSliceOmitEmpty + B []int `json:"b,omitempty"` + }{ + structSliceOmitEmpty: nil, + B: []int{-1}, + }, + }, + { + name: "NilPtrAnonymousHeadSliceString", + data: struct { + *structSliceString + B []int `json:"b,string"` + }{ + structSliceString: nil, + B: []int{-1}, + }, + }, + + // AnonymousHeadSlicePtr + { + name: "AnonymousHeadSlicePtr", + data: struct { + structSlicePtr + B *[]int `json:"b"` + }{ + structSlicePtr: structSlicePtr{A: sliceptr([]int{-1})}, + B: nil, + }, + }, + { + name: "AnonymousHeadSlicePtrOmitEmpty", + data: struct { + structSlicePtrOmitEmpty + B *[]int `json:"b,omitempty"` + }{ + structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: sliceptr([]int{-1})}, + B: nil, + }, + }, + { + name: "AnonymousHeadSlicePtrString", + data: struct { + structSlicePtrString + B *[]int `json:"b,string"` + }{ + structSlicePtrString: structSlicePtrString{A: sliceptr([]int{-1})}, + B: nil, + }, + }, + + // AnonymousHeadSlicePtrNil + { + name: "AnonymousHeadSlicePtrNil", + data: struct { + structSlicePtr + B *[]int `json:"b"` + }{ + structSlicePtr: structSlicePtr{A: nil}, + B: sliceptr([]int{-1}), + }, + }, + { + name: "AnonymousHeadSlicePtrNilOmitEmpty", + data: struct { + structSlicePtrOmitEmpty + B *[]int `json:"b,omitempty"` + }{ + structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: nil}, + B: sliceptr([]int{-1}), + }, + }, + { + name: "AnonymousHeadSlicePtrNilString", + data: struct { + structSlicePtrString + B *[]int `json:"b,string"` + }{ + structSlicePtrString: structSlicePtrString{A: nil}, + B: sliceptr([]int{-1}), + }, + }, + + // PtrAnonymousHeadSlicePtr + { + name: "PtrAnonymousHeadSlicePtr", + data: struct { + *structSlicePtr + B *[]int `json:"b"` + }{ + structSlicePtr: &structSlicePtr{A: sliceptr([]int{-1})}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadSlicePtrOmitEmpty", + data: struct { + *structSlicePtrOmitEmpty + B *[]int `json:"b,omitempty"` + }{ + structSlicePtrOmitEmpty: &structSlicePtrOmitEmpty{A: sliceptr([]int{-1})}, + B: nil, + }, + }, + { + name: "PtrAnonymousHeadSlicePtrString", + data: struct { + *structSlicePtrString + B *[]int `json:"b,string"` + }{ + structSlicePtrString: &structSlicePtrString{A: sliceptr([]int{-1})}, + B: nil, + }, + }, + + // NilPtrAnonymousHeadSlicePtr + { + name: "NilPtrAnonymousHeadSlicePtr", + data: struct { + *structSlicePtr + B *[]int `json:"b"` + }{ + structSlicePtr: nil, + B: sliceptr([]int{-1}), + }, + }, + { + name: "NilPtrAnonymousHeadSlicePtrOmitEmpty", + data: struct { + *structSlicePtrOmitEmpty + B *[]int `json:"b,omitempty"` + }{ + structSlicePtrOmitEmpty: nil, + B: sliceptr([]int{-1}), + }, + }, + { + name: "NilPtrAnonymousHeadSlicePtrString", + data: struct { + *structSlicePtrString + B *[]int `json:"b,string"` + }{ + structSlicePtrString: nil, + B: sliceptr([]int{-1}), + }, + }, + + // AnonymousHeadSliceOnly + { + name: "AnonymousHeadSliceOnly", + data: struct { + structSlice + }{ + structSlice: structSlice{A: []int{-1}}, + }, + }, + { + name: "AnonymousHeadSliceOnlyOmitEmpty", + data: struct { + structSliceOmitEmpty + }{ + structSliceOmitEmpty: structSliceOmitEmpty{A: []int{-1}}, + }, + }, + { + name: "AnonymousHeadSliceOnlyString", + data: struct { + structSliceString + }{ + structSliceString: structSliceString{A: []int{-1}}, + }, + }, + + // PtrAnonymousHeadSliceOnly + { + name: "PtrAnonymousHeadSliceOnly", + data: struct { + *structSlice + }{ + structSlice: &structSlice{A: []int{-1}}, + }, + }, + { + name: "PtrAnonymousHeadSliceOnlyOmitEmpty", + data: struct { + *structSliceOmitEmpty + }{ + structSliceOmitEmpty: &structSliceOmitEmpty{A: []int{-1}}, + }, + }, + { + name: "PtrAnonymousHeadSliceOnlyString", + data: struct { + *structSliceString + }{ + structSliceString: &structSliceString{A: []int{-1}}, + }, + }, + + // NilPtrAnonymousHeadSliceOnly + { + name: "NilPtrAnonymousHeadSliceOnly", + data: struct { + *structSlice + }{ + structSlice: nil, + }, + }, + { + name: "NilPtrAnonymousHeadSliceOnlyOmitEmpty", + data: struct { + *structSliceOmitEmpty + }{ + structSliceOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadSliceOnlyString", + data: struct { + *structSliceString + }{ + structSliceString: nil, + }, + }, + + // AnonymousHeadSlicePtrOnly + { + name: "AnonymousHeadSlicePtrOnly", + data: struct { + structSlicePtr + }{ + structSlicePtr: structSlicePtr{A: sliceptr([]int{-1})}, + }, + }, + { + name: "AnonymousHeadSlicePtrOnlyOmitEmpty", + data: struct { + structSlicePtrOmitEmpty + }{ + structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: sliceptr([]int{-1})}, + }, + }, + { + name: "AnonymousHeadSlicePtrOnlyString", + data: struct { + structSlicePtrString + }{ + structSlicePtrString: structSlicePtrString{A: sliceptr([]int{-1})}, + }, + }, + + // AnonymousHeadSlicePtrNilOnly + { + name: "AnonymousHeadSlicePtrNilOnly", + data: struct { + structSlicePtr + }{ + structSlicePtr: structSlicePtr{A: nil}, + }, + }, + { + name: "AnonymousHeadSlicePtrNilOnlyOmitEmpty", + data: struct { + structSlicePtrOmitEmpty + }{ + structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadSlicePtrNilOnlyString", + data: struct { + structSlicePtrString + }{ + structSlicePtrString: structSlicePtrString{A: nil}, + }, + }, + + // PtrAnonymousHeadSlicePtrOnly + { + name: "PtrAnonymousHeadSlicePtrOnly", + data: struct { + *structSlicePtr + }{ + structSlicePtr: &structSlicePtr{A: sliceptr([]int{-1})}, + }, + }, + { + name: "PtrAnonymousHeadSlicePtrOnlyOmitEmpty", + data: struct { + *structSlicePtrOmitEmpty + }{ + structSlicePtrOmitEmpty: &structSlicePtrOmitEmpty{A: sliceptr([]int{-1})}, + }, + }, + { + name: "PtrAnonymousHeadSlicePtrOnlyString", + data: struct { + *structSlicePtrString + }{ + structSlicePtrString: &structSlicePtrString{A: sliceptr([]int{-1})}, + }, + }, + + // NilPtrAnonymousHeadSlicePtrOnly + { + name: "NilPtrAnonymousHeadSlicePtrOnly", + data: struct { + *structSlicePtr + }{ + structSlicePtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadSlicePtrOnlyOmitEmpty", + data: struct { + *structSlicePtrOmitEmpty + }{ + structSlicePtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadSlicePtrOnlyString", + data: struct { + *structSlicePtrString + }{ + structSlicePtrString: nil, + }, + }, + } + for _, test := range tests { + for _, indent := range []bool{true, false} { + for _, htmlEscape := range []bool{true, false} { + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + enc.SetEscapeHTML(htmlEscape) + if indent { + enc.SetIndent("", " ") + } + if err := enc.Encode(test.data); err != nil { + 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:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String()) + } + } + } + } +} diff --git a/cover_string_test.go b/cover_string_test.go index d0665cc..d80d296 100644 --- a/cover_string_test.go +++ b/cover_string_test.go @@ -1793,11 +1793,11 @@ func TestCoverString(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/cover_uint16_test.go b/cover_uint16_test.go index 4b450c2..446b69f 100644 --- a/cover_uint16_test.go +++ b/cover_uint16_test.go @@ -1774,11 +1774,11 @@ func TestCoverUint16(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/decode_compile.go b/decode_compile.go index da9f1c0..e6ed018 100644 --- a/decode_compile.go +++ b/decode_compile.go @@ -80,7 +80,7 @@ func decodeCompile(typ *rtype, structName, fieldName string, structTypeToDecoder case reflect.Uint64: return decodeCompileUint64(typ, structName, fieldName) case reflect.String: - return decodeCompileString(structName, fieldName) + return decodeCompileString(typ, structName, fieldName) case reflect.Bool: return decodeCompileBool(structName, fieldName) case reflect.Float32: @@ -203,7 +203,12 @@ func decodeCompileFloat64(structName, fieldName string) (decoder, error) { }), nil } -func decodeCompileString(structName, fieldName string) (decoder, error) { +func decodeCompileString(typ *rtype, structName, fieldName string) (decoder, error) { + if typ == type2rtype(jsonNumberType) { + return newNumberDecoder(structName, fieldName, func(p unsafe.Pointer, v Number) { + *(*Number)(p) = v + }), nil + } return newStringDecoder(structName, fieldName), nil } diff --git a/decode_number.go b/decode_number.go index bf358cb..c667161 100644 --- a/decode_number.go +++ b/decode_number.go @@ -1,42 +1,118 @@ package json import ( + "strconv" "unsafe" ) type numberDecoder struct { - *floatDecoder - op func(unsafe.Pointer, Number) - structName string - fieldName string + stringDecoder *stringDecoder + op func(unsafe.Pointer, Number) + structName string + fieldName string } func newNumberDecoder(structName, fieldName string, op func(unsafe.Pointer, Number)) *numberDecoder { return &numberDecoder{ - floatDecoder: newFloatDecoder(structName, fieldName, nil), - op: op, - structName: structName, - fieldName: fieldName, + stringDecoder: newStringDecoder(structName, fieldName), + op: op, + structName: structName, + fieldName: fieldName, } } func (d *numberDecoder) decodeStream(s *stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.floatDecoder.decodeStreamByte(s) + bytes, err := d.decodeStreamByte(s) if err != nil { return err } + if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { + return &SyntaxError{msg: err.Error(), Offset: s.totalOffset()} + } d.op(p, Number(string(bytes))) s.reset() return nil } func (d *numberDecoder) decode(buf []byte, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.floatDecoder.decodeByte(buf, cursor) + bytes, c, err := d.decodeByte(buf, cursor) if err != nil { return 0, err } + if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { + return 0, &SyntaxError{msg: err.Error(), Offset: c} + } cursor = c s := *(*string)(unsafe.Pointer(&bytes)) d.op(p, Number(s)) return cursor, nil } + +func (d *numberDecoder) decodeStreamByte(s *stream) ([]byte, error) { + for { + switch s.char() { + case ' ', '\n', '\t', '\r': + s.cursor++ + continue + case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + return floatBytes(s), nil + case 'n': + if err := nullBytes(s); err != nil { + return nil, err + } + return nil, nil + case '"': + return d.stringDecoder.decodeStreamByte(s) + case nul: + if s.read() { + continue + } + goto ERROR + default: + goto ERROR + } + } +ERROR: + return nil, errUnexpectedEndOfJSON("json.Number", s.totalOffset()) +} + +func (d *numberDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { + buflen := int64(len(buf)) + for ; cursor < buflen; cursor++ { + switch buf[cursor] { + case ' ', '\n', '\t', '\r': + continue + case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + start := cursor + cursor++ + for ; cursor < buflen; cursor++ { + if floatTable[buf[cursor]] { + continue + } + break + } + num := buf[start:cursor] + return num, cursor, nil + case 'n': + if cursor+3 >= buflen { + return nil, 0, errUnexpectedEndOfJSON("null", cursor) + } + if buf[cursor+1] != 'u' { + return nil, 0, errInvalidCharacter(buf[cursor+1], "null", cursor) + } + if buf[cursor+2] != 'l' { + return nil, 0, errInvalidCharacter(buf[cursor+2], "null", cursor) + } + if buf[cursor+3] != 'l' { + return nil, 0, errInvalidCharacter(buf[cursor+3], "null", cursor) + } + cursor += 4 + return nil, cursor, nil + case '"': + return d.stringDecoder.decodeByte(buf, cursor) + default: + return nil, 0, errUnexpectedEndOfJSON("json.Number", cursor) + } + } + return nil, 0, errUnexpectedEndOfJSON("json.Number", cursor) +} diff --git a/decode_test.go b/decode_test.go index 0d30b9d..58e6307 100644 --- a/decode_test.go +++ b/decode_test.go @@ -1251,31 +1251,31 @@ var unmarshalTests = []unmarshalTest{ in: `invalid`, // 143 ptr: new(json.Number), err: json.NewSyntaxError( - `json: invalid character v as null`, + `json: json.Number unexpected end of JSON input`, 1, ), }, { in: `"invalid"`, // 144 ptr: new(json.Number), - err: fmt.Errorf(`strconv.ParseFloat: parsing "\"invalid\"": invalid syntax`), + err: fmt.Errorf(`strconv.ParseFloat: parsing "invalid": invalid syntax`), }, { in: `{"A":"invalid"}`, // 145 ptr: new(struct{ A json.Number }), - err: fmt.Errorf(`strconv.ParseFloat: parsing "\"invalid\"": invalid syntax`), + err: fmt.Errorf(`strconv.ParseFloat: parsing "invalid": invalid syntax`), }, { in: `{"A":"invalid"}`, // 146 ptr: new(struct { A json.Number `json:",string"` }), - err: fmt.Errorf(`json: null unexpected end of JSON input`), + err: fmt.Errorf(`json: json.Number unexpected end of JSON input`), }, { in: `{"A":"invalid"}`, // 147 ptr: new(map[string]json.Number), - err: fmt.Errorf(`strconv.ParseFloat: parsing "\"invalid\"": invalid syntax`), + err: fmt.Errorf(`strconv.ParseFloat: parsing "invalid": invalid syntax`), }, /* // invalid UTF-8 is coerced to valid UTF-8. @@ -1836,6 +1836,7 @@ func TestUnmarshal(t *testing.T) { // Check round trip also decodes correctly. if tt.err == nil { + //fmt.Println("iface = ", v.Interface(), v.Type()) enc, err := json.Marshal(v.Interface()) if err != nil { t.Errorf("#%d: error re-marshaling: %v", i, err) diff --git a/encode.go b/encode.go index 1d13270..2d51c57 100644 --- a/encode.go +++ b/encode.go @@ -2,10 +2,14 @@ package json import ( "bytes" + "encoding" "encoding/base64" + "fmt" "io" "math" + "reflect" "strconv" + "strings" "sync" "unsafe" ) @@ -358,7 +362,147 @@ func encodeByteSlice(b []byte, src []byte) []byte { return append(append(b, buf...), '"') } +func encodeNumber(b []byte, n Number) ([]byte, error) { + if len(n) == 0 { + return append(b, '0'), nil + } + for i := 0; i < len(n); i++ { + if !floatTable[n[i]] { + return nil, fmt.Errorf("json: invalid number literal %q", n) + } + } + b = append(b, n...) + return b, nil +} + func appendIndent(ctx *encodeRuntimeContext, b []byte, indent int) []byte { b = append(b, ctx.prefix...) return append(b, bytes.Repeat(ctx.indentStr, ctx.baseIndent+indent)...) } + +func encodeIsNilForMarshaler(v interface{}) bool { + rv := reflect.ValueOf(v) + switch rv.Kind() { + case reflect.Interface, reflect.Map, reflect.Ptr: + return rv.IsNil() + case reflect.Slice: + return rv.IsNil() || rv.Len() == 0 + } + return false +} + +func encodeMarshalJSON(code *opcode, b []byte, v interface{}, escape bool) ([]byte, error) { + rv := reflect.ValueOf(v) // convert by dynamic interface type + if code.addrForMarshaler { + if rv.CanAddr() { + rv = rv.Addr() + } else { + newV := reflect.New(rv.Type()) + newV.Elem().Set(rv) + rv = newV + } + } + v = rv.Interface() + marshaler, ok := v.(Marshaler) + if !ok { + return encodeNull(b), nil + } + bb, err := marshaler.MarshalJSON() + if err != nil { + return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + buf := bytes.NewBuffer(b) + //TODO: we should validate buffer with `compact` + if err := compact(buf, bb, escape); err != nil { + return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + return buf.Bytes(), nil +} + +func encodeMarshalJSONIndent(ctx *encodeRuntimeContext, code *opcode, b []byte, v interface{}, indent int, escape bool) ([]byte, error) { + rv := reflect.ValueOf(v) // convert by dynamic interface type + if code.addrForMarshaler { + if rv.CanAddr() { + rv = rv.Addr() + } else { + newV := reflect.New(rv.Type()) + newV.Elem().Set(rv) + rv = newV + } + } + v = rv.Interface() + marshaler, ok := v.(Marshaler) + if !ok { + return encodeNull(b), nil + } + bb, err := marshaler.MarshalJSON() + if err != nil { + return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + var compactBuf bytes.Buffer + if err := compact(&compactBuf, bb, escape); err != nil { + return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + var indentBuf bytes.Buffer + if err := encodeWithIndent( + &indentBuf, + compactBuf.Bytes(), + string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+indent+1), + string(ctx.indentStr), + ); err != nil { + return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + return append(b, indentBuf.Bytes()...), nil +} + +func encodeMarshalText(code *opcode, b []byte, v interface{}, escape bool) ([]byte, error) { + rv := reflect.ValueOf(v) // convert by dynamic interface type + if code.addrForMarshaler { + if rv.CanAddr() { + rv = rv.Addr() + } else { + newV := reflect.New(rv.Type()) + newV.Elem().Set(rv) + rv = newV + } + } + v = rv.Interface() + marshaler, ok := v.(encoding.TextMarshaler) + if !ok { + return encodeNull(b), nil + } + bytes, err := marshaler.MarshalText() + if err != nil { + return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + if escape { + return encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil + } + return encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil +} + +func encodeMarshalTextIndent(code *opcode, b []byte, v interface{}, escape bool) ([]byte, error) { + rv := reflect.ValueOf(v) // convert by dynamic interface type + if code.addrForMarshaler { + if rv.CanAddr() { + rv = rv.Addr() + } else { + newV := reflect.New(rv.Type()) + newV.Elem().Set(rv) + rv = newV + } + } + v = rv.Interface() + marshaler, ok := v.(encoding.TextMarshaler) + if !ok { + return encodeNull(b), nil + } + bytes, err := marshaler.MarshalText() + if err != nil { + return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} + } + if escape { + return encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil + } + return encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))), nil +} diff --git a/encode_compile.go b/encode_compile.go index c3b33eb..4f21288 100644 --- a/encode_compile.go +++ b/encode_compile.go @@ -24,6 +24,7 @@ type opcodeSet struct { var ( marshalJSONType = reflect.TypeOf((*Marshaler)(nil)).Elem() marshalTextType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() + jsonNumberType = reflect.TypeOf(Number("")) ) func encodeCompileToGetCodeSetSlowPath(typeptr uintptr) (*opcodeSet, error) { @@ -56,42 +57,44 @@ func encodeCompileToGetCodeSetSlowPath(typeptr uintptr) (*opcodeSet, error) { func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) { typ := ctx.typ switch { - case typ.Implements(marshalJSONType): + case encodeImplementsMarshalJSON(typ): return encodeCompileMarshalJSON(ctx) - case rtype_ptrTo(typ).Implements(marshalJSONType): - return encodeCompileMarshalJSONPtr(ctx) - case typ.Implements(marshalTextType): + case encodeImplementsMarshalText(typ): return encodeCompileMarshalText(ctx) - case rtype_ptrTo(typ).Implements(marshalTextType): - return encodeCompileMarshalTextPtr(ctx) } + isPtr := false orgType := typ if typ.Kind() == reflect.Ptr { typ = typ.Elem() isPtr = true } + switch { + case encodeImplementsMarshalJSON(typ): + return encodeCompileMarshalJSON(ctx) + case encodeImplementsMarshalText(typ): + return encodeCompileMarshalText(ctx) + } if typ.Kind() == reflect.Map { - return encodeCompileMap(ctx.withType(typ), isPtr) + if isPtr { + return encodeCompilePtr(ctx.withType(rtype_ptrTo(typ))) + } + return encodeCompileMap(ctx.withType(typ)) } else if typ.Kind() == reflect.Struct { code, err := encodeCompileStruct(ctx.withType(typ), isPtr) if err != nil { return nil, err } - encodeConvertHeadOnlyCode(code, isPtr) encodeOptimizeStructEnd(code) encodeLinkRecursiveCode(code) return code, nil } else if isPtr && typ.Implements(marshalTextType) { typ = orgType - } 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) encodeOptimizeStructEnd(code) encodeLinkRecursiveCode(code) return code, nil @@ -100,9 +103,7 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) { func encodeLinkRecursiveCode(c *opcode) { for code := c; code.op != opEnd && code.op != opStructFieldRecursiveEnd; { switch code.op { - case opStructFieldRecursive, - opStructFieldPtrAnonymousHeadRecursive, - opStructFieldAnonymousHeadRecursive: + case opStructFieldRecursive, opStructFieldRecursivePtr: if code.jmp.linked { code = code.next continue @@ -143,7 +144,7 @@ func encodeLinkRecursiveCode(c *opcode) { func encodeOptimizeStructEnd(c *opcode) { for code := c; code.op != opEnd; { - if code.op == opStructFieldRecursive { + if code.op == opStructFieldRecursive || code.op == opStructFieldRecursivePtr { // ignore if exists recursive operation return } @@ -163,7 +164,13 @@ func encodeOptimizeStructEnd(c *opcode) { switch code.op { case opStructEnd: prev := code.prevField - if strings.Contains(prev.op.String(), "Head") { + prevOp := prev.op.String() + if strings.Contains(prevOp, "Head") || + strings.Contains(prevOp, "Slice") || + strings.Contains(prevOp, "Array") || + strings.Contains(prevOp, "Map") || + strings.Contains(prevOp, "MarshalJSON") || + strings.Contains(prevOp, "MarshalText") { // not exists field code = code.next break @@ -182,96 +189,62 @@ func encodeOptimizeStructEnd(c *opcode) { } } -func encodeConvertHeadOnlyCode(c *opcode, isPtrHead bool) { - if c.nextField == nil { - return +func encodeImplementsMarshalJSON(typ *rtype) bool { + if !typ.Implements(marshalJSONType) { + return false } - 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): - return true - case rtype_ptrTo(typ).Implements(marshalJSONType): - return true - case typ.Implements(marshalTextType): - return true - case rtype_ptrTo(typ).Implements(marshalTextType): + if typ.Kind() != reflect.Ptr { return true } + // type kind is reflect.Ptr + if !typ.Elem().Implements(marshalJSONType) { + return true + } + // needs to dereference return false } -func encodeCompile(ctx *encodeCompileContext) (*opcode, error) { +func encodeImplementsMarshalText(typ *rtype) bool { + if !typ.Implements(marshalTextType) { + return false + } + if typ.Kind() != reflect.Ptr { + return true + } + // type kind is reflect.Ptr + if !typ.Elem().Implements(marshalTextType) { + return true + } + // needs to dereference + return false +} + +func encodeCompile(ctx *encodeCompileContext, isPtr bool) (*opcode, error) { typ := ctx.typ switch { - case typ.Implements(marshalJSONType): + case encodeImplementsMarshalJSON(typ): return encodeCompileMarshalJSON(ctx) - case rtype_ptrTo(typ).Implements(marshalJSONType): - return encodeCompileMarshalJSONPtr(ctx) - case typ.Implements(marshalTextType): + case encodeImplementsMarshalText(typ): return encodeCompileMarshalText(ctx) - case rtype_ptrTo(typ).Implements(marshalTextType): - return encodeCompileMarshalTextPtr(ctx) } switch typ.Kind() { case reflect.Ptr: return encodeCompilePtr(ctx) case reflect.Slice: elem := typ.Elem() - if !encodeImplementsMarshaler(elem) && elem.Kind() == reflect.Uint8 { - return encodeCompileBytes(ctx) + if elem.Kind() == reflect.Uint8 { + p := rtype_ptrTo(elem) + if !p.Implements(marshalJSONType) && !p.Implements(marshalTextType) { + return encodeCompileBytes(ctx) + } } return encodeCompileSlice(ctx) case reflect.Array: return encodeCompileArray(ctx) case reflect.Map: - return encodeCompileMap(ctx, true) + return encodeCompileMap(ctx) case reflect.Struct: - return encodeCompileStruct(ctx, false) + return encodeCompileStruct(ctx, isPtr) case reflect.Interface: return encodeCompileInterface(ctx) case reflect.Int: @@ -308,13 +281,51 @@ func encodeCompile(ctx *encodeCompileContext) (*opcode, error) { return nil, &UnsupportedTypeError{Type: rtype2type(typ)} } +func encodeConvertPtrOp(code *opcode) opType { + ptrHeadOp := code.op.headToPtrHead() + if code.op != ptrHeadOp { + return ptrHeadOp + } + switch code.op { + case opInt: + return opIntPtr + case opUint: + return opUintPtr + case opFloat32: + return opFloat32Ptr + case opFloat64: + return opFloat64Ptr + case opString: + return opStringPtr + case opBool: + return opBoolPtr + case opBytes: + return opBytesPtr + case opArray: + return opArrayPtr + case opSlice: + return opSlicePtr + case opMap: + return opMapPtr + case opMarshalJSON: + return opMarshalJSONPtr + case opMarshalText: + return opMarshalTextPtr + case opInterface: + return opInterfacePtr + case opStructFieldRecursive: + return opStructFieldRecursivePtr + } + return code.op +} + func encodeCompileKey(ctx *encodeCompileContext) (*opcode, error) { typ := ctx.typ switch { - case rtype_ptrTo(typ).Implements(marshalJSONType): - return encodeCompileMarshalJSONPtr(ctx) - case rtype_ptrTo(typ).Implements(marshalTextType): - return encodeCompileMarshalTextPtr(ctx) + case encodeImplementsMarshalJSON(typ): + return encodeCompileMarshalJSON(ctx) + case encodeImplementsMarshalText(typ): + return encodeCompileMarshalText(ctx) } switch typ.Kind() { case reflect.Ptr: @@ -350,46 +361,31 @@ func encodeCompileKey(ctx *encodeCompileContext) (*opcode, error) { } 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 } - ptrHeadOp := code.op.headToPtrHead() - if code.op != ptrHeadOp { - code.op = ptrHeadOp - code.decOpcodeIndex() - ctx.decIndex() - return code, nil - } - c := ctx.context() - c.opcodeIndex = ptrOpcodeIndex - c.ptrIndex = ptrIndex - return newOpCodeWithNext(c, opPtr, code), nil + code.op = encodeConvertPtrOp(code) + code.ptrNum++ + return code, nil } func encodeCompileMarshalJSON(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opMarshalJSON) - ctx.incIndex() - return code, nil -} - -func encodeCompileMarshalJSONPtr(ctx *encodeCompileContext) (*opcode, error) { - code := newOpCode(ctx.withType(rtype_ptrTo(ctx.typ)), opMarshalJSON) + typ := ctx.typ + if !typ.Implements(marshalJSONType) && rtype_ptrTo(typ).Implements(marshalJSONType) { + code.addrForMarshaler = true + } ctx.incIndex() return code, nil } func encodeCompileMarshalText(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opMarshalText) - ctx.incIndex() - return code, nil -} - -func encodeCompileMarshalTextPtr(ctx *encodeCompileContext) (*opcode, error) { - code := newOpCode(ctx.withType(rtype_ptrTo(ctx.typ)), opMarshalText) + typ := ctx.typ + if !typ.Implements(marshalTextType) && rtype_ptrTo(typ).Implements(marshalTextType) { + code.addrForMarshaler = true + } ctx.incIndex() return code, nil } @@ -593,7 +589,13 @@ func encodeCompileFloat64(ctx *encodeCompileContext) (*opcode, error) { } func encodeCompileString(ctx *encodeCompileContext) (*opcode, error) { - code := newOpCode(ctx, opString) + var op opType + if ctx.typ == type2rtype(jsonNumberType) { + op = opNumber + } else { + op = opString + } + code := newOpCode(ctx, op) ctx.incIndex() return code, nil } @@ -624,7 +626,7 @@ func encodeCompileSlice(ctx *encodeCompileContext) (*opcode, error) { header := newSliceHeaderCode(ctx) ctx.incIndex() - code, err := encodeCompile(ctx.withType(ctx.typ.Elem()).incIndent()) + code, err := encodeCompileSliceElem(ctx.withType(elem).incIndent()) if err != nil { return nil, err } @@ -648,6 +650,18 @@ func encodeCompileSlice(ctx *encodeCompileContext) (*opcode, error) { return (*opcode)(unsafe.Pointer(header)), nil } +func encodeCompileSliceElem(ctx *encodeCompileContext) (*opcode, error) { + typ := ctx.typ + switch { + case !typ.Implements(marshalJSONType) && rtype_ptrTo(typ).Implements(marshalJSONType): + return encodeCompileMarshalJSON(ctx) + case !typ.Implements(marshalTextType) && rtype_ptrTo(typ).Implements(marshalTextType): + return encodeCompileMarshalText(ctx) + default: + return encodeCompile(ctx, false) + } +} + func encodeCompileArray(ctx *encodeCompileContext) (*opcode, error) { ctx.root = false typ := ctx.typ @@ -658,7 +672,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 } @@ -697,12 +711,12 @@ func mapiternext(it unsafe.Pointer) //go:noescape func maplen(m unsafe.Pointer) int -func encodeCompileMap(ctx *encodeCompileContext, withLoad bool) (*opcode, error) { +func encodeCompileMap(ctx *encodeCompileContext) (*opcode, error) { // header => code => value => code => key => code => value => code => end // ^ | // |_______________________| ctx = ctx.incIndent() - header := newMapHeaderCode(ctx, withLoad) + header := newMapHeaderCode(ctx) ctx.incIndex() typ := ctx.typ @@ -716,7 +730,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 } @@ -745,174 +759,122 @@ func encodeCompileMap(ctx *encodeCompileContext, withLoad bool) (*opcode, error) return (*opcode)(unsafe.Pointer(header)), nil } -func encodeTypeToHeaderType(ctx *encodeCompileContext, code *opcode) opType { +func encodeTypeToHeaderType(code *opcode) opType { switch code.op { - case opPtr: - ptrNum := 1 - c := code - ctx.decIndex() - for { - if code.next.op == opPtr { - ptrNum++ - code = code.next - ctx.decIndex() - continue - } - break - } - c.ptrNum = ptrNum - if ptrNum > 1 { - switch code.next.op { - case opInt: - c.mask = code.next.mask - c.rshiftNum = code.next.rshiftNum - return opStructFieldHeadIntNPtr - case opUint: - c.mask = code.next.mask - return opStructFieldHeadUintNPtr - case opFloat32: - return opStructFieldHeadFloat32NPtr - case opFloat64: - return opStructFieldHeadFloat64NPtr - case opString: - return opStructFieldHeadStringNPtr - case opBool: - return opStructFieldHeadBoolNPtr - } - } else { - switch code.next.op { - case opInt: - c.mask = code.next.mask - c.rshiftNum = code.next.rshiftNum - return opStructFieldHeadIntPtr - case opUint: - c.mask = code.next.mask - return opStructFieldHeadUintPtr - case opFloat32: - return opStructFieldHeadFloat32Ptr - case opFloat64: - return opStructFieldHeadFloat64Ptr - case opString: - return opStructFieldHeadStringPtr - case opBool: - return opStructFieldHeadBoolPtr - } - } case opInt: return opStructFieldHeadInt + case opIntPtr: + return opStructFieldHeadIntPtr case opUint: return opStructFieldHeadUint + case opUintPtr: + return opStructFieldHeadUintPtr case opFloat32: return opStructFieldHeadFloat32 + case opFloat32Ptr: + return opStructFieldHeadFloat32Ptr case opFloat64: return opStructFieldHeadFloat64 + case opFloat64Ptr: + return opStructFieldHeadFloat64Ptr case opString: return opStructFieldHeadString + case opStringPtr: + return opStructFieldHeadStringPtr + case opNumber: + return opStructFieldHeadNumber + case opNumberPtr: + return opStructFieldHeadNumberPtr case opBool: return opStructFieldHeadBool - case opMapHead: + case opBoolPtr: + return opStructFieldHeadBoolPtr + case opMap: return opStructFieldHeadMap - case opMapHeadLoad: - return opStructFieldHeadMapLoad - case opArrayHead: + case opMapPtr: + code.op = opMap + return opStructFieldHeadMapPtr + case opArray: return opStructFieldHeadArray - case opSliceHead: + case opArrayPtr: + code.op = opArray + return opStructFieldHeadArrayPtr + case opSlice: return opStructFieldHeadSlice - case opStructFieldHead: - return opStructFieldHeadStruct + case opSlicePtr: + code.op = opSlice + return opStructFieldHeadSlicePtr case opMarshalJSON: return opStructFieldHeadMarshalJSON + case opMarshalJSONPtr: + return opStructFieldHeadMarshalJSONPtr case opMarshalText: return opStructFieldHeadMarshalText + case opMarshalTextPtr: + return opStructFieldHeadMarshalTextPtr } return opStructFieldHead } -func encodeTypeToFieldType(ctx *encodeCompileContext, code *opcode) opType { +func encodeTypeToFieldType(code *opcode) opType { switch code.op { - case opPtr: - ptrNum := 1 - ctx.decIndex() - c := code - for { - if code.next.op == opPtr { - ptrNum++ - code = code.next - ctx.decIndex() - continue - } - break - } - c.ptrNum = ptrNum - if ptrNum > 1 { - switch code.next.op { - case opInt: - c.mask = code.next.mask - c.rshiftNum = code.next.rshiftNum - return opStructFieldIntNPtr - case opUint: - c.mask = code.next.mask - return opStructFieldUintNPtr - case opFloat32: - return opStructFieldFloat32NPtr - case opFloat64: - return opStructFieldFloat64NPtr - case opString: - return opStructFieldStringNPtr - case opBool: - return opStructFieldBoolNPtr - } - } else { - switch code.next.op { - case opInt: - c.mask = code.next.mask - c.rshiftNum = code.next.rshiftNum - return opStructFieldIntPtr - case opUint: - c.mask = code.next.mask - return opStructFieldUintPtr - case opFloat32: - return opStructFieldFloat32Ptr - case opFloat64: - return opStructFieldFloat64Ptr - case opString: - return opStructFieldStringPtr - case opBool: - return opStructFieldBoolPtr - } - } case opInt: return opStructFieldInt + case opIntPtr: + return opStructFieldIntPtr case opUint: return opStructFieldUint + case opUintPtr: + return opStructFieldUintPtr case opFloat32: return opStructFieldFloat32 + case opFloat32Ptr: + return opStructFieldFloat32Ptr case opFloat64: return opStructFieldFloat64 + case opFloat64Ptr: + return opStructFieldFloat64Ptr case opString: return opStructFieldString + case opStringPtr: + return opStructFieldStringPtr + case opNumber: + return opStructFieldNumber + case opNumberPtr: + return opStructFieldNumberPtr case opBool: return opStructFieldBool - case opMapHead: + case opBoolPtr: + return opStructFieldBoolPtr + case opMap: return opStructFieldMap - case opMapHeadLoad: - return opStructFieldMapLoad - case opArrayHead: + case opMapPtr: + code.op = opMap + return opStructFieldMapPtr + case opArray: return opStructFieldArray - case opSliceHead: + case opArrayPtr: + code.op = opArray + return opStructFieldArrayPtr + case opSlice: return opStructFieldSlice - case opStructFieldHead: - return opStructFieldStruct + case opSlicePtr: + code.op = opSlice + return opStructFieldSlicePtr case opMarshalJSON: return opStructFieldMarshalJSON + case opMarshalJSONPtr: + return opStructFieldMarshalJSONPtr case opMarshalText: return opStructFieldMarshalText + case opMarshalTextPtr: + return opStructFieldMarshalTextPtr } return opStructField } -func encodeOptimizeStructHeader(ctx *encodeCompileContext, code *opcode, tag *structTag) opType { - headType := encodeTypeToHeaderType(ctx, code) +func encodeOptimizeStructHeader(code *opcode, tag *structTag) opType { + headType := encodeTypeToHeaderType(code) switch { case tag.isOmitEmpty: headType = headType.headToOmitEmptyHead() @@ -922,8 +884,8 @@ func encodeOptimizeStructHeader(ctx *encodeCompileContext, code *opcode, tag *st return headType } -func encodeOptimizeStructField(ctx *encodeCompileContext, code *opcode, tag *structTag) opType { - fieldType := encodeTypeToFieldType(ctx, code) +func encodeOptimizeStructField(code *opcode, tag *structTag) opType { + fieldType := encodeTypeToFieldType(code) switch { case tag.isOmitEmpty: fieldType = fieldType.fieldToOmitEmptyField() @@ -950,7 +912,7 @@ func encodeCompiledCode(ctx *encodeCompileContext) *opcode { func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode *opcode, tag *structTag) *opcode { fieldCode.indent-- - op := encodeOptimizeStructHeader(ctx, valueCode, tag) + op := encodeOptimizeStructHeader(valueCode, tag) fieldCode.op = op fieldCode.mask = valueCode.mask fieldCode.rshiftNum = valueCode.rshiftNum @@ -960,16 +922,35 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode opStructFieldHeadSlice, opStructFieldHeadArray, opStructFieldHeadMap, - opStructFieldHeadMapLoad, opStructFieldHeadStruct, opStructFieldHeadOmitEmpty, opStructFieldHeadOmitEmptySlice, + opStructFieldHeadStringTagSlice, opStructFieldHeadOmitEmptyArray, + opStructFieldHeadStringTagArray, opStructFieldHeadOmitEmptyMap, - opStructFieldHeadOmitEmptyMapLoad, + opStructFieldHeadStringTagMap, opStructFieldHeadOmitEmptyStruct, opStructFieldHeadStringTag: return valueCode.beforeLastCode() + case opStructFieldHeadSlicePtr, + opStructFieldHeadOmitEmptySlicePtr, + opStructFieldHeadStringTagSlicePtr, + opStructFieldHeadArrayPtr, + opStructFieldHeadOmitEmptyArrayPtr, + opStructFieldHeadStringTagArrayPtr, + opStructFieldHeadMapPtr, + opStructFieldHeadOmitEmptyMapPtr, + opStructFieldHeadStringTagMapPtr: + return valueCode.beforeLastCode() + case opStructFieldHeadMarshalJSONPtr, + opStructFieldHeadOmitEmptyMarshalJSONPtr, + opStructFieldHeadStringTagMarshalJSONPtr, + opStructFieldHeadMarshalTextPtr, + opStructFieldHeadOmitEmptyMarshalTextPtr, + opStructFieldHeadStringTagMarshalTextPtr: + ctx.decOpcodeIndex() + return (*opcode)(unsafe.Pointer(fieldCode)) } ctx.decOpcodeIndex() return (*opcode)(unsafe.Pointer(fieldCode)) @@ -977,26 +958,38 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode func encodeStructField(ctx *encodeCompileContext, fieldCode *opcode, valueCode *opcode, tag *structTag) *opcode { code := (*opcode)(unsafe.Pointer(fieldCode)) - op := encodeOptimizeStructField(ctx, valueCode, tag) + op := encodeOptimizeStructField(valueCode, tag) fieldCode.op = op fieldCode.ptrNum = valueCode.ptrNum fieldCode.mask = valueCode.mask fieldCode.rshiftNum = valueCode.rshiftNum + fieldCode.jmp = valueCode.jmp switch op { case opStructField, opStructFieldSlice, opStructFieldArray, opStructFieldMap, - opStructFieldMapLoad, opStructFieldStruct, opStructFieldOmitEmpty, opStructFieldOmitEmptySlice, + opStructFieldStringTagSlice, opStructFieldOmitEmptyArray, + opStructFieldStringTagArray, opStructFieldOmitEmptyMap, - opStructFieldOmitEmptyMapLoad, + opStructFieldStringTagMap, opStructFieldOmitEmptyStruct, opStructFieldStringTag: return valueCode.beforeLastCode() + case opStructFieldSlicePtr, + opStructFieldOmitEmptySlicePtr, + opStructFieldStringTagSlicePtr, + opStructFieldArrayPtr, + opStructFieldOmitEmptyArrayPtr, + opStructFieldStringTagArrayPtr, + opStructFieldMapPtr, + opStructFieldOmitEmptyMapPtr, + opStructFieldStringTagMapPtr: + return valueCode.beforeLastCode() } ctx.decIndex() return code @@ -1006,7 +999,10 @@ func encodeIsNotExistsField(head *opcode) bool { if head == nil { return false } - if head.op != opStructFieldAnonymousHead { + if head.op != opStructFieldHead { + return false + } + if !head.anonymousHead { return false } if head.next == nil { @@ -1068,14 +1064,17 @@ func encodeAnonymousStructFieldPairMap(tags structTags, named string, valueCode removedFields := map[*opcode]struct{}{} for { existsKey := tags.existsKey(f.displayKey) - op := f.op.headToAnonymousHead() - if existsKey && (f.next.op == opStructFieldPtrAnonymousHeadRecursive || f.next.op == opStructFieldAnonymousHeadRecursive) { + isHeadOp := strings.Contains(f.op.String(), "Head") + if existsKey && strings.Contains(f.op.String(), "Recursive") { // through - } else if op != f.op { + } else if isHeadOp && !f.anonymousHead { if existsKey { - f.op = opStructFieldAnonymousHead + // TODO: need to remove this head + f.op = opStructFieldHead + f.anonymousKey = true + f.anonymousHead = true } else if named == "" { - f.op = op + f.anonymousHead = true } } else if named == "" && f.op == opStructEnd { f.op = opStructAnonymousEnd @@ -1121,7 +1120,7 @@ func encodeAnonymousFieldPairRecursively(named string, valueCode *opcode) map[st f := valueCode var prevAnonymousField *opcode for { - if f.displayKey != "" && strings.Contains(f.op.String(), "Anonymous") { + if f.displayKey != "" && f.anonymousHead { key := fmt.Sprintf("%s.%s", named, f.displayKey) anonymousFields[key] = append(anonymousFields[key], structFieldPair{ prevField: prevAnonymousField, @@ -1158,7 +1157,9 @@ func encodeOptimizeConflictAnonymousFields(anonymousFields map[string][]structFi if !fieldPair.linked { if fieldPair.prevField == nil { // head operation - fieldPair.curField.op = opStructFieldAnonymousHead + fieldPair.curField.op = opStructFieldHead + fieldPair.curField.anonymousHead = true + fieldPair.curField.anonymousKey = true } else { diff := fieldPair.curField.nextField.displayIdx - fieldPair.curField.displayIdx for i := 0; i < diff; i++ { @@ -1176,7 +1177,9 @@ func encodeOptimizeConflictAnonymousFields(anonymousFields map[string][]structFi if !fieldPair.linked { if fieldPair.prevField == nil { // head operation - fieldPair.curField.op = opStructFieldAnonymousHead + fieldPair.curField.op = opStructFieldHead + fieldPair.curField.anonymousHead = true + fieldPair.curField.anonymousKey = true } else { diff := fieldPair.curField.nextField.displayIdx - fieldPair.curField.displayIdx removedFields[fieldPair.curField] = struct{}{} @@ -1209,7 +1212,10 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) // ^ | // |__________| fieldNum := typ.NumField() + indirect := ifaceIndir(typ) + //fmt.Println("indirect = ", indirect, "type = ", typ, "isPtr = ", isPtr) fieldIdx := 0 + disableIndirectConversion := false var ( head *opcode code *opcode @@ -1228,30 +1234,66 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) for i, tag := range tags { field := tag.field fieldType := type2rtype(field.Type) - if isPtr && i == 0 { - // head field of pointer structure at top level - // if field type is pointer and implements MarshalJSON or MarshalText, - // it need to operation of dereference of pointer. - if field.Type.Kind() == reflect.Ptr && - (field.Type.Implements(marshalJSONType) || field.Type.Implements(marshalTextType)) { - fieldType = rtype_ptrTo(fieldType) - } - } fieldOpcodeIndex := ctx.opcodeIndex fieldPtrIndex := ctx.ptrIndex ctx.incIndex() - valueCode, err := encodeCompile(ctx.withType(fieldType)) - if err != nil { - return nil, err + nilcheck := true + var valueCode *opcode + isNilValue := fieldType.Kind() == reflect.Ptr || fieldType.Kind() == reflect.Interface || fieldType.Kind() == reflect.Slice || fieldType.Kind() == reflect.Map + addrForMarshaler := false + if i == 0 && fieldNum == 1 && isPtr && !isNilValue && rtype_ptrTo(fieldType).Implements(marshalJSONType) && !fieldType.Implements(marshalJSONType) { + // *struct{ field T } => struct { field *T } + // func (*T) MarshalJSON() ([]byte, error) + // move pointer position from head to first field + code, err := encodeCompileMarshalJSON(ctx.withType(rtype_ptrTo(fieldType))) + if err != nil { + return nil, err + } + valueCode = code + nilcheck = false + indirect = false + disableIndirectConversion = true + } else if i == 0 && fieldNum == 1 && isPtr && !isNilValue && rtype_ptrTo(fieldType).Implements(marshalTextType) && !fieldType.Implements(marshalTextType) { + // *struct{ field T } => struct { field *T } + // func (*T) MarshalText() ([]byte, error) + // move pointer position from head to first field + code, err := encodeCompileMarshalText(ctx.withType(rtype_ptrTo(fieldType))) + if err != nil { + return nil, err + } + valueCode = code + nilcheck = false + indirect = false + disableIndirectConversion = true + } else if isPtr && !fieldType.Implements(marshalJSONType) && rtype_ptrTo(fieldType).Implements(marshalJSONType) { + // *struct{ field T } + // func (*T) MarshalJSON() ([]byte, error) + code, err := encodeCompileMarshalJSON(ctx.withType(fieldType)) + if err != nil { + return nil, err + } + addrForMarshaler = true + nilcheck = false + valueCode = code + } else if isPtr && !fieldType.Implements(marshalTextType) && rtype_ptrTo(fieldType).Implements(marshalTextType) { + // *struct{ field T } + // func (*T) MarshalText() ([]byte, error) + code, err := encodeCompileMarshalText(ctx.withType(fieldType)) + if err != nil { + return nil, err + } + addrForMarshaler = true + nilcheck = false + valueCode = code + } else { + code, err := encodeCompile(ctx.withType(fieldType), isPtr) + if err != nil { + return nil, err + } + valueCode = code } if field.Anonymous { - if valueCode.op == opPtr && valueCode.next.op == opStructFieldRecursive { - valueCode = valueCode.next - valueCode.decOpcodeIndex() - ctx.decIndex() - valueCode.op = opStructFieldPtrHeadRecursive - } tagKey := "" if tag.isTaggedKey { tagKey = tag.key @@ -1259,21 +1301,32 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) for k, v := range encodeAnonymousStructFieldPairMap(tags, tagKey, valueCode) { anonymousFields[k] = append(anonymousFields[k], v...) } + valueCode.decIndent() + + // fix issue144 + if !(isPtr && strings.Contains(valueCode.op.String(), "Marshal")) { + valueCode.indirect = indirect + } + } else { + valueCode.indirect = indirect } key := fmt.Sprintf(`"%s":`, tag.key) escapedKey := fmt.Sprintf(`%s:`, string(encodeEscapedString([]byte{}, tag.key))) fieldCode := &opcode{ - typ: valueCode.typ, - displayIdx: fieldOpcodeIndex, - idx: opcodeOffset(fieldPtrIndex), - next: valueCode, - indent: ctx.indent, - anonymousKey: field.Anonymous, - key: []byte(key), - escapedKey: []byte(escapedKey), - isTaggedKey: tag.isTaggedKey, - displayKey: tag.key, - offset: field.Offset, + typ: valueCode.typ, + displayIdx: fieldOpcodeIndex, + idx: opcodeOffset(fieldPtrIndex), + next: valueCode, + indent: ctx.indent, + anonymousKey: field.Anonymous, + key: []byte(key), + escapedKey: []byte(escapedKey), + isTaggedKey: tag.isTaggedKey, + displayKey: tag.key, + offset: field.Offset, + indirect: indirect, + nilcheck: nilcheck, + addrForMarshaler: addrForMarshaler, } if fieldIdx == 0 { fieldCode.headIdx = fieldCode.idx @@ -1333,5 +1386,9 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error) delete(ctx.structTypeToCompiledCode, typeptr) + if !disableIndirectConversion && !head.indirect && isPtr { + head.indirect = true + } + return ret, nil } diff --git a/encode_opcode.go b/encode_opcode.go index 109dd0c..d01e2e7 100644 --- a/encode_opcode.go +++ b/encode_opcode.go @@ -9,19 +9,23 @@ import ( const uintptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const type opcode struct { - op opType // operation type - typ *rtype // go type - displayIdx int // opcode index - key []byte // struct field key - escapedKey []byte // struct field key ( HTML escaped ) - ptrNum int // pointer number: e.g. double pointer is 2. - displayKey string // key text to display - isTaggedKey bool // whether tagged key - anonymousKey bool // whether anonymous key - root bool // whether root - rshiftNum uint8 // use to take bit for judging whether negative integer or not - mask uint64 // mask for number - indent int // indent number + op opType // operation type + typ *rtype // go type + displayIdx int // opcode index + key []byte // struct field key + escapedKey []byte // struct field key ( HTML escaped ) + ptrNum int // pointer number: e.g. double pointer is 2. + displayKey string // key text to display + isTaggedKey bool // whether tagged key + anonymousKey bool // whether anonymous key + anonymousHead bool // whether anonymous head or not + root bool // whether root + indirect bool // whether indirect or not + nilcheck bool // whether needs to nilcheck or not + addrForMarshaler bool // whether needs to addr for marshaler or not + rshiftNum uint8 // use to take bit for judging whether negative integer or not + mask uint64 // mask for number + indent int // indent number idx uintptr // offset to access ptr headIdx uintptr // offset to access slice/struct head @@ -79,27 +83,31 @@ func (c *opcode) copy(codeMap map[uintptr]*opcode) *opcode { return code } copied := &opcode{ - op: c.op, - typ: c.typ, - displayIdx: c.displayIdx, - key: c.key, - escapedKey: c.escapedKey, - displayKey: c.displayKey, - ptrNum: c.ptrNum, - mask: c.mask, - rshiftNum: c.rshiftNum, - isTaggedKey: c.isTaggedKey, - anonymousKey: c.anonymousKey, - root: c.root, - indent: c.indent, - idx: c.idx, - headIdx: c.headIdx, - elemIdx: c.elemIdx, - length: c.length, - mapIter: c.mapIter, - mapPos: c.mapPos, - offset: c.offset, - size: c.size, + op: c.op, + typ: c.typ, + displayIdx: c.displayIdx, + key: c.key, + escapedKey: c.escapedKey, + displayKey: c.displayKey, + ptrNum: c.ptrNum, + mask: c.mask, + rshiftNum: c.rshiftNum, + isTaggedKey: c.isTaggedKey, + anonymousKey: c.anonymousKey, + anonymousHead: c.anonymousHead, + root: c.root, + indirect: c.indirect, + nilcheck: c.nilcheck, + addrForMarshaler: c.addrForMarshaler, + indent: c.indent, + idx: c.idx, + headIdx: c.headIdx, + elemIdx: c.elemIdx, + length: c.length, + mapIter: c.mapIter, + mapPos: c.mapPos, + offset: c.offset, + size: c.size, } codeMap[addr] = copied copied.mapKey = c.mapKey.copy(codeMap) @@ -172,6 +180,18 @@ func (c *opcode) decOpcodeIndex() { } } +func (c *opcode) decIndent() { + for code := c; code.op != opEnd; { + code.indent-- + switch code.op.codeType() { + case codeArrayElem, codeSliceElem, codeMapKey: + code = code.end + default: + code = code.next + } + } +} + func (c *opcode) dumpHead(code *opcode) string { var length uintptr if code.op.codeType() == codeArrayHead { @@ -360,7 +380,7 @@ func newSliceHeaderCode(ctx *encodeCompileContext) *opcode { ctx.incPtrIndex() length := opcodeOffset(ctx.ptrIndex) return &opcode{ - op: opSliceHead, + op: opSlice, displayIdx: ctx.opcodeIndex, idx: idx, headIdx: idx, @@ -388,7 +408,7 @@ func newArrayHeaderCode(ctx *encodeCompileContext, alen int) *opcode { ctx.incPtrIndex() elemIdx := opcodeOffset(ctx.ptrIndex) return &opcode{ - op: opArrayHead, + op: opArray, displayIdx: ctx.opcodeIndex, idx: idx, headIdx: idx, @@ -406,17 +426,12 @@ func newArrayElemCode(ctx *encodeCompileContext, head *opcode, length int, size elemIdx: head.elemIdx, headIdx: head.headIdx, length: uintptr(length), + indent: ctx.indent, size: size, } } -func newMapHeaderCode(ctx *encodeCompileContext, withLoad bool) *opcode { - var op opType - if withLoad { - op = opMapHeadLoad - } else { - op = opMapHead - } +func newMapHeaderCode(ctx *encodeCompileContext) *opcode { idx := opcodeOffset(ctx.ptrIndex) ctx.incPtrIndex() elemIdx := opcodeOffset(ctx.ptrIndex) @@ -425,7 +440,7 @@ func newMapHeaderCode(ctx *encodeCompileContext, withLoad bool) *opcode { ctx.incPtrIndex() mapIter := opcodeOffset(ctx.ptrIndex) return &opcode{ - op: op, + op: opMap, typ: ctx.typ, displayIdx: ctx.opcodeIndex, idx: idx, diff --git a/encode_optype.go b/encode_optype.go index 229c3f3..0a384f3 100644 --- a/encode_optype.go +++ b/encode_optype.go @@ -22,21 +22,16 @@ const ( codeStructEnd codeType = 11 ) -var opTypeStrings = [1394]string{ +var opTypeStrings = [442]string{ "End", "Interface", "Ptr", - "NPtr", - "SliceHead", "RootSliceHead", "SliceElem", "RootSliceElem", "SliceEnd", - "ArrayHead", "ArrayElem", "ArrayEnd", - "MapHead", - "MapHeadLoad", "MapKey", "MapValue", "MapEnd", @@ -49,9 +44,9 @@ var opTypeStrings = [1394]string{ "Bool", "String", "Bytes", + "Number", "Array", "Map", - "MapLoad", "Slice", "Struct", "MarshalJSON", @@ -66,1165 +61,212 @@ var opTypeStrings = [1394]string{ "BoolPtr", "StringPtr", "BytesPtr", - "IntNPtr", - "UintNPtr", - "Float32NPtr", - "Float64NPtr", - "BoolNPtr", - "StringNPtr", - "BytesNPtr", + "NumberPtr", + "ArrayPtr", + "MapPtr", + "SlicePtr", + "MarshalJSONPtr", + "MarshalTextPtr", + "InterfacePtr", + "RecursivePtr", "StructFieldHeadInt", - "StructFieldHeadIntOnly", "StructFieldHeadOmitEmptyInt", - "StructFieldHeadOmitEmptyIntOnly", "StructFieldHeadStringTagInt", - "StructFieldHeadStringTagIntOnly", - "StructFieldAnonymousHeadInt", - "StructFieldAnonymousHeadIntOnly", - "StructFieldAnonymousHeadOmitEmptyInt", - "StructFieldAnonymousHeadOmitEmptyIntOnly", - "StructFieldAnonymousHeadStringTagInt", - "StructFieldAnonymousHeadStringTagIntOnly", "StructFieldPtrHeadInt", - "StructFieldPtrHeadIntOnly", "StructFieldPtrHeadOmitEmptyInt", - "StructFieldPtrHeadOmitEmptyIntOnly", "StructFieldPtrHeadStringTagInt", - "StructFieldPtrHeadStringTagIntOnly", - "StructFieldPtrAnonymousHeadInt", - "StructFieldPtrAnonymousHeadIntOnly", - "StructFieldPtrAnonymousHeadOmitEmptyInt", - "StructFieldPtrAnonymousHeadOmitEmptyIntOnly", - "StructFieldPtrAnonymousHeadStringTagInt", - "StructFieldPtrAnonymousHeadStringTagIntOnly", - "StructFieldNPtrHeadInt", - "StructFieldNPtrHeadIntOnly", - "StructFieldNPtrHeadOmitEmptyInt", - "StructFieldNPtrHeadOmitEmptyIntOnly", - "StructFieldNPtrHeadStringTagInt", - "StructFieldNPtrHeadStringTagIntOnly", - "StructFieldNPtrAnonymousHeadInt", - "StructFieldNPtrAnonymousHeadIntOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyInt", - "StructFieldNPtrAnonymousHeadOmitEmptyIntOnly", - "StructFieldNPtrAnonymousHeadStringTagInt", - "StructFieldNPtrAnonymousHeadStringTagIntOnly", "StructFieldHeadUint", - "StructFieldHeadUintOnly", "StructFieldHeadOmitEmptyUint", - "StructFieldHeadOmitEmptyUintOnly", "StructFieldHeadStringTagUint", - "StructFieldHeadStringTagUintOnly", - "StructFieldAnonymousHeadUint", - "StructFieldAnonymousHeadUintOnly", - "StructFieldAnonymousHeadOmitEmptyUint", - "StructFieldAnonymousHeadOmitEmptyUintOnly", - "StructFieldAnonymousHeadStringTagUint", - "StructFieldAnonymousHeadStringTagUintOnly", "StructFieldPtrHeadUint", - "StructFieldPtrHeadUintOnly", "StructFieldPtrHeadOmitEmptyUint", - "StructFieldPtrHeadOmitEmptyUintOnly", "StructFieldPtrHeadStringTagUint", - "StructFieldPtrHeadStringTagUintOnly", - "StructFieldPtrAnonymousHeadUint", - "StructFieldPtrAnonymousHeadUintOnly", - "StructFieldPtrAnonymousHeadOmitEmptyUint", - "StructFieldPtrAnonymousHeadOmitEmptyUintOnly", - "StructFieldPtrAnonymousHeadStringTagUint", - "StructFieldPtrAnonymousHeadStringTagUintOnly", - "StructFieldNPtrHeadUint", - "StructFieldNPtrHeadUintOnly", - "StructFieldNPtrHeadOmitEmptyUint", - "StructFieldNPtrHeadOmitEmptyUintOnly", - "StructFieldNPtrHeadStringTagUint", - "StructFieldNPtrHeadStringTagUintOnly", - "StructFieldNPtrAnonymousHeadUint", - "StructFieldNPtrAnonymousHeadUintOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyUint", - "StructFieldNPtrAnonymousHeadOmitEmptyUintOnly", - "StructFieldNPtrAnonymousHeadStringTagUint", - "StructFieldNPtrAnonymousHeadStringTagUintOnly", "StructFieldHeadFloat32", - "StructFieldHeadFloat32Only", "StructFieldHeadOmitEmptyFloat32", - "StructFieldHeadOmitEmptyFloat32Only", "StructFieldHeadStringTagFloat32", - "StructFieldHeadStringTagFloat32Only", - "StructFieldAnonymousHeadFloat32", - "StructFieldAnonymousHeadFloat32Only", - "StructFieldAnonymousHeadOmitEmptyFloat32", - "StructFieldAnonymousHeadOmitEmptyFloat32Only", - "StructFieldAnonymousHeadStringTagFloat32", - "StructFieldAnonymousHeadStringTagFloat32Only", "StructFieldPtrHeadFloat32", - "StructFieldPtrHeadFloat32Only", "StructFieldPtrHeadOmitEmptyFloat32", - "StructFieldPtrHeadOmitEmptyFloat32Only", "StructFieldPtrHeadStringTagFloat32", - "StructFieldPtrHeadStringTagFloat32Only", - "StructFieldPtrAnonymousHeadFloat32", - "StructFieldPtrAnonymousHeadFloat32Only", - "StructFieldPtrAnonymousHeadOmitEmptyFloat32", - "StructFieldPtrAnonymousHeadOmitEmptyFloat32Only", - "StructFieldPtrAnonymousHeadStringTagFloat32", - "StructFieldPtrAnonymousHeadStringTagFloat32Only", - "StructFieldNPtrHeadFloat32", - "StructFieldNPtrHeadFloat32Only", - "StructFieldNPtrHeadOmitEmptyFloat32", - "StructFieldNPtrHeadOmitEmptyFloat32Only", - "StructFieldNPtrHeadStringTagFloat32", - "StructFieldNPtrHeadStringTagFloat32Only", - "StructFieldNPtrAnonymousHeadFloat32", - "StructFieldNPtrAnonymousHeadFloat32Only", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat32", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat32Only", - "StructFieldNPtrAnonymousHeadStringTagFloat32", - "StructFieldNPtrAnonymousHeadStringTagFloat32Only", "StructFieldHeadFloat64", - "StructFieldHeadFloat64Only", "StructFieldHeadOmitEmptyFloat64", - "StructFieldHeadOmitEmptyFloat64Only", "StructFieldHeadStringTagFloat64", - "StructFieldHeadStringTagFloat64Only", - "StructFieldAnonymousHeadFloat64", - "StructFieldAnonymousHeadFloat64Only", - "StructFieldAnonymousHeadOmitEmptyFloat64", - "StructFieldAnonymousHeadOmitEmptyFloat64Only", - "StructFieldAnonymousHeadStringTagFloat64", - "StructFieldAnonymousHeadStringTagFloat64Only", "StructFieldPtrHeadFloat64", - "StructFieldPtrHeadFloat64Only", "StructFieldPtrHeadOmitEmptyFloat64", - "StructFieldPtrHeadOmitEmptyFloat64Only", "StructFieldPtrHeadStringTagFloat64", - "StructFieldPtrHeadStringTagFloat64Only", - "StructFieldPtrAnonymousHeadFloat64", - "StructFieldPtrAnonymousHeadFloat64Only", - "StructFieldPtrAnonymousHeadOmitEmptyFloat64", - "StructFieldPtrAnonymousHeadOmitEmptyFloat64Only", - "StructFieldPtrAnonymousHeadStringTagFloat64", - "StructFieldPtrAnonymousHeadStringTagFloat64Only", - "StructFieldNPtrHeadFloat64", - "StructFieldNPtrHeadFloat64Only", - "StructFieldNPtrHeadOmitEmptyFloat64", - "StructFieldNPtrHeadOmitEmptyFloat64Only", - "StructFieldNPtrHeadStringTagFloat64", - "StructFieldNPtrHeadStringTagFloat64Only", - "StructFieldNPtrAnonymousHeadFloat64", - "StructFieldNPtrAnonymousHeadFloat64Only", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat64", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat64Only", - "StructFieldNPtrAnonymousHeadStringTagFloat64", - "StructFieldNPtrAnonymousHeadStringTagFloat64Only", "StructFieldHeadBool", - "StructFieldHeadBoolOnly", "StructFieldHeadOmitEmptyBool", - "StructFieldHeadOmitEmptyBoolOnly", "StructFieldHeadStringTagBool", - "StructFieldHeadStringTagBoolOnly", - "StructFieldAnonymousHeadBool", - "StructFieldAnonymousHeadBoolOnly", - "StructFieldAnonymousHeadOmitEmptyBool", - "StructFieldAnonymousHeadOmitEmptyBoolOnly", - "StructFieldAnonymousHeadStringTagBool", - "StructFieldAnonymousHeadStringTagBoolOnly", "StructFieldPtrHeadBool", - "StructFieldPtrHeadBoolOnly", "StructFieldPtrHeadOmitEmptyBool", - "StructFieldPtrHeadOmitEmptyBoolOnly", "StructFieldPtrHeadStringTagBool", - "StructFieldPtrHeadStringTagBoolOnly", - "StructFieldPtrAnonymousHeadBool", - "StructFieldPtrAnonymousHeadBoolOnly", - "StructFieldPtrAnonymousHeadOmitEmptyBool", - "StructFieldPtrAnonymousHeadOmitEmptyBoolOnly", - "StructFieldPtrAnonymousHeadStringTagBool", - "StructFieldPtrAnonymousHeadStringTagBoolOnly", - "StructFieldNPtrHeadBool", - "StructFieldNPtrHeadBoolOnly", - "StructFieldNPtrHeadOmitEmptyBool", - "StructFieldNPtrHeadOmitEmptyBoolOnly", - "StructFieldNPtrHeadStringTagBool", - "StructFieldNPtrHeadStringTagBoolOnly", - "StructFieldNPtrAnonymousHeadBool", - "StructFieldNPtrAnonymousHeadBoolOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyBool", - "StructFieldNPtrAnonymousHeadOmitEmptyBoolOnly", - "StructFieldNPtrAnonymousHeadStringTagBool", - "StructFieldNPtrAnonymousHeadStringTagBoolOnly", "StructFieldHeadString", - "StructFieldHeadStringOnly", "StructFieldHeadOmitEmptyString", - "StructFieldHeadOmitEmptyStringOnly", "StructFieldHeadStringTagString", - "StructFieldHeadStringTagStringOnly", - "StructFieldAnonymousHeadString", - "StructFieldAnonymousHeadStringOnly", - "StructFieldAnonymousHeadOmitEmptyString", - "StructFieldAnonymousHeadOmitEmptyStringOnly", - "StructFieldAnonymousHeadStringTagString", - "StructFieldAnonymousHeadStringTagStringOnly", "StructFieldPtrHeadString", - "StructFieldPtrHeadStringOnly", "StructFieldPtrHeadOmitEmptyString", - "StructFieldPtrHeadOmitEmptyStringOnly", "StructFieldPtrHeadStringTagString", - "StructFieldPtrHeadStringTagStringOnly", - "StructFieldPtrAnonymousHeadString", - "StructFieldPtrAnonymousHeadStringOnly", - "StructFieldPtrAnonymousHeadOmitEmptyString", - "StructFieldPtrAnonymousHeadOmitEmptyStringOnly", - "StructFieldPtrAnonymousHeadStringTagString", - "StructFieldPtrAnonymousHeadStringTagStringOnly", - "StructFieldNPtrHeadString", - "StructFieldNPtrHeadStringOnly", - "StructFieldNPtrHeadOmitEmptyString", - "StructFieldNPtrHeadOmitEmptyStringOnly", - "StructFieldNPtrHeadStringTagString", - "StructFieldNPtrHeadStringTagStringOnly", - "StructFieldNPtrAnonymousHeadString", - "StructFieldNPtrAnonymousHeadStringOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyString", - "StructFieldNPtrAnonymousHeadOmitEmptyStringOnly", - "StructFieldNPtrAnonymousHeadStringTagString", - "StructFieldNPtrAnonymousHeadStringTagStringOnly", "StructFieldHeadBytes", - "StructFieldHeadBytesOnly", "StructFieldHeadOmitEmptyBytes", - "StructFieldHeadOmitEmptyBytesOnly", "StructFieldHeadStringTagBytes", - "StructFieldHeadStringTagBytesOnly", - "StructFieldAnonymousHeadBytes", - "StructFieldAnonymousHeadBytesOnly", - "StructFieldAnonymousHeadOmitEmptyBytes", - "StructFieldAnonymousHeadOmitEmptyBytesOnly", - "StructFieldAnonymousHeadStringTagBytes", - "StructFieldAnonymousHeadStringTagBytesOnly", "StructFieldPtrHeadBytes", - "StructFieldPtrHeadBytesOnly", "StructFieldPtrHeadOmitEmptyBytes", - "StructFieldPtrHeadOmitEmptyBytesOnly", "StructFieldPtrHeadStringTagBytes", - "StructFieldPtrHeadStringTagBytesOnly", - "StructFieldPtrAnonymousHeadBytes", - "StructFieldPtrAnonymousHeadBytesOnly", - "StructFieldPtrAnonymousHeadOmitEmptyBytes", - "StructFieldPtrAnonymousHeadOmitEmptyBytesOnly", - "StructFieldPtrAnonymousHeadStringTagBytes", - "StructFieldPtrAnonymousHeadStringTagBytesOnly", - "StructFieldNPtrHeadBytes", - "StructFieldNPtrHeadBytesOnly", - "StructFieldNPtrHeadOmitEmptyBytes", - "StructFieldNPtrHeadOmitEmptyBytesOnly", - "StructFieldNPtrHeadStringTagBytes", - "StructFieldNPtrHeadStringTagBytesOnly", - "StructFieldNPtrAnonymousHeadBytes", - "StructFieldNPtrAnonymousHeadBytesOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyBytes", - "StructFieldNPtrAnonymousHeadOmitEmptyBytesOnly", - "StructFieldNPtrAnonymousHeadStringTagBytes", - "StructFieldNPtrAnonymousHeadStringTagBytesOnly", + "StructFieldHeadNumber", + "StructFieldHeadOmitEmptyNumber", + "StructFieldHeadStringTagNumber", + "StructFieldPtrHeadNumber", + "StructFieldPtrHeadOmitEmptyNumber", + "StructFieldPtrHeadStringTagNumber", "StructFieldHeadArray", - "StructFieldHeadArrayOnly", "StructFieldHeadOmitEmptyArray", - "StructFieldHeadOmitEmptyArrayOnly", "StructFieldHeadStringTagArray", - "StructFieldHeadStringTagArrayOnly", - "StructFieldAnonymousHeadArray", - "StructFieldAnonymousHeadArrayOnly", - "StructFieldAnonymousHeadOmitEmptyArray", - "StructFieldAnonymousHeadOmitEmptyArrayOnly", - "StructFieldAnonymousHeadStringTagArray", - "StructFieldAnonymousHeadStringTagArrayOnly", "StructFieldPtrHeadArray", - "StructFieldPtrHeadArrayOnly", "StructFieldPtrHeadOmitEmptyArray", - "StructFieldPtrHeadOmitEmptyArrayOnly", "StructFieldPtrHeadStringTagArray", - "StructFieldPtrHeadStringTagArrayOnly", - "StructFieldPtrAnonymousHeadArray", - "StructFieldPtrAnonymousHeadArrayOnly", - "StructFieldPtrAnonymousHeadOmitEmptyArray", - "StructFieldPtrAnonymousHeadOmitEmptyArrayOnly", - "StructFieldPtrAnonymousHeadStringTagArray", - "StructFieldPtrAnonymousHeadStringTagArrayOnly", - "StructFieldNPtrHeadArray", - "StructFieldNPtrHeadArrayOnly", - "StructFieldNPtrHeadOmitEmptyArray", - "StructFieldNPtrHeadOmitEmptyArrayOnly", - "StructFieldNPtrHeadStringTagArray", - "StructFieldNPtrHeadStringTagArrayOnly", - "StructFieldNPtrAnonymousHeadArray", - "StructFieldNPtrAnonymousHeadArrayOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyArray", - "StructFieldNPtrAnonymousHeadOmitEmptyArrayOnly", - "StructFieldNPtrAnonymousHeadStringTagArray", - "StructFieldNPtrAnonymousHeadStringTagArrayOnly", "StructFieldHeadMap", - "StructFieldHeadMapOnly", "StructFieldHeadOmitEmptyMap", - "StructFieldHeadOmitEmptyMapOnly", "StructFieldHeadStringTagMap", - "StructFieldHeadStringTagMapOnly", - "StructFieldAnonymousHeadMap", - "StructFieldAnonymousHeadMapOnly", - "StructFieldAnonymousHeadOmitEmptyMap", - "StructFieldAnonymousHeadOmitEmptyMapOnly", - "StructFieldAnonymousHeadStringTagMap", - "StructFieldAnonymousHeadStringTagMapOnly", "StructFieldPtrHeadMap", - "StructFieldPtrHeadMapOnly", "StructFieldPtrHeadOmitEmptyMap", - "StructFieldPtrHeadOmitEmptyMapOnly", "StructFieldPtrHeadStringTagMap", - "StructFieldPtrHeadStringTagMapOnly", - "StructFieldPtrAnonymousHeadMap", - "StructFieldPtrAnonymousHeadMapOnly", - "StructFieldPtrAnonymousHeadOmitEmptyMap", - "StructFieldPtrAnonymousHeadOmitEmptyMapOnly", - "StructFieldPtrAnonymousHeadStringTagMap", - "StructFieldPtrAnonymousHeadStringTagMapOnly", - "StructFieldNPtrHeadMap", - "StructFieldNPtrHeadMapOnly", - "StructFieldNPtrHeadOmitEmptyMap", - "StructFieldNPtrHeadOmitEmptyMapOnly", - "StructFieldNPtrHeadStringTagMap", - "StructFieldNPtrHeadStringTagMapOnly", - "StructFieldNPtrAnonymousHeadMap", - "StructFieldNPtrAnonymousHeadMapOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyMap", - "StructFieldNPtrAnonymousHeadOmitEmptyMapOnly", - "StructFieldNPtrAnonymousHeadStringTagMap", - "StructFieldNPtrAnonymousHeadStringTagMapOnly", - "StructFieldHeadMapLoad", - "StructFieldHeadMapLoadOnly", - "StructFieldHeadOmitEmptyMapLoad", - "StructFieldHeadOmitEmptyMapLoadOnly", - "StructFieldHeadStringTagMapLoad", - "StructFieldHeadStringTagMapLoadOnly", - "StructFieldAnonymousHeadMapLoad", - "StructFieldAnonymousHeadMapLoadOnly", - "StructFieldAnonymousHeadOmitEmptyMapLoad", - "StructFieldAnonymousHeadOmitEmptyMapLoadOnly", - "StructFieldAnonymousHeadStringTagMapLoad", - "StructFieldAnonymousHeadStringTagMapLoadOnly", - "StructFieldPtrHeadMapLoad", - "StructFieldPtrHeadMapLoadOnly", - "StructFieldPtrHeadOmitEmptyMapLoad", - "StructFieldPtrHeadOmitEmptyMapLoadOnly", - "StructFieldPtrHeadStringTagMapLoad", - "StructFieldPtrHeadStringTagMapLoadOnly", - "StructFieldPtrAnonymousHeadMapLoad", - "StructFieldPtrAnonymousHeadMapLoadOnly", - "StructFieldPtrAnonymousHeadOmitEmptyMapLoad", - "StructFieldPtrAnonymousHeadOmitEmptyMapLoadOnly", - "StructFieldPtrAnonymousHeadStringTagMapLoad", - "StructFieldPtrAnonymousHeadStringTagMapLoadOnly", - "StructFieldNPtrHeadMapLoad", - "StructFieldNPtrHeadMapLoadOnly", - "StructFieldNPtrHeadOmitEmptyMapLoad", - "StructFieldNPtrHeadOmitEmptyMapLoadOnly", - "StructFieldNPtrHeadStringTagMapLoad", - "StructFieldNPtrHeadStringTagMapLoadOnly", - "StructFieldNPtrAnonymousHeadMapLoad", - "StructFieldNPtrAnonymousHeadMapLoadOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyMapLoad", - "StructFieldNPtrAnonymousHeadOmitEmptyMapLoadOnly", - "StructFieldNPtrAnonymousHeadStringTagMapLoad", - "StructFieldNPtrAnonymousHeadStringTagMapLoadOnly", "StructFieldHeadSlice", - "StructFieldHeadSliceOnly", "StructFieldHeadOmitEmptySlice", - "StructFieldHeadOmitEmptySliceOnly", "StructFieldHeadStringTagSlice", - "StructFieldHeadStringTagSliceOnly", - "StructFieldAnonymousHeadSlice", - "StructFieldAnonymousHeadSliceOnly", - "StructFieldAnonymousHeadOmitEmptySlice", - "StructFieldAnonymousHeadOmitEmptySliceOnly", - "StructFieldAnonymousHeadStringTagSlice", - "StructFieldAnonymousHeadStringTagSliceOnly", "StructFieldPtrHeadSlice", - "StructFieldPtrHeadSliceOnly", "StructFieldPtrHeadOmitEmptySlice", - "StructFieldPtrHeadOmitEmptySliceOnly", "StructFieldPtrHeadStringTagSlice", - "StructFieldPtrHeadStringTagSliceOnly", - "StructFieldPtrAnonymousHeadSlice", - "StructFieldPtrAnonymousHeadSliceOnly", - "StructFieldPtrAnonymousHeadOmitEmptySlice", - "StructFieldPtrAnonymousHeadOmitEmptySliceOnly", - "StructFieldPtrAnonymousHeadStringTagSlice", - "StructFieldPtrAnonymousHeadStringTagSliceOnly", - "StructFieldNPtrHeadSlice", - "StructFieldNPtrHeadSliceOnly", - "StructFieldNPtrHeadOmitEmptySlice", - "StructFieldNPtrHeadOmitEmptySliceOnly", - "StructFieldNPtrHeadStringTagSlice", - "StructFieldNPtrHeadStringTagSliceOnly", - "StructFieldNPtrAnonymousHeadSlice", - "StructFieldNPtrAnonymousHeadSliceOnly", - "StructFieldNPtrAnonymousHeadOmitEmptySlice", - "StructFieldNPtrAnonymousHeadOmitEmptySliceOnly", - "StructFieldNPtrAnonymousHeadStringTagSlice", - "StructFieldNPtrAnonymousHeadStringTagSliceOnly", "StructFieldHeadStruct", - "StructFieldHeadStructOnly", "StructFieldHeadOmitEmptyStruct", - "StructFieldHeadOmitEmptyStructOnly", "StructFieldHeadStringTagStruct", - "StructFieldHeadStringTagStructOnly", - "StructFieldAnonymousHeadStruct", - "StructFieldAnonymousHeadStructOnly", - "StructFieldAnonymousHeadOmitEmptyStruct", - "StructFieldAnonymousHeadOmitEmptyStructOnly", - "StructFieldAnonymousHeadStringTagStruct", - "StructFieldAnonymousHeadStringTagStructOnly", "StructFieldPtrHeadStruct", - "StructFieldPtrHeadStructOnly", "StructFieldPtrHeadOmitEmptyStruct", - "StructFieldPtrHeadOmitEmptyStructOnly", "StructFieldPtrHeadStringTagStruct", - "StructFieldPtrHeadStringTagStructOnly", - "StructFieldPtrAnonymousHeadStruct", - "StructFieldPtrAnonymousHeadStructOnly", - "StructFieldPtrAnonymousHeadOmitEmptyStruct", - "StructFieldPtrAnonymousHeadOmitEmptyStructOnly", - "StructFieldPtrAnonymousHeadStringTagStruct", - "StructFieldPtrAnonymousHeadStringTagStructOnly", - "StructFieldNPtrHeadStruct", - "StructFieldNPtrHeadStructOnly", - "StructFieldNPtrHeadOmitEmptyStruct", - "StructFieldNPtrHeadOmitEmptyStructOnly", - "StructFieldNPtrHeadStringTagStruct", - "StructFieldNPtrHeadStringTagStructOnly", - "StructFieldNPtrAnonymousHeadStruct", - "StructFieldNPtrAnonymousHeadStructOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyStruct", - "StructFieldNPtrAnonymousHeadOmitEmptyStructOnly", - "StructFieldNPtrAnonymousHeadStringTagStruct", - "StructFieldNPtrAnonymousHeadStringTagStructOnly", "StructFieldHeadMarshalJSON", - "StructFieldHeadMarshalJSONOnly", "StructFieldHeadOmitEmptyMarshalJSON", - "StructFieldHeadOmitEmptyMarshalJSONOnly", "StructFieldHeadStringTagMarshalJSON", - "StructFieldHeadStringTagMarshalJSONOnly", - "StructFieldAnonymousHeadMarshalJSON", - "StructFieldAnonymousHeadMarshalJSONOnly", - "StructFieldAnonymousHeadOmitEmptyMarshalJSON", - "StructFieldAnonymousHeadOmitEmptyMarshalJSONOnly", - "StructFieldAnonymousHeadStringTagMarshalJSON", - "StructFieldAnonymousHeadStringTagMarshalJSONOnly", "StructFieldPtrHeadMarshalJSON", - "StructFieldPtrHeadMarshalJSONOnly", "StructFieldPtrHeadOmitEmptyMarshalJSON", - "StructFieldPtrHeadOmitEmptyMarshalJSONOnly", "StructFieldPtrHeadStringTagMarshalJSON", - "StructFieldPtrHeadStringTagMarshalJSONOnly", - "StructFieldPtrAnonymousHeadMarshalJSON", - "StructFieldPtrAnonymousHeadMarshalJSONOnly", - "StructFieldPtrAnonymousHeadOmitEmptyMarshalJSON", - "StructFieldPtrAnonymousHeadOmitEmptyMarshalJSONOnly", - "StructFieldPtrAnonymousHeadStringTagMarshalJSON", - "StructFieldPtrAnonymousHeadStringTagMarshalJSONOnly", - "StructFieldNPtrHeadMarshalJSON", - "StructFieldNPtrHeadMarshalJSONOnly", - "StructFieldNPtrHeadOmitEmptyMarshalJSON", - "StructFieldNPtrHeadOmitEmptyMarshalJSONOnly", - "StructFieldNPtrHeadStringTagMarshalJSON", - "StructFieldNPtrHeadStringTagMarshalJSONOnly", - "StructFieldNPtrAnonymousHeadMarshalJSON", - "StructFieldNPtrAnonymousHeadMarshalJSONOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyMarshalJSON", - "StructFieldNPtrAnonymousHeadOmitEmptyMarshalJSONOnly", - "StructFieldNPtrAnonymousHeadStringTagMarshalJSON", - "StructFieldNPtrAnonymousHeadStringTagMarshalJSONOnly", "StructFieldHeadMarshalText", - "StructFieldHeadMarshalTextOnly", "StructFieldHeadOmitEmptyMarshalText", - "StructFieldHeadOmitEmptyMarshalTextOnly", "StructFieldHeadStringTagMarshalText", - "StructFieldHeadStringTagMarshalTextOnly", - "StructFieldAnonymousHeadMarshalText", - "StructFieldAnonymousHeadMarshalTextOnly", - "StructFieldAnonymousHeadOmitEmptyMarshalText", - "StructFieldAnonymousHeadOmitEmptyMarshalTextOnly", - "StructFieldAnonymousHeadStringTagMarshalText", - "StructFieldAnonymousHeadStringTagMarshalTextOnly", "StructFieldPtrHeadMarshalText", - "StructFieldPtrHeadMarshalTextOnly", "StructFieldPtrHeadOmitEmptyMarshalText", - "StructFieldPtrHeadOmitEmptyMarshalTextOnly", "StructFieldPtrHeadStringTagMarshalText", - "StructFieldPtrHeadStringTagMarshalTextOnly", - "StructFieldPtrAnonymousHeadMarshalText", - "StructFieldPtrAnonymousHeadMarshalTextOnly", - "StructFieldPtrAnonymousHeadOmitEmptyMarshalText", - "StructFieldPtrAnonymousHeadOmitEmptyMarshalTextOnly", - "StructFieldPtrAnonymousHeadStringTagMarshalText", - "StructFieldPtrAnonymousHeadStringTagMarshalTextOnly", - "StructFieldNPtrHeadMarshalText", - "StructFieldNPtrHeadMarshalTextOnly", - "StructFieldNPtrHeadOmitEmptyMarshalText", - "StructFieldNPtrHeadOmitEmptyMarshalTextOnly", - "StructFieldNPtrHeadStringTagMarshalText", - "StructFieldNPtrHeadStringTagMarshalTextOnly", - "StructFieldNPtrAnonymousHeadMarshalText", - "StructFieldNPtrAnonymousHeadMarshalTextOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyMarshalText", - "StructFieldNPtrAnonymousHeadOmitEmptyMarshalTextOnly", - "StructFieldNPtrAnonymousHeadStringTagMarshalText", - "StructFieldNPtrAnonymousHeadStringTagMarshalTextOnly", "StructFieldHeadRecursive", - "StructFieldHeadRecursiveOnly", "StructFieldHeadOmitEmptyRecursive", - "StructFieldHeadOmitEmptyRecursiveOnly", "StructFieldHeadStringTagRecursive", - "StructFieldHeadStringTagRecursiveOnly", - "StructFieldAnonymousHeadRecursive", - "StructFieldAnonymousHeadRecursiveOnly", - "StructFieldAnonymousHeadOmitEmptyRecursive", - "StructFieldAnonymousHeadOmitEmptyRecursiveOnly", - "StructFieldAnonymousHeadStringTagRecursive", - "StructFieldAnonymousHeadStringTagRecursiveOnly", "StructFieldPtrHeadRecursive", - "StructFieldPtrHeadRecursiveOnly", "StructFieldPtrHeadOmitEmptyRecursive", - "StructFieldPtrHeadOmitEmptyRecursiveOnly", "StructFieldPtrHeadStringTagRecursive", - "StructFieldPtrHeadStringTagRecursiveOnly", - "StructFieldPtrAnonymousHeadRecursive", - "StructFieldPtrAnonymousHeadRecursiveOnly", - "StructFieldPtrAnonymousHeadOmitEmptyRecursive", - "StructFieldPtrAnonymousHeadOmitEmptyRecursiveOnly", - "StructFieldPtrAnonymousHeadStringTagRecursive", - "StructFieldPtrAnonymousHeadStringTagRecursiveOnly", - "StructFieldNPtrHeadRecursive", - "StructFieldNPtrHeadRecursiveOnly", - "StructFieldNPtrHeadOmitEmptyRecursive", - "StructFieldNPtrHeadOmitEmptyRecursiveOnly", - "StructFieldNPtrHeadStringTagRecursive", - "StructFieldNPtrHeadStringTagRecursiveOnly", - "StructFieldNPtrAnonymousHeadRecursive", - "StructFieldNPtrAnonymousHeadRecursiveOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyRecursive", - "StructFieldNPtrAnonymousHeadOmitEmptyRecursiveOnly", - "StructFieldNPtrAnonymousHeadStringTagRecursive", - "StructFieldNPtrAnonymousHeadStringTagRecursiveOnly", "StructFieldHeadIntString", - "StructFieldHeadIntStringOnly", "StructFieldHeadOmitEmptyIntString", - "StructFieldHeadOmitEmptyIntStringOnly", "StructFieldHeadStringTagIntString", - "StructFieldHeadStringTagIntStringOnly", - "StructFieldAnonymousHeadIntString", - "StructFieldAnonymousHeadIntStringOnly", - "StructFieldAnonymousHeadOmitEmptyIntString", - "StructFieldAnonymousHeadOmitEmptyIntStringOnly", - "StructFieldAnonymousHeadStringTagIntString", - "StructFieldAnonymousHeadStringTagIntStringOnly", "StructFieldPtrHeadIntString", - "StructFieldPtrHeadIntStringOnly", "StructFieldPtrHeadOmitEmptyIntString", - "StructFieldPtrHeadOmitEmptyIntStringOnly", "StructFieldPtrHeadStringTagIntString", - "StructFieldPtrHeadStringTagIntStringOnly", - "StructFieldPtrAnonymousHeadIntString", - "StructFieldPtrAnonymousHeadIntStringOnly", - "StructFieldPtrAnonymousHeadOmitEmptyIntString", - "StructFieldPtrAnonymousHeadOmitEmptyIntStringOnly", - "StructFieldPtrAnonymousHeadStringTagIntString", - "StructFieldPtrAnonymousHeadStringTagIntStringOnly", - "StructFieldNPtrHeadIntString", - "StructFieldNPtrHeadIntStringOnly", - "StructFieldNPtrHeadOmitEmptyIntString", - "StructFieldNPtrHeadOmitEmptyIntStringOnly", - "StructFieldNPtrHeadStringTagIntString", - "StructFieldNPtrHeadStringTagIntStringOnly", - "StructFieldNPtrAnonymousHeadIntString", - "StructFieldNPtrAnonymousHeadIntStringOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyIntString", - "StructFieldNPtrAnonymousHeadOmitEmptyIntStringOnly", - "StructFieldNPtrAnonymousHeadStringTagIntString", - "StructFieldNPtrAnonymousHeadStringTagIntStringOnly", "StructFieldHeadUintString", - "StructFieldHeadUintStringOnly", "StructFieldHeadOmitEmptyUintString", - "StructFieldHeadOmitEmptyUintStringOnly", "StructFieldHeadStringTagUintString", - "StructFieldHeadStringTagUintStringOnly", - "StructFieldAnonymousHeadUintString", - "StructFieldAnonymousHeadUintStringOnly", - "StructFieldAnonymousHeadOmitEmptyUintString", - "StructFieldAnonymousHeadOmitEmptyUintStringOnly", - "StructFieldAnonymousHeadStringTagUintString", - "StructFieldAnonymousHeadStringTagUintStringOnly", "StructFieldPtrHeadUintString", - "StructFieldPtrHeadUintStringOnly", "StructFieldPtrHeadOmitEmptyUintString", - "StructFieldPtrHeadOmitEmptyUintStringOnly", "StructFieldPtrHeadStringTagUintString", - "StructFieldPtrHeadStringTagUintStringOnly", - "StructFieldPtrAnonymousHeadUintString", - "StructFieldPtrAnonymousHeadUintStringOnly", - "StructFieldPtrAnonymousHeadOmitEmptyUintString", - "StructFieldPtrAnonymousHeadOmitEmptyUintStringOnly", - "StructFieldPtrAnonymousHeadStringTagUintString", - "StructFieldPtrAnonymousHeadStringTagUintStringOnly", - "StructFieldNPtrHeadUintString", - "StructFieldNPtrHeadUintStringOnly", - "StructFieldNPtrHeadOmitEmptyUintString", - "StructFieldNPtrHeadOmitEmptyUintStringOnly", - "StructFieldNPtrHeadStringTagUintString", - "StructFieldNPtrHeadStringTagUintStringOnly", - "StructFieldNPtrAnonymousHeadUintString", - "StructFieldNPtrAnonymousHeadUintStringOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyUintString", - "StructFieldNPtrAnonymousHeadOmitEmptyUintStringOnly", - "StructFieldNPtrAnonymousHeadStringTagUintString", - "StructFieldNPtrAnonymousHeadStringTagUintStringOnly", "StructFieldHeadIntPtr", - "StructFieldHeadIntPtrOnly", "StructFieldHeadOmitEmptyIntPtr", - "StructFieldHeadOmitEmptyIntPtrOnly", "StructFieldHeadStringTagIntPtr", - "StructFieldHeadStringTagIntPtrOnly", - "StructFieldAnonymousHeadIntPtr", - "StructFieldAnonymousHeadIntPtrOnly", - "StructFieldAnonymousHeadOmitEmptyIntPtr", - "StructFieldAnonymousHeadOmitEmptyIntPtrOnly", - "StructFieldAnonymousHeadStringTagIntPtr", - "StructFieldAnonymousHeadStringTagIntPtrOnly", "StructFieldPtrHeadIntPtr", - "StructFieldPtrHeadIntPtrOnly", "StructFieldPtrHeadOmitEmptyIntPtr", - "StructFieldPtrHeadOmitEmptyIntPtrOnly", "StructFieldPtrHeadStringTagIntPtr", - "StructFieldPtrHeadStringTagIntPtrOnly", - "StructFieldPtrAnonymousHeadIntPtr", - "StructFieldPtrAnonymousHeadIntPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyIntPtr", - "StructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly", - "StructFieldPtrAnonymousHeadStringTagIntPtr", - "StructFieldPtrAnonymousHeadStringTagIntPtrOnly", - "StructFieldNPtrHeadIntPtr", - "StructFieldNPtrHeadIntPtrOnly", - "StructFieldNPtrHeadOmitEmptyIntPtr", - "StructFieldNPtrHeadOmitEmptyIntPtrOnly", - "StructFieldNPtrHeadStringTagIntPtr", - "StructFieldNPtrHeadStringTagIntPtrOnly", - "StructFieldNPtrAnonymousHeadIntPtr", - "StructFieldNPtrAnonymousHeadIntPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyIntPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyIntPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagIntPtr", - "StructFieldNPtrAnonymousHeadStringTagIntPtrOnly", "StructFieldHeadUintPtr", - "StructFieldHeadUintPtrOnly", "StructFieldHeadOmitEmptyUintPtr", - "StructFieldHeadOmitEmptyUintPtrOnly", "StructFieldHeadStringTagUintPtr", - "StructFieldHeadStringTagUintPtrOnly", - "StructFieldAnonymousHeadUintPtr", - "StructFieldAnonymousHeadUintPtrOnly", - "StructFieldAnonymousHeadOmitEmptyUintPtr", - "StructFieldAnonymousHeadOmitEmptyUintPtrOnly", - "StructFieldAnonymousHeadStringTagUintPtr", - "StructFieldAnonymousHeadStringTagUintPtrOnly", "StructFieldPtrHeadUintPtr", - "StructFieldPtrHeadUintPtrOnly", "StructFieldPtrHeadOmitEmptyUintPtr", - "StructFieldPtrHeadOmitEmptyUintPtrOnly", "StructFieldPtrHeadStringTagUintPtr", - "StructFieldPtrHeadStringTagUintPtrOnly", - "StructFieldPtrAnonymousHeadUintPtr", - "StructFieldPtrAnonymousHeadUintPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyUintPtr", - "StructFieldPtrAnonymousHeadOmitEmptyUintPtrOnly", - "StructFieldPtrAnonymousHeadStringTagUintPtr", - "StructFieldPtrAnonymousHeadStringTagUintPtrOnly", - "StructFieldNPtrHeadUintPtr", - "StructFieldNPtrHeadUintPtrOnly", - "StructFieldNPtrHeadOmitEmptyUintPtr", - "StructFieldNPtrHeadOmitEmptyUintPtrOnly", - "StructFieldNPtrHeadStringTagUintPtr", - "StructFieldNPtrHeadStringTagUintPtrOnly", - "StructFieldNPtrAnonymousHeadUintPtr", - "StructFieldNPtrAnonymousHeadUintPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyUintPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyUintPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagUintPtr", - "StructFieldNPtrAnonymousHeadStringTagUintPtrOnly", "StructFieldHeadFloat32Ptr", - "StructFieldHeadFloat32PtrOnly", "StructFieldHeadOmitEmptyFloat32Ptr", - "StructFieldHeadOmitEmptyFloat32PtrOnly", "StructFieldHeadStringTagFloat32Ptr", - "StructFieldHeadStringTagFloat32PtrOnly", - "StructFieldAnonymousHeadFloat32Ptr", - "StructFieldAnonymousHeadFloat32PtrOnly", - "StructFieldAnonymousHeadOmitEmptyFloat32Ptr", - "StructFieldAnonymousHeadOmitEmptyFloat32PtrOnly", - "StructFieldAnonymousHeadStringTagFloat32Ptr", - "StructFieldAnonymousHeadStringTagFloat32PtrOnly", "StructFieldPtrHeadFloat32Ptr", - "StructFieldPtrHeadFloat32PtrOnly", "StructFieldPtrHeadOmitEmptyFloat32Ptr", - "StructFieldPtrHeadOmitEmptyFloat32PtrOnly", "StructFieldPtrHeadStringTagFloat32Ptr", - "StructFieldPtrHeadStringTagFloat32PtrOnly", - "StructFieldPtrAnonymousHeadFloat32Ptr", - "StructFieldPtrAnonymousHeadFloat32PtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr", - "StructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly", - "StructFieldPtrAnonymousHeadStringTagFloat32Ptr", - "StructFieldPtrAnonymousHeadStringTagFloat32PtrOnly", - "StructFieldNPtrHeadFloat32Ptr", - "StructFieldNPtrHeadFloat32PtrOnly", - "StructFieldNPtrHeadOmitEmptyFloat32Ptr", - "StructFieldNPtrHeadOmitEmptyFloat32PtrOnly", - "StructFieldNPtrHeadStringTagFloat32Ptr", - "StructFieldNPtrHeadStringTagFloat32PtrOnly", - "StructFieldNPtrAnonymousHeadFloat32Ptr", - "StructFieldNPtrAnonymousHeadFloat32PtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat32Ptr", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat32PtrOnly", - "StructFieldNPtrAnonymousHeadStringTagFloat32Ptr", - "StructFieldNPtrAnonymousHeadStringTagFloat32PtrOnly", "StructFieldHeadFloat64Ptr", - "StructFieldHeadFloat64PtrOnly", "StructFieldHeadOmitEmptyFloat64Ptr", - "StructFieldHeadOmitEmptyFloat64PtrOnly", "StructFieldHeadStringTagFloat64Ptr", - "StructFieldHeadStringTagFloat64PtrOnly", - "StructFieldAnonymousHeadFloat64Ptr", - "StructFieldAnonymousHeadFloat64PtrOnly", - "StructFieldAnonymousHeadOmitEmptyFloat64Ptr", - "StructFieldAnonymousHeadOmitEmptyFloat64PtrOnly", - "StructFieldAnonymousHeadStringTagFloat64Ptr", - "StructFieldAnonymousHeadStringTagFloat64PtrOnly", "StructFieldPtrHeadFloat64Ptr", - "StructFieldPtrHeadFloat64PtrOnly", "StructFieldPtrHeadOmitEmptyFloat64Ptr", - "StructFieldPtrHeadOmitEmptyFloat64PtrOnly", "StructFieldPtrHeadStringTagFloat64Ptr", - "StructFieldPtrHeadStringTagFloat64PtrOnly", - "StructFieldPtrAnonymousHeadFloat64Ptr", - "StructFieldPtrAnonymousHeadFloat64PtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr", - "StructFieldPtrAnonymousHeadOmitEmptyFloat64PtrOnly", - "StructFieldPtrAnonymousHeadStringTagFloat64Ptr", - "StructFieldPtrAnonymousHeadStringTagFloat64PtrOnly", - "StructFieldNPtrHeadFloat64Ptr", - "StructFieldNPtrHeadFloat64PtrOnly", - "StructFieldNPtrHeadOmitEmptyFloat64Ptr", - "StructFieldNPtrHeadOmitEmptyFloat64PtrOnly", - "StructFieldNPtrHeadStringTagFloat64Ptr", - "StructFieldNPtrHeadStringTagFloat64PtrOnly", - "StructFieldNPtrAnonymousHeadFloat64Ptr", - "StructFieldNPtrAnonymousHeadFloat64PtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat64Ptr", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat64PtrOnly", - "StructFieldNPtrAnonymousHeadStringTagFloat64Ptr", - "StructFieldNPtrAnonymousHeadStringTagFloat64PtrOnly", "StructFieldHeadBoolPtr", - "StructFieldHeadBoolPtrOnly", "StructFieldHeadOmitEmptyBoolPtr", - "StructFieldHeadOmitEmptyBoolPtrOnly", "StructFieldHeadStringTagBoolPtr", - "StructFieldHeadStringTagBoolPtrOnly", - "StructFieldAnonymousHeadBoolPtr", - "StructFieldAnonymousHeadBoolPtrOnly", - "StructFieldAnonymousHeadOmitEmptyBoolPtr", - "StructFieldAnonymousHeadOmitEmptyBoolPtrOnly", - "StructFieldAnonymousHeadStringTagBoolPtr", - "StructFieldAnonymousHeadStringTagBoolPtrOnly", "StructFieldPtrHeadBoolPtr", - "StructFieldPtrHeadBoolPtrOnly", "StructFieldPtrHeadOmitEmptyBoolPtr", - "StructFieldPtrHeadOmitEmptyBoolPtrOnly", "StructFieldPtrHeadStringTagBoolPtr", - "StructFieldPtrHeadStringTagBoolPtrOnly", - "StructFieldPtrAnonymousHeadBoolPtr", - "StructFieldPtrAnonymousHeadBoolPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyBoolPtr", - "StructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly", - "StructFieldPtrAnonymousHeadStringTagBoolPtr", - "StructFieldPtrAnonymousHeadStringTagBoolPtrOnly", - "StructFieldNPtrHeadBoolPtr", - "StructFieldNPtrHeadBoolPtrOnly", - "StructFieldNPtrHeadOmitEmptyBoolPtr", - "StructFieldNPtrHeadOmitEmptyBoolPtrOnly", - "StructFieldNPtrHeadStringTagBoolPtr", - "StructFieldNPtrHeadStringTagBoolPtrOnly", - "StructFieldNPtrAnonymousHeadBoolPtr", - "StructFieldNPtrAnonymousHeadBoolPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyBoolPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyBoolPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagBoolPtr", - "StructFieldNPtrAnonymousHeadStringTagBoolPtrOnly", "StructFieldHeadStringPtr", - "StructFieldHeadStringPtrOnly", "StructFieldHeadOmitEmptyStringPtr", - "StructFieldHeadOmitEmptyStringPtrOnly", "StructFieldHeadStringTagStringPtr", - "StructFieldHeadStringTagStringPtrOnly", - "StructFieldAnonymousHeadStringPtr", - "StructFieldAnonymousHeadStringPtrOnly", - "StructFieldAnonymousHeadOmitEmptyStringPtr", - "StructFieldAnonymousHeadOmitEmptyStringPtrOnly", - "StructFieldAnonymousHeadStringTagStringPtr", - "StructFieldAnonymousHeadStringTagStringPtrOnly", "StructFieldPtrHeadStringPtr", - "StructFieldPtrHeadStringPtrOnly", "StructFieldPtrHeadOmitEmptyStringPtr", - "StructFieldPtrHeadOmitEmptyStringPtrOnly", "StructFieldPtrHeadStringTagStringPtr", - "StructFieldPtrHeadStringTagStringPtrOnly", - "StructFieldPtrAnonymousHeadStringPtr", - "StructFieldPtrAnonymousHeadStringPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyStringPtr", - "StructFieldPtrAnonymousHeadOmitEmptyStringPtrOnly", - "StructFieldPtrAnonymousHeadStringTagStringPtr", - "StructFieldPtrAnonymousHeadStringTagStringPtrOnly", - "StructFieldNPtrHeadStringPtr", - "StructFieldNPtrHeadStringPtrOnly", - "StructFieldNPtrHeadOmitEmptyStringPtr", - "StructFieldNPtrHeadOmitEmptyStringPtrOnly", - "StructFieldNPtrHeadStringTagStringPtr", - "StructFieldNPtrHeadStringTagStringPtrOnly", - "StructFieldNPtrAnonymousHeadStringPtr", - "StructFieldNPtrAnonymousHeadStringPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyStringPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyStringPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagStringPtr", - "StructFieldNPtrAnonymousHeadStringTagStringPtrOnly", "StructFieldHeadBytesPtr", - "StructFieldHeadBytesPtrOnly", "StructFieldHeadOmitEmptyBytesPtr", - "StructFieldHeadOmitEmptyBytesPtrOnly", "StructFieldHeadStringTagBytesPtr", - "StructFieldHeadStringTagBytesPtrOnly", - "StructFieldAnonymousHeadBytesPtr", - "StructFieldAnonymousHeadBytesPtrOnly", - "StructFieldAnonymousHeadOmitEmptyBytesPtr", - "StructFieldAnonymousHeadOmitEmptyBytesPtrOnly", - "StructFieldAnonymousHeadStringTagBytesPtr", - "StructFieldAnonymousHeadStringTagBytesPtrOnly", "StructFieldPtrHeadBytesPtr", - "StructFieldPtrHeadBytesPtrOnly", "StructFieldPtrHeadOmitEmptyBytesPtr", - "StructFieldPtrHeadOmitEmptyBytesPtrOnly", "StructFieldPtrHeadStringTagBytesPtr", - "StructFieldPtrHeadStringTagBytesPtrOnly", - "StructFieldPtrAnonymousHeadBytesPtr", - "StructFieldPtrAnonymousHeadBytesPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyBytesPtr", - "StructFieldPtrAnonymousHeadOmitEmptyBytesPtrOnly", - "StructFieldPtrAnonymousHeadStringTagBytesPtr", - "StructFieldPtrAnonymousHeadStringTagBytesPtrOnly", - "StructFieldNPtrHeadBytesPtr", - "StructFieldNPtrHeadBytesPtrOnly", - "StructFieldNPtrHeadOmitEmptyBytesPtr", - "StructFieldNPtrHeadOmitEmptyBytesPtrOnly", - "StructFieldNPtrHeadStringTagBytesPtr", - "StructFieldNPtrHeadStringTagBytesPtrOnly", - "StructFieldNPtrAnonymousHeadBytesPtr", - "StructFieldNPtrAnonymousHeadBytesPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyBytesPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyBytesPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagBytesPtr", - "StructFieldNPtrAnonymousHeadStringTagBytesPtrOnly", - "StructFieldHeadIntNPtr", - "StructFieldHeadIntNPtrOnly", - "StructFieldHeadOmitEmptyIntNPtr", - "StructFieldHeadOmitEmptyIntNPtrOnly", - "StructFieldHeadStringTagIntNPtr", - "StructFieldHeadStringTagIntNPtrOnly", - "StructFieldAnonymousHeadIntNPtr", - "StructFieldAnonymousHeadIntNPtrOnly", - "StructFieldAnonymousHeadOmitEmptyIntNPtr", - "StructFieldAnonymousHeadOmitEmptyIntNPtrOnly", - "StructFieldAnonymousHeadStringTagIntNPtr", - "StructFieldAnonymousHeadStringTagIntNPtrOnly", - "StructFieldPtrHeadIntNPtr", - "StructFieldPtrHeadIntNPtrOnly", - "StructFieldPtrHeadOmitEmptyIntNPtr", - "StructFieldPtrHeadOmitEmptyIntNPtrOnly", - "StructFieldPtrHeadStringTagIntNPtr", - "StructFieldPtrHeadStringTagIntNPtrOnly", - "StructFieldPtrAnonymousHeadIntNPtr", - "StructFieldPtrAnonymousHeadIntNPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyIntNPtr", - "StructFieldPtrAnonymousHeadOmitEmptyIntNPtrOnly", - "StructFieldPtrAnonymousHeadStringTagIntNPtr", - "StructFieldPtrAnonymousHeadStringTagIntNPtrOnly", - "StructFieldNPtrHeadIntNPtr", - "StructFieldNPtrHeadIntNPtrOnly", - "StructFieldNPtrHeadOmitEmptyIntNPtr", - "StructFieldNPtrHeadOmitEmptyIntNPtrOnly", - "StructFieldNPtrHeadStringTagIntNPtr", - "StructFieldNPtrHeadStringTagIntNPtrOnly", - "StructFieldNPtrAnonymousHeadIntNPtr", - "StructFieldNPtrAnonymousHeadIntNPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyIntNPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyIntNPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagIntNPtr", - "StructFieldNPtrAnonymousHeadStringTagIntNPtrOnly", - "StructFieldHeadUintNPtr", - "StructFieldHeadUintNPtrOnly", - "StructFieldHeadOmitEmptyUintNPtr", - "StructFieldHeadOmitEmptyUintNPtrOnly", - "StructFieldHeadStringTagUintNPtr", - "StructFieldHeadStringTagUintNPtrOnly", - "StructFieldAnonymousHeadUintNPtr", - "StructFieldAnonymousHeadUintNPtrOnly", - "StructFieldAnonymousHeadOmitEmptyUintNPtr", - "StructFieldAnonymousHeadOmitEmptyUintNPtrOnly", - "StructFieldAnonymousHeadStringTagUintNPtr", - "StructFieldAnonymousHeadStringTagUintNPtrOnly", - "StructFieldPtrHeadUintNPtr", - "StructFieldPtrHeadUintNPtrOnly", - "StructFieldPtrHeadOmitEmptyUintNPtr", - "StructFieldPtrHeadOmitEmptyUintNPtrOnly", - "StructFieldPtrHeadStringTagUintNPtr", - "StructFieldPtrHeadStringTagUintNPtrOnly", - "StructFieldPtrAnonymousHeadUintNPtr", - "StructFieldPtrAnonymousHeadUintNPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyUintNPtr", - "StructFieldPtrAnonymousHeadOmitEmptyUintNPtrOnly", - "StructFieldPtrAnonymousHeadStringTagUintNPtr", - "StructFieldPtrAnonymousHeadStringTagUintNPtrOnly", - "StructFieldNPtrHeadUintNPtr", - "StructFieldNPtrHeadUintNPtrOnly", - "StructFieldNPtrHeadOmitEmptyUintNPtr", - "StructFieldNPtrHeadOmitEmptyUintNPtrOnly", - "StructFieldNPtrHeadStringTagUintNPtr", - "StructFieldNPtrHeadStringTagUintNPtrOnly", - "StructFieldNPtrAnonymousHeadUintNPtr", - "StructFieldNPtrAnonymousHeadUintNPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyUintNPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyUintNPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagUintNPtr", - "StructFieldNPtrAnonymousHeadStringTagUintNPtrOnly", - "StructFieldHeadFloat32NPtr", - "StructFieldHeadFloat32NPtrOnly", - "StructFieldHeadOmitEmptyFloat32NPtr", - "StructFieldHeadOmitEmptyFloat32NPtrOnly", - "StructFieldHeadStringTagFloat32NPtr", - "StructFieldHeadStringTagFloat32NPtrOnly", - "StructFieldAnonymousHeadFloat32NPtr", - "StructFieldAnonymousHeadFloat32NPtrOnly", - "StructFieldAnonymousHeadOmitEmptyFloat32NPtr", - "StructFieldAnonymousHeadOmitEmptyFloat32NPtrOnly", - "StructFieldAnonymousHeadStringTagFloat32NPtr", - "StructFieldAnonymousHeadStringTagFloat32NPtrOnly", - "StructFieldPtrHeadFloat32NPtr", - "StructFieldPtrHeadFloat32NPtrOnly", - "StructFieldPtrHeadOmitEmptyFloat32NPtr", - "StructFieldPtrHeadOmitEmptyFloat32NPtrOnly", - "StructFieldPtrHeadStringTagFloat32NPtr", - "StructFieldPtrHeadStringTagFloat32NPtrOnly", - "StructFieldPtrAnonymousHeadFloat32NPtr", - "StructFieldPtrAnonymousHeadFloat32NPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyFloat32NPtr", - "StructFieldPtrAnonymousHeadOmitEmptyFloat32NPtrOnly", - "StructFieldPtrAnonymousHeadStringTagFloat32NPtr", - "StructFieldPtrAnonymousHeadStringTagFloat32NPtrOnly", - "StructFieldNPtrHeadFloat32NPtr", - "StructFieldNPtrHeadFloat32NPtrOnly", - "StructFieldNPtrHeadOmitEmptyFloat32NPtr", - "StructFieldNPtrHeadOmitEmptyFloat32NPtrOnly", - "StructFieldNPtrHeadStringTagFloat32NPtr", - "StructFieldNPtrHeadStringTagFloat32NPtrOnly", - "StructFieldNPtrAnonymousHeadFloat32NPtr", - "StructFieldNPtrAnonymousHeadFloat32NPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat32NPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat32NPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagFloat32NPtr", - "StructFieldNPtrAnonymousHeadStringTagFloat32NPtrOnly", - "StructFieldHeadFloat64NPtr", - "StructFieldHeadFloat64NPtrOnly", - "StructFieldHeadOmitEmptyFloat64NPtr", - "StructFieldHeadOmitEmptyFloat64NPtrOnly", - "StructFieldHeadStringTagFloat64NPtr", - "StructFieldHeadStringTagFloat64NPtrOnly", - "StructFieldAnonymousHeadFloat64NPtr", - "StructFieldAnonymousHeadFloat64NPtrOnly", - "StructFieldAnonymousHeadOmitEmptyFloat64NPtr", - "StructFieldAnonymousHeadOmitEmptyFloat64NPtrOnly", - "StructFieldAnonymousHeadStringTagFloat64NPtr", - "StructFieldAnonymousHeadStringTagFloat64NPtrOnly", - "StructFieldPtrHeadFloat64NPtr", - "StructFieldPtrHeadFloat64NPtrOnly", - "StructFieldPtrHeadOmitEmptyFloat64NPtr", - "StructFieldPtrHeadOmitEmptyFloat64NPtrOnly", - "StructFieldPtrHeadStringTagFloat64NPtr", - "StructFieldPtrHeadStringTagFloat64NPtrOnly", - "StructFieldPtrAnonymousHeadFloat64NPtr", - "StructFieldPtrAnonymousHeadFloat64NPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyFloat64NPtr", - "StructFieldPtrAnonymousHeadOmitEmptyFloat64NPtrOnly", - "StructFieldPtrAnonymousHeadStringTagFloat64NPtr", - "StructFieldPtrAnonymousHeadStringTagFloat64NPtrOnly", - "StructFieldNPtrHeadFloat64NPtr", - "StructFieldNPtrHeadFloat64NPtrOnly", - "StructFieldNPtrHeadOmitEmptyFloat64NPtr", - "StructFieldNPtrHeadOmitEmptyFloat64NPtrOnly", - "StructFieldNPtrHeadStringTagFloat64NPtr", - "StructFieldNPtrHeadStringTagFloat64NPtrOnly", - "StructFieldNPtrAnonymousHeadFloat64NPtr", - "StructFieldNPtrAnonymousHeadFloat64NPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat64NPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyFloat64NPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagFloat64NPtr", - "StructFieldNPtrAnonymousHeadStringTagFloat64NPtrOnly", - "StructFieldHeadBoolNPtr", - "StructFieldHeadBoolNPtrOnly", - "StructFieldHeadOmitEmptyBoolNPtr", - "StructFieldHeadOmitEmptyBoolNPtrOnly", - "StructFieldHeadStringTagBoolNPtr", - "StructFieldHeadStringTagBoolNPtrOnly", - "StructFieldAnonymousHeadBoolNPtr", - "StructFieldAnonymousHeadBoolNPtrOnly", - "StructFieldAnonymousHeadOmitEmptyBoolNPtr", - "StructFieldAnonymousHeadOmitEmptyBoolNPtrOnly", - "StructFieldAnonymousHeadStringTagBoolNPtr", - "StructFieldAnonymousHeadStringTagBoolNPtrOnly", - "StructFieldPtrHeadBoolNPtr", - "StructFieldPtrHeadBoolNPtrOnly", - "StructFieldPtrHeadOmitEmptyBoolNPtr", - "StructFieldPtrHeadOmitEmptyBoolNPtrOnly", - "StructFieldPtrHeadStringTagBoolNPtr", - "StructFieldPtrHeadStringTagBoolNPtrOnly", - "StructFieldPtrAnonymousHeadBoolNPtr", - "StructFieldPtrAnonymousHeadBoolNPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyBoolNPtr", - "StructFieldPtrAnonymousHeadOmitEmptyBoolNPtrOnly", - "StructFieldPtrAnonymousHeadStringTagBoolNPtr", - "StructFieldPtrAnonymousHeadStringTagBoolNPtrOnly", - "StructFieldNPtrHeadBoolNPtr", - "StructFieldNPtrHeadBoolNPtrOnly", - "StructFieldNPtrHeadOmitEmptyBoolNPtr", - "StructFieldNPtrHeadOmitEmptyBoolNPtrOnly", - "StructFieldNPtrHeadStringTagBoolNPtr", - "StructFieldNPtrHeadStringTagBoolNPtrOnly", - "StructFieldNPtrAnonymousHeadBoolNPtr", - "StructFieldNPtrAnonymousHeadBoolNPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyBoolNPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyBoolNPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagBoolNPtr", - "StructFieldNPtrAnonymousHeadStringTagBoolNPtrOnly", - "StructFieldHeadStringNPtr", - "StructFieldHeadStringNPtrOnly", - "StructFieldHeadOmitEmptyStringNPtr", - "StructFieldHeadOmitEmptyStringNPtrOnly", - "StructFieldHeadStringTagStringNPtr", - "StructFieldHeadStringTagStringNPtrOnly", - "StructFieldAnonymousHeadStringNPtr", - "StructFieldAnonymousHeadStringNPtrOnly", - "StructFieldAnonymousHeadOmitEmptyStringNPtr", - "StructFieldAnonymousHeadOmitEmptyStringNPtrOnly", - "StructFieldAnonymousHeadStringTagStringNPtr", - "StructFieldAnonymousHeadStringTagStringNPtrOnly", - "StructFieldPtrHeadStringNPtr", - "StructFieldPtrHeadStringNPtrOnly", - "StructFieldPtrHeadOmitEmptyStringNPtr", - "StructFieldPtrHeadOmitEmptyStringNPtrOnly", - "StructFieldPtrHeadStringTagStringNPtr", - "StructFieldPtrHeadStringTagStringNPtrOnly", - "StructFieldPtrAnonymousHeadStringNPtr", - "StructFieldPtrAnonymousHeadStringNPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyStringNPtr", - "StructFieldPtrAnonymousHeadOmitEmptyStringNPtrOnly", - "StructFieldPtrAnonymousHeadStringTagStringNPtr", - "StructFieldPtrAnonymousHeadStringTagStringNPtrOnly", - "StructFieldNPtrHeadStringNPtr", - "StructFieldNPtrHeadStringNPtrOnly", - "StructFieldNPtrHeadOmitEmptyStringNPtr", - "StructFieldNPtrHeadOmitEmptyStringNPtrOnly", - "StructFieldNPtrHeadStringTagStringNPtr", - "StructFieldNPtrHeadStringTagStringNPtrOnly", - "StructFieldNPtrAnonymousHeadStringNPtr", - "StructFieldNPtrAnonymousHeadStringNPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyStringNPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyStringNPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagStringNPtr", - "StructFieldNPtrAnonymousHeadStringTagStringNPtrOnly", - "StructFieldHeadBytesNPtr", - "StructFieldHeadBytesNPtrOnly", - "StructFieldHeadOmitEmptyBytesNPtr", - "StructFieldHeadOmitEmptyBytesNPtrOnly", - "StructFieldHeadStringTagBytesNPtr", - "StructFieldHeadStringTagBytesNPtrOnly", - "StructFieldAnonymousHeadBytesNPtr", - "StructFieldAnonymousHeadBytesNPtrOnly", - "StructFieldAnonymousHeadOmitEmptyBytesNPtr", - "StructFieldAnonymousHeadOmitEmptyBytesNPtrOnly", - "StructFieldAnonymousHeadStringTagBytesNPtr", - "StructFieldAnonymousHeadStringTagBytesNPtrOnly", - "StructFieldPtrHeadBytesNPtr", - "StructFieldPtrHeadBytesNPtrOnly", - "StructFieldPtrHeadOmitEmptyBytesNPtr", - "StructFieldPtrHeadOmitEmptyBytesNPtrOnly", - "StructFieldPtrHeadStringTagBytesNPtr", - "StructFieldPtrHeadStringTagBytesNPtrOnly", - "StructFieldPtrAnonymousHeadBytesNPtr", - "StructFieldPtrAnonymousHeadBytesNPtrOnly", - "StructFieldPtrAnonymousHeadOmitEmptyBytesNPtr", - "StructFieldPtrAnonymousHeadOmitEmptyBytesNPtrOnly", - "StructFieldPtrAnonymousHeadStringTagBytesNPtr", - "StructFieldPtrAnonymousHeadStringTagBytesNPtrOnly", - "StructFieldNPtrHeadBytesNPtr", - "StructFieldNPtrHeadBytesNPtrOnly", - "StructFieldNPtrHeadOmitEmptyBytesNPtr", - "StructFieldNPtrHeadOmitEmptyBytesNPtrOnly", - "StructFieldNPtrHeadStringTagBytesNPtr", - "StructFieldNPtrHeadStringTagBytesNPtrOnly", - "StructFieldNPtrAnonymousHeadBytesNPtr", - "StructFieldNPtrAnonymousHeadBytesNPtrOnly", - "StructFieldNPtrAnonymousHeadOmitEmptyBytesNPtr", - "StructFieldNPtrAnonymousHeadOmitEmptyBytesNPtrOnly", - "StructFieldNPtrAnonymousHeadStringTagBytesNPtr", - "StructFieldNPtrAnonymousHeadStringTagBytesNPtrOnly", + "StructFieldHeadNumberPtr", + "StructFieldHeadOmitEmptyNumberPtr", + "StructFieldHeadStringTagNumberPtr", + "StructFieldPtrHeadNumberPtr", + "StructFieldPtrHeadOmitEmptyNumberPtr", + "StructFieldPtrHeadStringTagNumberPtr", + "StructFieldHeadArrayPtr", + "StructFieldHeadOmitEmptyArrayPtr", + "StructFieldHeadStringTagArrayPtr", + "StructFieldPtrHeadArrayPtr", + "StructFieldPtrHeadOmitEmptyArrayPtr", + "StructFieldPtrHeadStringTagArrayPtr", + "StructFieldHeadMapPtr", + "StructFieldHeadOmitEmptyMapPtr", + "StructFieldHeadStringTagMapPtr", + "StructFieldPtrHeadMapPtr", + "StructFieldPtrHeadOmitEmptyMapPtr", + "StructFieldPtrHeadStringTagMapPtr", + "StructFieldHeadSlicePtr", + "StructFieldHeadOmitEmptySlicePtr", + "StructFieldHeadStringTagSlicePtr", + "StructFieldPtrHeadSlicePtr", + "StructFieldPtrHeadOmitEmptySlicePtr", + "StructFieldPtrHeadStringTagSlicePtr", + "StructFieldHeadMarshalJSONPtr", + "StructFieldHeadOmitEmptyMarshalJSONPtr", + "StructFieldHeadStringTagMarshalJSONPtr", + "StructFieldPtrHeadMarshalJSONPtr", + "StructFieldPtrHeadOmitEmptyMarshalJSONPtr", + "StructFieldPtrHeadStringTagMarshalJSONPtr", + "StructFieldHeadMarshalTextPtr", + "StructFieldHeadOmitEmptyMarshalTextPtr", + "StructFieldHeadStringTagMarshalTextPtr", + "StructFieldPtrHeadMarshalTextPtr", + "StructFieldPtrHeadOmitEmptyMarshalTextPtr", + "StructFieldPtrHeadStringTagMarshalTextPtr", + "StructFieldHeadInterfacePtr", + "StructFieldHeadOmitEmptyInterfacePtr", + "StructFieldHeadStringTagInterfacePtr", + "StructFieldPtrHeadInterfacePtr", + "StructFieldPtrHeadOmitEmptyInterfacePtr", + "StructFieldPtrHeadStringTagInterfacePtr", + "StructFieldHeadRecursivePtr", + "StructFieldHeadOmitEmptyRecursivePtr", + "StructFieldHeadStringTagRecursivePtr", + "StructFieldPtrHeadRecursivePtr", + "StructFieldPtrHeadOmitEmptyRecursivePtr", + "StructFieldPtrHeadStringTagRecursivePtr", "StructFieldHead", - "StructFieldHeadOnly", "StructFieldHeadOmitEmpty", - "StructFieldHeadOmitEmptyOnly", "StructFieldHeadStringTag", - "StructFieldHeadStringTagOnly", - "StructFieldAnonymousHead", - "StructFieldAnonymousHeadOnly", - "StructFieldAnonymousHeadOmitEmpty", - "StructFieldAnonymousHeadOmitEmptyOnly", - "StructFieldAnonymousHeadStringTag", - "StructFieldAnonymousHeadStringTagOnly", "StructFieldPtrHead", - "StructFieldPtrHeadOnly", "StructFieldPtrHeadOmitEmpty", - "StructFieldPtrHeadOmitEmptyOnly", "StructFieldPtrHeadStringTag", - "StructFieldPtrHeadStringTagOnly", - "StructFieldPtrAnonymousHead", - "StructFieldPtrAnonymousHeadOnly", - "StructFieldPtrAnonymousHeadOmitEmpty", - "StructFieldPtrAnonymousHeadOmitEmptyOnly", - "StructFieldPtrAnonymousHeadStringTag", - "StructFieldPtrAnonymousHeadStringTagOnly", - "StructFieldNPtrHead", - "StructFieldNPtrHeadOnly", - "StructFieldNPtrHeadOmitEmpty", - "StructFieldNPtrHeadOmitEmptyOnly", - "StructFieldNPtrHeadStringTag", - "StructFieldNPtrHeadStringTagOnly", - "StructFieldNPtrAnonymousHead", - "StructFieldNPtrAnonymousHeadOnly", - "StructFieldNPtrAnonymousHeadOmitEmpty", - "StructFieldNPtrAnonymousHeadOmitEmptyOnly", - "StructFieldNPtrAnonymousHeadStringTag", - "StructFieldNPtrAnonymousHeadStringTagOnly", "StructFieldInt", "StructFieldOmitEmptyInt", "StructFieldStringTagInt", @@ -1246,15 +288,15 @@ var opTypeStrings = [1394]string{ "StructFieldBytes", "StructFieldOmitEmptyBytes", "StructFieldStringTagBytes", + "StructFieldNumber", + "StructFieldOmitEmptyNumber", + "StructFieldStringTagNumber", "StructFieldArray", "StructFieldOmitEmptyArray", "StructFieldStringTagArray", "StructFieldMap", "StructFieldOmitEmptyMap", "StructFieldStringTagMap", - "StructFieldMapLoad", - "StructFieldOmitEmptyMapLoad", - "StructFieldStringTagMapLoad", "StructFieldSlice", "StructFieldOmitEmptySlice", "StructFieldStringTagSlice", @@ -1297,27 +339,30 @@ var opTypeStrings = [1394]string{ "StructFieldBytesPtr", "StructFieldOmitEmptyBytesPtr", "StructFieldStringTagBytesPtr", - "StructFieldIntNPtr", - "StructFieldOmitEmptyIntNPtr", - "StructFieldStringTagIntNPtr", - "StructFieldUintNPtr", - "StructFieldOmitEmptyUintNPtr", - "StructFieldStringTagUintNPtr", - "StructFieldFloat32NPtr", - "StructFieldOmitEmptyFloat32NPtr", - "StructFieldStringTagFloat32NPtr", - "StructFieldFloat64NPtr", - "StructFieldOmitEmptyFloat64NPtr", - "StructFieldStringTagFloat64NPtr", - "StructFieldBoolNPtr", - "StructFieldOmitEmptyBoolNPtr", - "StructFieldStringTagBoolNPtr", - "StructFieldStringNPtr", - "StructFieldOmitEmptyStringNPtr", - "StructFieldStringTagStringNPtr", - "StructFieldBytesNPtr", - "StructFieldOmitEmptyBytesNPtr", - "StructFieldStringTagBytesNPtr", + "StructFieldNumberPtr", + "StructFieldOmitEmptyNumberPtr", + "StructFieldStringTagNumberPtr", + "StructFieldArrayPtr", + "StructFieldOmitEmptyArrayPtr", + "StructFieldStringTagArrayPtr", + "StructFieldMapPtr", + "StructFieldOmitEmptyMapPtr", + "StructFieldStringTagMapPtr", + "StructFieldSlicePtr", + "StructFieldOmitEmptySlicePtr", + "StructFieldStringTagSlicePtr", + "StructFieldMarshalJSONPtr", + "StructFieldOmitEmptyMarshalJSONPtr", + "StructFieldStringTagMarshalJSONPtr", + "StructFieldMarshalTextPtr", + "StructFieldOmitEmptyMarshalTextPtr", + "StructFieldStringTagMarshalTextPtr", + "StructFieldInterfacePtr", + "StructFieldOmitEmptyInterfacePtr", + "StructFieldStringTagInterfacePtr", + "StructFieldRecursivePtr", + "StructFieldOmitEmptyRecursivePtr", + "StructFieldStringTagRecursivePtr", "StructField", "StructFieldOmitEmpty", "StructFieldStringTag", @@ -1342,15 +387,15 @@ var opTypeStrings = [1394]string{ "StructEndBytes", "StructEndOmitEmptyBytes", "StructEndStringTagBytes", + "StructEndNumber", + "StructEndOmitEmptyNumber", + "StructEndStringTagNumber", "StructEndArray", "StructEndOmitEmptyArray", "StructEndStringTagArray", "StructEndMap", "StructEndOmitEmptyMap", "StructEndStringTagMap", - "StructEndMapLoad", - "StructEndOmitEmptyMapLoad", - "StructEndStringTagMapLoad", "StructEndSlice", "StructEndOmitEmptySlice", "StructEndStringTagSlice", @@ -1393,27 +438,30 @@ var opTypeStrings = [1394]string{ "StructEndBytesPtr", "StructEndOmitEmptyBytesPtr", "StructEndStringTagBytesPtr", - "StructEndIntNPtr", - "StructEndOmitEmptyIntNPtr", - "StructEndStringTagIntNPtr", - "StructEndUintNPtr", - "StructEndOmitEmptyUintNPtr", - "StructEndStringTagUintNPtr", - "StructEndFloat32NPtr", - "StructEndOmitEmptyFloat32NPtr", - "StructEndStringTagFloat32NPtr", - "StructEndFloat64NPtr", - "StructEndOmitEmptyFloat64NPtr", - "StructEndStringTagFloat64NPtr", - "StructEndBoolNPtr", - "StructEndOmitEmptyBoolNPtr", - "StructEndStringTagBoolNPtr", - "StructEndStringNPtr", - "StructEndOmitEmptyStringNPtr", - "StructEndStringTagStringNPtr", - "StructEndBytesNPtr", - "StructEndOmitEmptyBytesNPtr", - "StructEndStringTagBytesNPtr", + "StructEndNumberPtr", + "StructEndOmitEmptyNumberPtr", + "StructEndStringTagNumberPtr", + "StructEndArrayPtr", + "StructEndOmitEmptyArrayPtr", + "StructEndStringTagArrayPtr", + "StructEndMapPtr", + "StructEndOmitEmptyMapPtr", + "StructEndStringTagMapPtr", + "StructEndSlicePtr", + "StructEndOmitEmptySlicePtr", + "StructEndStringTagSlicePtr", + "StructEndMarshalJSONPtr", + "StructEndOmitEmptyMarshalJSONPtr", + "StructEndStringTagMarshalJSONPtr", + "StructEndMarshalTextPtr", + "StructEndOmitEmptyMarshalTextPtr", + "StructEndStringTagMarshalTextPtr", + "StructEndInterfacePtr", + "StructEndOmitEmptyInterfacePtr", + "StructEndStringTagInterfacePtr", + "StructEndRecursivePtr", + "StructEndOmitEmptyRecursivePtr", + "StructEndStringTagRecursivePtr", "StructEnd", "StructEndOmitEmpty", "StructEndStringTag", @@ -1422,1404 +470,452 @@ var opTypeStrings = [1394]string{ type opType int const ( - opEnd opType = 0 - opInterface opType = 1 - opPtr opType = 2 - opNPtr opType = 3 - opSliceHead opType = 4 - opRootSliceHead opType = 5 - opSliceElem opType = 6 - opRootSliceElem opType = 7 - opSliceEnd opType = 8 - opArrayHead opType = 9 - opArrayElem opType = 10 - opArrayEnd opType = 11 - opMapHead opType = 12 - opMapHeadLoad opType = 13 - opMapKey opType = 14 - opMapValue opType = 15 - opMapEnd opType = 16 - opStructFieldRecursiveEnd opType = 17 - opStructAnonymousEnd opType = 18 - opInt opType = 19 - opUint opType = 20 - opFloat32 opType = 21 - opFloat64 opType = 22 - opBool opType = 23 - opString opType = 24 - opBytes opType = 25 - opArray opType = 26 - opMap opType = 27 - opMapLoad opType = 28 - opSlice opType = 29 - opStruct opType = 30 - opMarshalJSON opType = 31 - opMarshalText opType = 32 - opRecursive opType = 33 - opIntString opType = 34 - opUintString opType = 35 - opIntPtr opType = 36 - opUintPtr opType = 37 - opFloat32Ptr opType = 38 - opFloat64Ptr opType = 39 - opBoolPtr opType = 40 - opStringPtr opType = 41 - opBytesPtr opType = 42 - opIntNPtr opType = 43 - opUintNPtr opType = 44 - opFloat32NPtr opType = 45 - opFloat64NPtr opType = 46 - opBoolNPtr opType = 47 - opStringNPtr opType = 48 - opBytesNPtr opType = 49 - opStructFieldHeadInt opType = 50 - opStructFieldHeadIntOnly opType = 51 - opStructFieldHeadOmitEmptyInt opType = 52 - opStructFieldHeadOmitEmptyIntOnly opType = 53 - opStructFieldHeadStringTagInt opType = 54 - opStructFieldHeadStringTagIntOnly opType = 55 - opStructFieldAnonymousHeadInt opType = 56 - opStructFieldAnonymousHeadIntOnly opType = 57 - opStructFieldAnonymousHeadOmitEmptyInt opType = 58 - opStructFieldAnonymousHeadOmitEmptyIntOnly opType = 59 - opStructFieldAnonymousHeadStringTagInt opType = 60 - opStructFieldAnonymousHeadStringTagIntOnly opType = 61 - opStructFieldPtrHeadInt opType = 62 - opStructFieldPtrHeadIntOnly opType = 63 - opStructFieldPtrHeadOmitEmptyInt opType = 64 - opStructFieldPtrHeadOmitEmptyIntOnly opType = 65 - opStructFieldPtrHeadStringTagInt opType = 66 - opStructFieldPtrHeadStringTagIntOnly opType = 67 - opStructFieldPtrAnonymousHeadInt opType = 68 - opStructFieldPtrAnonymousHeadIntOnly opType = 69 - opStructFieldPtrAnonymousHeadOmitEmptyInt opType = 70 - opStructFieldPtrAnonymousHeadOmitEmptyIntOnly opType = 71 - opStructFieldPtrAnonymousHeadStringTagInt opType = 72 - opStructFieldPtrAnonymousHeadStringTagIntOnly opType = 73 - opStructFieldNPtrHeadInt opType = 74 - opStructFieldNPtrHeadIntOnly opType = 75 - opStructFieldNPtrHeadOmitEmptyInt opType = 76 - opStructFieldNPtrHeadOmitEmptyIntOnly opType = 77 - opStructFieldNPtrHeadStringTagInt opType = 78 - opStructFieldNPtrHeadStringTagIntOnly opType = 79 - opStructFieldNPtrAnonymousHeadInt opType = 80 - opStructFieldNPtrAnonymousHeadIntOnly opType = 81 - opStructFieldNPtrAnonymousHeadOmitEmptyInt opType = 82 - opStructFieldNPtrAnonymousHeadOmitEmptyIntOnly opType = 83 - opStructFieldNPtrAnonymousHeadStringTagInt opType = 84 - opStructFieldNPtrAnonymousHeadStringTagIntOnly opType = 85 - opStructFieldHeadUint opType = 86 - opStructFieldHeadUintOnly opType = 87 - opStructFieldHeadOmitEmptyUint opType = 88 - opStructFieldHeadOmitEmptyUintOnly opType = 89 - opStructFieldHeadStringTagUint opType = 90 - opStructFieldHeadStringTagUintOnly opType = 91 - opStructFieldAnonymousHeadUint opType = 92 - opStructFieldAnonymousHeadUintOnly opType = 93 - opStructFieldAnonymousHeadOmitEmptyUint opType = 94 - opStructFieldAnonymousHeadOmitEmptyUintOnly opType = 95 - opStructFieldAnonymousHeadStringTagUint opType = 96 - opStructFieldAnonymousHeadStringTagUintOnly opType = 97 - opStructFieldPtrHeadUint opType = 98 - opStructFieldPtrHeadUintOnly opType = 99 - opStructFieldPtrHeadOmitEmptyUint opType = 100 - opStructFieldPtrHeadOmitEmptyUintOnly opType = 101 - opStructFieldPtrHeadStringTagUint opType = 102 - opStructFieldPtrHeadStringTagUintOnly opType = 103 - opStructFieldPtrAnonymousHeadUint opType = 104 - opStructFieldPtrAnonymousHeadUintOnly opType = 105 - opStructFieldPtrAnonymousHeadOmitEmptyUint opType = 106 - opStructFieldPtrAnonymousHeadOmitEmptyUintOnly opType = 107 - opStructFieldPtrAnonymousHeadStringTagUint opType = 108 - opStructFieldPtrAnonymousHeadStringTagUintOnly opType = 109 - opStructFieldNPtrHeadUint opType = 110 - opStructFieldNPtrHeadUintOnly opType = 111 - opStructFieldNPtrHeadOmitEmptyUint opType = 112 - opStructFieldNPtrHeadOmitEmptyUintOnly opType = 113 - opStructFieldNPtrHeadStringTagUint opType = 114 - opStructFieldNPtrHeadStringTagUintOnly opType = 115 - opStructFieldNPtrAnonymousHeadUint opType = 116 - opStructFieldNPtrAnonymousHeadUintOnly opType = 117 - opStructFieldNPtrAnonymousHeadOmitEmptyUint opType = 118 - opStructFieldNPtrAnonymousHeadOmitEmptyUintOnly opType = 119 - opStructFieldNPtrAnonymousHeadStringTagUint opType = 120 - opStructFieldNPtrAnonymousHeadStringTagUintOnly opType = 121 - opStructFieldHeadFloat32 opType = 122 - opStructFieldHeadFloat32Only opType = 123 - opStructFieldHeadOmitEmptyFloat32 opType = 124 - opStructFieldHeadOmitEmptyFloat32Only opType = 125 - opStructFieldHeadStringTagFloat32 opType = 126 - opStructFieldHeadStringTagFloat32Only opType = 127 - opStructFieldAnonymousHeadFloat32 opType = 128 - opStructFieldAnonymousHeadFloat32Only opType = 129 - opStructFieldAnonymousHeadOmitEmptyFloat32 opType = 130 - opStructFieldAnonymousHeadOmitEmptyFloat32Only opType = 131 - opStructFieldAnonymousHeadStringTagFloat32 opType = 132 - opStructFieldAnonymousHeadStringTagFloat32Only opType = 133 - opStructFieldPtrHeadFloat32 opType = 134 - opStructFieldPtrHeadFloat32Only opType = 135 - opStructFieldPtrHeadOmitEmptyFloat32 opType = 136 - opStructFieldPtrHeadOmitEmptyFloat32Only opType = 137 - opStructFieldPtrHeadStringTagFloat32 opType = 138 - opStructFieldPtrHeadStringTagFloat32Only opType = 139 - opStructFieldPtrAnonymousHeadFloat32 opType = 140 - opStructFieldPtrAnonymousHeadFloat32Only opType = 141 - opStructFieldPtrAnonymousHeadOmitEmptyFloat32 opType = 142 - opStructFieldPtrAnonymousHeadOmitEmptyFloat32Only opType = 143 - opStructFieldPtrAnonymousHeadStringTagFloat32 opType = 144 - opStructFieldPtrAnonymousHeadStringTagFloat32Only opType = 145 - opStructFieldNPtrHeadFloat32 opType = 146 - opStructFieldNPtrHeadFloat32Only opType = 147 - opStructFieldNPtrHeadOmitEmptyFloat32 opType = 148 - opStructFieldNPtrHeadOmitEmptyFloat32Only opType = 149 - opStructFieldNPtrHeadStringTagFloat32 opType = 150 - opStructFieldNPtrHeadStringTagFloat32Only opType = 151 - opStructFieldNPtrAnonymousHeadFloat32 opType = 152 - opStructFieldNPtrAnonymousHeadFloat32Only opType = 153 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat32 opType = 154 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat32Only opType = 155 - opStructFieldNPtrAnonymousHeadStringTagFloat32 opType = 156 - opStructFieldNPtrAnonymousHeadStringTagFloat32Only opType = 157 - opStructFieldHeadFloat64 opType = 158 - opStructFieldHeadFloat64Only opType = 159 - opStructFieldHeadOmitEmptyFloat64 opType = 160 - opStructFieldHeadOmitEmptyFloat64Only opType = 161 - opStructFieldHeadStringTagFloat64 opType = 162 - opStructFieldHeadStringTagFloat64Only opType = 163 - opStructFieldAnonymousHeadFloat64 opType = 164 - opStructFieldAnonymousHeadFloat64Only opType = 165 - opStructFieldAnonymousHeadOmitEmptyFloat64 opType = 166 - opStructFieldAnonymousHeadOmitEmptyFloat64Only opType = 167 - opStructFieldAnonymousHeadStringTagFloat64 opType = 168 - opStructFieldAnonymousHeadStringTagFloat64Only opType = 169 - opStructFieldPtrHeadFloat64 opType = 170 - opStructFieldPtrHeadFloat64Only opType = 171 - opStructFieldPtrHeadOmitEmptyFloat64 opType = 172 - opStructFieldPtrHeadOmitEmptyFloat64Only opType = 173 - opStructFieldPtrHeadStringTagFloat64 opType = 174 - opStructFieldPtrHeadStringTagFloat64Only opType = 175 - opStructFieldPtrAnonymousHeadFloat64 opType = 176 - opStructFieldPtrAnonymousHeadFloat64Only opType = 177 - opStructFieldPtrAnonymousHeadOmitEmptyFloat64 opType = 178 - opStructFieldPtrAnonymousHeadOmitEmptyFloat64Only opType = 179 - opStructFieldPtrAnonymousHeadStringTagFloat64 opType = 180 - opStructFieldPtrAnonymousHeadStringTagFloat64Only opType = 181 - opStructFieldNPtrHeadFloat64 opType = 182 - opStructFieldNPtrHeadFloat64Only opType = 183 - opStructFieldNPtrHeadOmitEmptyFloat64 opType = 184 - opStructFieldNPtrHeadOmitEmptyFloat64Only opType = 185 - opStructFieldNPtrHeadStringTagFloat64 opType = 186 - opStructFieldNPtrHeadStringTagFloat64Only opType = 187 - opStructFieldNPtrAnonymousHeadFloat64 opType = 188 - opStructFieldNPtrAnonymousHeadFloat64Only opType = 189 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat64 opType = 190 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat64Only opType = 191 - opStructFieldNPtrAnonymousHeadStringTagFloat64 opType = 192 - opStructFieldNPtrAnonymousHeadStringTagFloat64Only opType = 193 - opStructFieldHeadBool opType = 194 - opStructFieldHeadBoolOnly opType = 195 - opStructFieldHeadOmitEmptyBool opType = 196 - opStructFieldHeadOmitEmptyBoolOnly opType = 197 - opStructFieldHeadStringTagBool opType = 198 - opStructFieldHeadStringTagBoolOnly opType = 199 - opStructFieldAnonymousHeadBool opType = 200 - opStructFieldAnonymousHeadBoolOnly opType = 201 - opStructFieldAnonymousHeadOmitEmptyBool opType = 202 - opStructFieldAnonymousHeadOmitEmptyBoolOnly opType = 203 - opStructFieldAnonymousHeadStringTagBool opType = 204 - opStructFieldAnonymousHeadStringTagBoolOnly opType = 205 - opStructFieldPtrHeadBool opType = 206 - opStructFieldPtrHeadBoolOnly opType = 207 - opStructFieldPtrHeadOmitEmptyBool opType = 208 - opStructFieldPtrHeadOmitEmptyBoolOnly opType = 209 - opStructFieldPtrHeadStringTagBool opType = 210 - opStructFieldPtrHeadStringTagBoolOnly opType = 211 - opStructFieldPtrAnonymousHeadBool opType = 212 - opStructFieldPtrAnonymousHeadBoolOnly opType = 213 - opStructFieldPtrAnonymousHeadOmitEmptyBool opType = 214 - opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly opType = 215 - opStructFieldPtrAnonymousHeadStringTagBool opType = 216 - opStructFieldPtrAnonymousHeadStringTagBoolOnly opType = 217 - opStructFieldNPtrHeadBool opType = 218 - opStructFieldNPtrHeadBoolOnly opType = 219 - opStructFieldNPtrHeadOmitEmptyBool opType = 220 - opStructFieldNPtrHeadOmitEmptyBoolOnly opType = 221 - opStructFieldNPtrHeadStringTagBool opType = 222 - opStructFieldNPtrHeadStringTagBoolOnly opType = 223 - opStructFieldNPtrAnonymousHeadBool opType = 224 - opStructFieldNPtrAnonymousHeadBoolOnly opType = 225 - opStructFieldNPtrAnonymousHeadOmitEmptyBool opType = 226 - opStructFieldNPtrAnonymousHeadOmitEmptyBoolOnly opType = 227 - opStructFieldNPtrAnonymousHeadStringTagBool opType = 228 - opStructFieldNPtrAnonymousHeadStringTagBoolOnly opType = 229 - opStructFieldHeadString opType = 230 - opStructFieldHeadStringOnly opType = 231 - opStructFieldHeadOmitEmptyString opType = 232 - opStructFieldHeadOmitEmptyStringOnly opType = 233 - opStructFieldHeadStringTagString opType = 234 - opStructFieldHeadStringTagStringOnly opType = 235 - opStructFieldAnonymousHeadString opType = 236 - opStructFieldAnonymousHeadStringOnly opType = 237 - opStructFieldAnonymousHeadOmitEmptyString opType = 238 - opStructFieldAnonymousHeadOmitEmptyStringOnly opType = 239 - opStructFieldAnonymousHeadStringTagString opType = 240 - opStructFieldAnonymousHeadStringTagStringOnly opType = 241 - opStructFieldPtrHeadString opType = 242 - opStructFieldPtrHeadStringOnly opType = 243 - opStructFieldPtrHeadOmitEmptyString opType = 244 - opStructFieldPtrHeadOmitEmptyStringOnly opType = 245 - opStructFieldPtrHeadStringTagString opType = 246 - opStructFieldPtrHeadStringTagStringOnly opType = 247 - opStructFieldPtrAnonymousHeadString opType = 248 - opStructFieldPtrAnonymousHeadStringOnly opType = 249 - opStructFieldPtrAnonymousHeadOmitEmptyString opType = 250 - opStructFieldPtrAnonymousHeadOmitEmptyStringOnly opType = 251 - opStructFieldPtrAnonymousHeadStringTagString opType = 252 - opStructFieldPtrAnonymousHeadStringTagStringOnly opType = 253 - opStructFieldNPtrHeadString opType = 254 - opStructFieldNPtrHeadStringOnly opType = 255 - opStructFieldNPtrHeadOmitEmptyString opType = 256 - opStructFieldNPtrHeadOmitEmptyStringOnly opType = 257 - opStructFieldNPtrHeadStringTagString opType = 258 - opStructFieldNPtrHeadStringTagStringOnly opType = 259 - opStructFieldNPtrAnonymousHeadString opType = 260 - opStructFieldNPtrAnonymousHeadStringOnly opType = 261 - opStructFieldNPtrAnonymousHeadOmitEmptyString opType = 262 - opStructFieldNPtrAnonymousHeadOmitEmptyStringOnly opType = 263 - opStructFieldNPtrAnonymousHeadStringTagString opType = 264 - opStructFieldNPtrAnonymousHeadStringTagStringOnly opType = 265 - opStructFieldHeadBytes opType = 266 - opStructFieldHeadBytesOnly opType = 267 - opStructFieldHeadOmitEmptyBytes opType = 268 - opStructFieldHeadOmitEmptyBytesOnly opType = 269 - opStructFieldHeadStringTagBytes opType = 270 - opStructFieldHeadStringTagBytesOnly opType = 271 - opStructFieldAnonymousHeadBytes opType = 272 - opStructFieldAnonymousHeadBytesOnly opType = 273 - opStructFieldAnonymousHeadOmitEmptyBytes opType = 274 - opStructFieldAnonymousHeadOmitEmptyBytesOnly opType = 275 - opStructFieldAnonymousHeadStringTagBytes opType = 276 - opStructFieldAnonymousHeadStringTagBytesOnly opType = 277 - opStructFieldPtrHeadBytes opType = 278 - opStructFieldPtrHeadBytesOnly opType = 279 - opStructFieldPtrHeadOmitEmptyBytes opType = 280 - opStructFieldPtrHeadOmitEmptyBytesOnly opType = 281 - opStructFieldPtrHeadStringTagBytes opType = 282 - opStructFieldPtrHeadStringTagBytesOnly opType = 283 - opStructFieldPtrAnonymousHeadBytes opType = 284 - opStructFieldPtrAnonymousHeadBytesOnly opType = 285 - opStructFieldPtrAnonymousHeadOmitEmptyBytes opType = 286 - opStructFieldPtrAnonymousHeadOmitEmptyBytesOnly opType = 287 - opStructFieldPtrAnonymousHeadStringTagBytes opType = 288 - opStructFieldPtrAnonymousHeadStringTagBytesOnly opType = 289 - opStructFieldNPtrHeadBytes opType = 290 - opStructFieldNPtrHeadBytesOnly opType = 291 - opStructFieldNPtrHeadOmitEmptyBytes opType = 292 - opStructFieldNPtrHeadOmitEmptyBytesOnly opType = 293 - opStructFieldNPtrHeadStringTagBytes opType = 294 - opStructFieldNPtrHeadStringTagBytesOnly opType = 295 - opStructFieldNPtrAnonymousHeadBytes opType = 296 - opStructFieldNPtrAnonymousHeadBytesOnly opType = 297 - opStructFieldNPtrAnonymousHeadOmitEmptyBytes opType = 298 - opStructFieldNPtrAnonymousHeadOmitEmptyBytesOnly opType = 299 - opStructFieldNPtrAnonymousHeadStringTagBytes opType = 300 - opStructFieldNPtrAnonymousHeadStringTagBytesOnly opType = 301 - opStructFieldHeadArray opType = 302 - opStructFieldHeadArrayOnly opType = 303 - opStructFieldHeadOmitEmptyArray opType = 304 - opStructFieldHeadOmitEmptyArrayOnly opType = 305 - opStructFieldHeadStringTagArray opType = 306 - opStructFieldHeadStringTagArrayOnly opType = 307 - opStructFieldAnonymousHeadArray opType = 308 - opStructFieldAnonymousHeadArrayOnly opType = 309 - opStructFieldAnonymousHeadOmitEmptyArray opType = 310 - opStructFieldAnonymousHeadOmitEmptyArrayOnly opType = 311 - opStructFieldAnonymousHeadStringTagArray opType = 312 - opStructFieldAnonymousHeadStringTagArrayOnly opType = 313 - opStructFieldPtrHeadArray opType = 314 - opStructFieldPtrHeadArrayOnly opType = 315 - opStructFieldPtrHeadOmitEmptyArray opType = 316 - opStructFieldPtrHeadOmitEmptyArrayOnly opType = 317 - opStructFieldPtrHeadStringTagArray opType = 318 - opStructFieldPtrHeadStringTagArrayOnly opType = 319 - opStructFieldPtrAnonymousHeadArray opType = 320 - opStructFieldPtrAnonymousHeadArrayOnly opType = 321 - opStructFieldPtrAnonymousHeadOmitEmptyArray opType = 322 - opStructFieldPtrAnonymousHeadOmitEmptyArrayOnly opType = 323 - opStructFieldPtrAnonymousHeadStringTagArray opType = 324 - opStructFieldPtrAnonymousHeadStringTagArrayOnly opType = 325 - opStructFieldNPtrHeadArray opType = 326 - opStructFieldNPtrHeadArrayOnly opType = 327 - opStructFieldNPtrHeadOmitEmptyArray opType = 328 - opStructFieldNPtrHeadOmitEmptyArrayOnly opType = 329 - opStructFieldNPtrHeadStringTagArray opType = 330 - opStructFieldNPtrHeadStringTagArrayOnly opType = 331 - opStructFieldNPtrAnonymousHeadArray opType = 332 - opStructFieldNPtrAnonymousHeadArrayOnly opType = 333 - opStructFieldNPtrAnonymousHeadOmitEmptyArray opType = 334 - opStructFieldNPtrAnonymousHeadOmitEmptyArrayOnly opType = 335 - opStructFieldNPtrAnonymousHeadStringTagArray opType = 336 - opStructFieldNPtrAnonymousHeadStringTagArrayOnly opType = 337 - opStructFieldHeadMap opType = 338 - opStructFieldHeadMapOnly opType = 339 - opStructFieldHeadOmitEmptyMap opType = 340 - opStructFieldHeadOmitEmptyMapOnly opType = 341 - opStructFieldHeadStringTagMap opType = 342 - opStructFieldHeadStringTagMapOnly opType = 343 - opStructFieldAnonymousHeadMap opType = 344 - opStructFieldAnonymousHeadMapOnly opType = 345 - opStructFieldAnonymousHeadOmitEmptyMap opType = 346 - opStructFieldAnonymousHeadOmitEmptyMapOnly opType = 347 - opStructFieldAnonymousHeadStringTagMap opType = 348 - opStructFieldAnonymousHeadStringTagMapOnly opType = 349 - opStructFieldPtrHeadMap opType = 350 - opStructFieldPtrHeadMapOnly opType = 351 - opStructFieldPtrHeadOmitEmptyMap opType = 352 - opStructFieldPtrHeadOmitEmptyMapOnly opType = 353 - opStructFieldPtrHeadStringTagMap opType = 354 - opStructFieldPtrHeadStringTagMapOnly opType = 355 - opStructFieldPtrAnonymousHeadMap opType = 356 - opStructFieldPtrAnonymousHeadMapOnly opType = 357 - opStructFieldPtrAnonymousHeadOmitEmptyMap opType = 358 - opStructFieldPtrAnonymousHeadOmitEmptyMapOnly opType = 359 - opStructFieldPtrAnonymousHeadStringTagMap opType = 360 - opStructFieldPtrAnonymousHeadStringTagMapOnly opType = 361 - opStructFieldNPtrHeadMap opType = 362 - opStructFieldNPtrHeadMapOnly opType = 363 - opStructFieldNPtrHeadOmitEmptyMap opType = 364 - opStructFieldNPtrHeadOmitEmptyMapOnly opType = 365 - opStructFieldNPtrHeadStringTagMap opType = 366 - opStructFieldNPtrHeadStringTagMapOnly opType = 367 - opStructFieldNPtrAnonymousHeadMap opType = 368 - opStructFieldNPtrAnonymousHeadMapOnly opType = 369 - opStructFieldNPtrAnonymousHeadOmitEmptyMap opType = 370 - opStructFieldNPtrAnonymousHeadOmitEmptyMapOnly opType = 371 - opStructFieldNPtrAnonymousHeadStringTagMap opType = 372 - opStructFieldNPtrAnonymousHeadStringTagMapOnly opType = 373 - opStructFieldHeadMapLoad opType = 374 - opStructFieldHeadMapLoadOnly opType = 375 - opStructFieldHeadOmitEmptyMapLoad opType = 376 - opStructFieldHeadOmitEmptyMapLoadOnly opType = 377 - opStructFieldHeadStringTagMapLoad opType = 378 - opStructFieldHeadStringTagMapLoadOnly opType = 379 - opStructFieldAnonymousHeadMapLoad opType = 380 - opStructFieldAnonymousHeadMapLoadOnly opType = 381 - opStructFieldAnonymousHeadOmitEmptyMapLoad opType = 382 - opStructFieldAnonymousHeadOmitEmptyMapLoadOnly opType = 383 - opStructFieldAnonymousHeadStringTagMapLoad opType = 384 - opStructFieldAnonymousHeadStringTagMapLoadOnly opType = 385 - opStructFieldPtrHeadMapLoad opType = 386 - opStructFieldPtrHeadMapLoadOnly opType = 387 - opStructFieldPtrHeadOmitEmptyMapLoad opType = 388 - opStructFieldPtrHeadOmitEmptyMapLoadOnly opType = 389 - opStructFieldPtrHeadStringTagMapLoad opType = 390 - opStructFieldPtrHeadStringTagMapLoadOnly opType = 391 - opStructFieldPtrAnonymousHeadMapLoad opType = 392 - opStructFieldPtrAnonymousHeadMapLoadOnly opType = 393 - opStructFieldPtrAnonymousHeadOmitEmptyMapLoad opType = 394 - opStructFieldPtrAnonymousHeadOmitEmptyMapLoadOnly opType = 395 - opStructFieldPtrAnonymousHeadStringTagMapLoad opType = 396 - opStructFieldPtrAnonymousHeadStringTagMapLoadOnly opType = 397 - opStructFieldNPtrHeadMapLoad opType = 398 - opStructFieldNPtrHeadMapLoadOnly opType = 399 - opStructFieldNPtrHeadOmitEmptyMapLoad opType = 400 - opStructFieldNPtrHeadOmitEmptyMapLoadOnly opType = 401 - opStructFieldNPtrHeadStringTagMapLoad opType = 402 - opStructFieldNPtrHeadStringTagMapLoadOnly opType = 403 - opStructFieldNPtrAnonymousHeadMapLoad opType = 404 - opStructFieldNPtrAnonymousHeadMapLoadOnly opType = 405 - opStructFieldNPtrAnonymousHeadOmitEmptyMapLoad opType = 406 - opStructFieldNPtrAnonymousHeadOmitEmptyMapLoadOnly opType = 407 - opStructFieldNPtrAnonymousHeadStringTagMapLoad opType = 408 - opStructFieldNPtrAnonymousHeadStringTagMapLoadOnly opType = 409 - opStructFieldHeadSlice opType = 410 - opStructFieldHeadSliceOnly opType = 411 - opStructFieldHeadOmitEmptySlice opType = 412 - opStructFieldHeadOmitEmptySliceOnly opType = 413 - opStructFieldHeadStringTagSlice opType = 414 - opStructFieldHeadStringTagSliceOnly opType = 415 - opStructFieldAnonymousHeadSlice opType = 416 - opStructFieldAnonymousHeadSliceOnly opType = 417 - opStructFieldAnonymousHeadOmitEmptySlice opType = 418 - opStructFieldAnonymousHeadOmitEmptySliceOnly opType = 419 - opStructFieldAnonymousHeadStringTagSlice opType = 420 - opStructFieldAnonymousHeadStringTagSliceOnly opType = 421 - opStructFieldPtrHeadSlice opType = 422 - opStructFieldPtrHeadSliceOnly opType = 423 - opStructFieldPtrHeadOmitEmptySlice opType = 424 - opStructFieldPtrHeadOmitEmptySliceOnly opType = 425 - opStructFieldPtrHeadStringTagSlice opType = 426 - opStructFieldPtrHeadStringTagSliceOnly opType = 427 - opStructFieldPtrAnonymousHeadSlice opType = 428 - opStructFieldPtrAnonymousHeadSliceOnly opType = 429 - opStructFieldPtrAnonymousHeadOmitEmptySlice opType = 430 - opStructFieldPtrAnonymousHeadOmitEmptySliceOnly opType = 431 - opStructFieldPtrAnonymousHeadStringTagSlice opType = 432 - opStructFieldPtrAnonymousHeadStringTagSliceOnly opType = 433 - opStructFieldNPtrHeadSlice opType = 434 - opStructFieldNPtrHeadSliceOnly opType = 435 - opStructFieldNPtrHeadOmitEmptySlice opType = 436 - opStructFieldNPtrHeadOmitEmptySliceOnly opType = 437 - opStructFieldNPtrHeadStringTagSlice opType = 438 - opStructFieldNPtrHeadStringTagSliceOnly opType = 439 - opStructFieldNPtrAnonymousHeadSlice opType = 440 - opStructFieldNPtrAnonymousHeadSliceOnly opType = 441 - opStructFieldNPtrAnonymousHeadOmitEmptySlice opType = 442 - opStructFieldNPtrAnonymousHeadOmitEmptySliceOnly opType = 443 - opStructFieldNPtrAnonymousHeadStringTagSlice opType = 444 - opStructFieldNPtrAnonymousHeadStringTagSliceOnly opType = 445 - opStructFieldHeadStruct opType = 446 - opStructFieldHeadStructOnly opType = 447 - opStructFieldHeadOmitEmptyStruct opType = 448 - opStructFieldHeadOmitEmptyStructOnly opType = 449 - opStructFieldHeadStringTagStruct opType = 450 - opStructFieldHeadStringTagStructOnly opType = 451 - opStructFieldAnonymousHeadStruct opType = 452 - opStructFieldAnonymousHeadStructOnly opType = 453 - opStructFieldAnonymousHeadOmitEmptyStruct opType = 454 - opStructFieldAnonymousHeadOmitEmptyStructOnly opType = 455 - opStructFieldAnonymousHeadStringTagStruct opType = 456 - opStructFieldAnonymousHeadStringTagStructOnly opType = 457 - opStructFieldPtrHeadStruct opType = 458 - opStructFieldPtrHeadStructOnly opType = 459 - opStructFieldPtrHeadOmitEmptyStruct opType = 460 - opStructFieldPtrHeadOmitEmptyStructOnly opType = 461 - opStructFieldPtrHeadStringTagStruct opType = 462 - opStructFieldPtrHeadStringTagStructOnly opType = 463 - opStructFieldPtrAnonymousHeadStruct opType = 464 - opStructFieldPtrAnonymousHeadStructOnly opType = 465 - opStructFieldPtrAnonymousHeadOmitEmptyStruct opType = 466 - opStructFieldPtrAnonymousHeadOmitEmptyStructOnly opType = 467 - opStructFieldPtrAnonymousHeadStringTagStruct opType = 468 - opStructFieldPtrAnonymousHeadStringTagStructOnly opType = 469 - opStructFieldNPtrHeadStruct opType = 470 - opStructFieldNPtrHeadStructOnly opType = 471 - opStructFieldNPtrHeadOmitEmptyStruct opType = 472 - opStructFieldNPtrHeadOmitEmptyStructOnly opType = 473 - opStructFieldNPtrHeadStringTagStruct opType = 474 - opStructFieldNPtrHeadStringTagStructOnly opType = 475 - opStructFieldNPtrAnonymousHeadStruct opType = 476 - opStructFieldNPtrAnonymousHeadStructOnly opType = 477 - opStructFieldNPtrAnonymousHeadOmitEmptyStruct opType = 478 - opStructFieldNPtrAnonymousHeadOmitEmptyStructOnly opType = 479 - opStructFieldNPtrAnonymousHeadStringTagStruct opType = 480 - opStructFieldNPtrAnonymousHeadStringTagStructOnly opType = 481 - opStructFieldHeadMarshalJSON opType = 482 - opStructFieldHeadMarshalJSONOnly opType = 483 - opStructFieldHeadOmitEmptyMarshalJSON opType = 484 - opStructFieldHeadOmitEmptyMarshalJSONOnly opType = 485 - opStructFieldHeadStringTagMarshalJSON opType = 486 - opStructFieldHeadStringTagMarshalJSONOnly opType = 487 - opStructFieldAnonymousHeadMarshalJSON opType = 488 - opStructFieldAnonymousHeadMarshalJSONOnly opType = 489 - opStructFieldAnonymousHeadOmitEmptyMarshalJSON opType = 490 - opStructFieldAnonymousHeadOmitEmptyMarshalJSONOnly opType = 491 - opStructFieldAnonymousHeadStringTagMarshalJSON opType = 492 - opStructFieldAnonymousHeadStringTagMarshalJSONOnly opType = 493 - opStructFieldPtrHeadMarshalJSON opType = 494 - opStructFieldPtrHeadMarshalJSONOnly opType = 495 - opStructFieldPtrHeadOmitEmptyMarshalJSON opType = 496 - opStructFieldPtrHeadOmitEmptyMarshalJSONOnly opType = 497 - opStructFieldPtrHeadStringTagMarshalJSON opType = 498 - opStructFieldPtrHeadStringTagMarshalJSONOnly opType = 499 - opStructFieldPtrAnonymousHeadMarshalJSON opType = 500 - opStructFieldPtrAnonymousHeadMarshalJSONOnly opType = 501 - opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON opType = 502 - opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSONOnly opType = 503 - opStructFieldPtrAnonymousHeadStringTagMarshalJSON opType = 504 - opStructFieldPtrAnonymousHeadStringTagMarshalJSONOnly opType = 505 - opStructFieldNPtrHeadMarshalJSON opType = 506 - opStructFieldNPtrHeadMarshalJSONOnly opType = 507 - opStructFieldNPtrHeadOmitEmptyMarshalJSON opType = 508 - opStructFieldNPtrHeadOmitEmptyMarshalJSONOnly opType = 509 - opStructFieldNPtrHeadStringTagMarshalJSON opType = 510 - opStructFieldNPtrHeadStringTagMarshalJSONOnly opType = 511 - opStructFieldNPtrAnonymousHeadMarshalJSON opType = 512 - opStructFieldNPtrAnonymousHeadMarshalJSONOnly opType = 513 - opStructFieldNPtrAnonymousHeadOmitEmptyMarshalJSON opType = 514 - opStructFieldNPtrAnonymousHeadOmitEmptyMarshalJSONOnly opType = 515 - opStructFieldNPtrAnonymousHeadStringTagMarshalJSON opType = 516 - opStructFieldNPtrAnonymousHeadStringTagMarshalJSONOnly opType = 517 - opStructFieldHeadMarshalText opType = 518 - opStructFieldHeadMarshalTextOnly opType = 519 - opStructFieldHeadOmitEmptyMarshalText opType = 520 - opStructFieldHeadOmitEmptyMarshalTextOnly opType = 521 - opStructFieldHeadStringTagMarshalText opType = 522 - opStructFieldHeadStringTagMarshalTextOnly opType = 523 - opStructFieldAnonymousHeadMarshalText opType = 524 - opStructFieldAnonymousHeadMarshalTextOnly opType = 525 - opStructFieldAnonymousHeadOmitEmptyMarshalText opType = 526 - opStructFieldAnonymousHeadOmitEmptyMarshalTextOnly opType = 527 - opStructFieldAnonymousHeadStringTagMarshalText opType = 528 - opStructFieldAnonymousHeadStringTagMarshalTextOnly opType = 529 - opStructFieldPtrHeadMarshalText opType = 530 - opStructFieldPtrHeadMarshalTextOnly opType = 531 - opStructFieldPtrHeadOmitEmptyMarshalText opType = 532 - opStructFieldPtrHeadOmitEmptyMarshalTextOnly opType = 533 - opStructFieldPtrHeadStringTagMarshalText opType = 534 - opStructFieldPtrHeadStringTagMarshalTextOnly opType = 535 - opStructFieldPtrAnonymousHeadMarshalText opType = 536 - opStructFieldPtrAnonymousHeadMarshalTextOnly opType = 537 - opStructFieldPtrAnonymousHeadOmitEmptyMarshalText opType = 538 - opStructFieldPtrAnonymousHeadOmitEmptyMarshalTextOnly opType = 539 - opStructFieldPtrAnonymousHeadStringTagMarshalText opType = 540 - opStructFieldPtrAnonymousHeadStringTagMarshalTextOnly opType = 541 - opStructFieldNPtrHeadMarshalText opType = 542 - opStructFieldNPtrHeadMarshalTextOnly opType = 543 - opStructFieldNPtrHeadOmitEmptyMarshalText opType = 544 - opStructFieldNPtrHeadOmitEmptyMarshalTextOnly opType = 545 - opStructFieldNPtrHeadStringTagMarshalText opType = 546 - opStructFieldNPtrHeadStringTagMarshalTextOnly opType = 547 - opStructFieldNPtrAnonymousHeadMarshalText opType = 548 - opStructFieldNPtrAnonymousHeadMarshalTextOnly opType = 549 - opStructFieldNPtrAnonymousHeadOmitEmptyMarshalText opType = 550 - opStructFieldNPtrAnonymousHeadOmitEmptyMarshalTextOnly opType = 551 - opStructFieldNPtrAnonymousHeadStringTagMarshalText opType = 552 - opStructFieldNPtrAnonymousHeadStringTagMarshalTextOnly opType = 553 - opStructFieldHeadRecursive opType = 554 - opStructFieldHeadRecursiveOnly opType = 555 - opStructFieldHeadOmitEmptyRecursive opType = 556 - opStructFieldHeadOmitEmptyRecursiveOnly opType = 557 - opStructFieldHeadStringTagRecursive opType = 558 - opStructFieldHeadStringTagRecursiveOnly opType = 559 - opStructFieldAnonymousHeadRecursive opType = 560 - opStructFieldAnonymousHeadRecursiveOnly opType = 561 - opStructFieldAnonymousHeadOmitEmptyRecursive opType = 562 - opStructFieldAnonymousHeadOmitEmptyRecursiveOnly opType = 563 - opStructFieldAnonymousHeadStringTagRecursive opType = 564 - opStructFieldAnonymousHeadStringTagRecursiveOnly opType = 565 - opStructFieldPtrHeadRecursive opType = 566 - opStructFieldPtrHeadRecursiveOnly opType = 567 - opStructFieldPtrHeadOmitEmptyRecursive opType = 568 - opStructFieldPtrHeadOmitEmptyRecursiveOnly opType = 569 - opStructFieldPtrHeadStringTagRecursive opType = 570 - opStructFieldPtrHeadStringTagRecursiveOnly opType = 571 - opStructFieldPtrAnonymousHeadRecursive opType = 572 - opStructFieldPtrAnonymousHeadRecursiveOnly opType = 573 - opStructFieldPtrAnonymousHeadOmitEmptyRecursive opType = 574 - opStructFieldPtrAnonymousHeadOmitEmptyRecursiveOnly opType = 575 - opStructFieldPtrAnonymousHeadStringTagRecursive opType = 576 - opStructFieldPtrAnonymousHeadStringTagRecursiveOnly opType = 577 - opStructFieldNPtrHeadRecursive opType = 578 - opStructFieldNPtrHeadRecursiveOnly opType = 579 - opStructFieldNPtrHeadOmitEmptyRecursive opType = 580 - opStructFieldNPtrHeadOmitEmptyRecursiveOnly opType = 581 - opStructFieldNPtrHeadStringTagRecursive opType = 582 - opStructFieldNPtrHeadStringTagRecursiveOnly opType = 583 - opStructFieldNPtrAnonymousHeadRecursive opType = 584 - opStructFieldNPtrAnonymousHeadRecursiveOnly opType = 585 - opStructFieldNPtrAnonymousHeadOmitEmptyRecursive opType = 586 - opStructFieldNPtrAnonymousHeadOmitEmptyRecursiveOnly opType = 587 - opStructFieldNPtrAnonymousHeadStringTagRecursive opType = 588 - opStructFieldNPtrAnonymousHeadStringTagRecursiveOnly opType = 589 - opStructFieldHeadIntString opType = 590 - opStructFieldHeadIntStringOnly opType = 591 - opStructFieldHeadOmitEmptyIntString opType = 592 - opStructFieldHeadOmitEmptyIntStringOnly opType = 593 - opStructFieldHeadStringTagIntString opType = 594 - opStructFieldHeadStringTagIntStringOnly opType = 595 - opStructFieldAnonymousHeadIntString opType = 596 - opStructFieldAnonymousHeadIntStringOnly opType = 597 - opStructFieldAnonymousHeadOmitEmptyIntString opType = 598 - opStructFieldAnonymousHeadOmitEmptyIntStringOnly opType = 599 - opStructFieldAnonymousHeadStringTagIntString opType = 600 - opStructFieldAnonymousHeadStringTagIntStringOnly opType = 601 - opStructFieldPtrHeadIntString opType = 602 - opStructFieldPtrHeadIntStringOnly opType = 603 - opStructFieldPtrHeadOmitEmptyIntString opType = 604 - opStructFieldPtrHeadOmitEmptyIntStringOnly opType = 605 - opStructFieldPtrHeadStringTagIntString opType = 606 - opStructFieldPtrHeadStringTagIntStringOnly opType = 607 - opStructFieldPtrAnonymousHeadIntString opType = 608 - opStructFieldPtrAnonymousHeadIntStringOnly opType = 609 - opStructFieldPtrAnonymousHeadOmitEmptyIntString opType = 610 - opStructFieldPtrAnonymousHeadOmitEmptyIntStringOnly opType = 611 - opStructFieldPtrAnonymousHeadStringTagIntString opType = 612 - opStructFieldPtrAnonymousHeadStringTagIntStringOnly opType = 613 - opStructFieldNPtrHeadIntString opType = 614 - opStructFieldNPtrHeadIntStringOnly opType = 615 - opStructFieldNPtrHeadOmitEmptyIntString opType = 616 - opStructFieldNPtrHeadOmitEmptyIntStringOnly opType = 617 - opStructFieldNPtrHeadStringTagIntString opType = 618 - opStructFieldNPtrHeadStringTagIntStringOnly opType = 619 - opStructFieldNPtrAnonymousHeadIntString opType = 620 - opStructFieldNPtrAnonymousHeadIntStringOnly opType = 621 - opStructFieldNPtrAnonymousHeadOmitEmptyIntString opType = 622 - opStructFieldNPtrAnonymousHeadOmitEmptyIntStringOnly opType = 623 - opStructFieldNPtrAnonymousHeadStringTagIntString opType = 624 - opStructFieldNPtrAnonymousHeadStringTagIntStringOnly opType = 625 - opStructFieldHeadUintString opType = 626 - opStructFieldHeadUintStringOnly opType = 627 - opStructFieldHeadOmitEmptyUintString opType = 628 - opStructFieldHeadOmitEmptyUintStringOnly opType = 629 - opStructFieldHeadStringTagUintString opType = 630 - opStructFieldHeadStringTagUintStringOnly opType = 631 - opStructFieldAnonymousHeadUintString opType = 632 - opStructFieldAnonymousHeadUintStringOnly opType = 633 - opStructFieldAnonymousHeadOmitEmptyUintString opType = 634 - opStructFieldAnonymousHeadOmitEmptyUintStringOnly opType = 635 - opStructFieldAnonymousHeadStringTagUintString opType = 636 - opStructFieldAnonymousHeadStringTagUintStringOnly opType = 637 - opStructFieldPtrHeadUintString opType = 638 - opStructFieldPtrHeadUintStringOnly opType = 639 - opStructFieldPtrHeadOmitEmptyUintString opType = 640 - opStructFieldPtrHeadOmitEmptyUintStringOnly opType = 641 - opStructFieldPtrHeadStringTagUintString opType = 642 - opStructFieldPtrHeadStringTagUintStringOnly opType = 643 - opStructFieldPtrAnonymousHeadUintString opType = 644 - opStructFieldPtrAnonymousHeadUintStringOnly opType = 645 - opStructFieldPtrAnonymousHeadOmitEmptyUintString opType = 646 - opStructFieldPtrAnonymousHeadOmitEmptyUintStringOnly opType = 647 - opStructFieldPtrAnonymousHeadStringTagUintString opType = 648 - opStructFieldPtrAnonymousHeadStringTagUintStringOnly opType = 649 - opStructFieldNPtrHeadUintString opType = 650 - opStructFieldNPtrHeadUintStringOnly opType = 651 - opStructFieldNPtrHeadOmitEmptyUintString opType = 652 - opStructFieldNPtrHeadOmitEmptyUintStringOnly opType = 653 - opStructFieldNPtrHeadStringTagUintString opType = 654 - opStructFieldNPtrHeadStringTagUintStringOnly opType = 655 - opStructFieldNPtrAnonymousHeadUintString opType = 656 - opStructFieldNPtrAnonymousHeadUintStringOnly opType = 657 - opStructFieldNPtrAnonymousHeadOmitEmptyUintString opType = 658 - opStructFieldNPtrAnonymousHeadOmitEmptyUintStringOnly opType = 659 - opStructFieldNPtrAnonymousHeadStringTagUintString opType = 660 - opStructFieldNPtrAnonymousHeadStringTagUintStringOnly opType = 661 - opStructFieldHeadIntPtr opType = 662 - opStructFieldHeadIntPtrOnly opType = 663 - opStructFieldHeadOmitEmptyIntPtr opType = 664 - opStructFieldHeadOmitEmptyIntPtrOnly opType = 665 - opStructFieldHeadStringTagIntPtr opType = 666 - opStructFieldHeadStringTagIntPtrOnly opType = 667 - opStructFieldAnonymousHeadIntPtr opType = 668 - opStructFieldAnonymousHeadIntPtrOnly opType = 669 - opStructFieldAnonymousHeadOmitEmptyIntPtr opType = 670 - opStructFieldAnonymousHeadOmitEmptyIntPtrOnly opType = 671 - opStructFieldAnonymousHeadStringTagIntPtr opType = 672 - opStructFieldAnonymousHeadStringTagIntPtrOnly opType = 673 - opStructFieldPtrHeadIntPtr opType = 674 - opStructFieldPtrHeadIntPtrOnly opType = 675 - opStructFieldPtrHeadOmitEmptyIntPtr opType = 676 - opStructFieldPtrHeadOmitEmptyIntPtrOnly opType = 677 - opStructFieldPtrHeadStringTagIntPtr opType = 678 - opStructFieldPtrHeadStringTagIntPtrOnly opType = 679 - opStructFieldPtrAnonymousHeadIntPtr opType = 680 - opStructFieldPtrAnonymousHeadIntPtrOnly opType = 681 - opStructFieldPtrAnonymousHeadOmitEmptyIntPtr opType = 682 - opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly opType = 683 - opStructFieldPtrAnonymousHeadStringTagIntPtr opType = 684 - opStructFieldPtrAnonymousHeadStringTagIntPtrOnly opType = 685 - opStructFieldNPtrHeadIntPtr opType = 686 - opStructFieldNPtrHeadIntPtrOnly opType = 687 - opStructFieldNPtrHeadOmitEmptyIntPtr opType = 688 - opStructFieldNPtrHeadOmitEmptyIntPtrOnly opType = 689 - opStructFieldNPtrHeadStringTagIntPtr opType = 690 - opStructFieldNPtrHeadStringTagIntPtrOnly opType = 691 - opStructFieldNPtrAnonymousHeadIntPtr opType = 692 - opStructFieldNPtrAnonymousHeadIntPtrOnly opType = 693 - opStructFieldNPtrAnonymousHeadOmitEmptyIntPtr opType = 694 - opStructFieldNPtrAnonymousHeadOmitEmptyIntPtrOnly opType = 695 - opStructFieldNPtrAnonymousHeadStringTagIntPtr opType = 696 - opStructFieldNPtrAnonymousHeadStringTagIntPtrOnly opType = 697 - opStructFieldHeadUintPtr opType = 698 - opStructFieldHeadUintPtrOnly opType = 699 - opStructFieldHeadOmitEmptyUintPtr opType = 700 - opStructFieldHeadOmitEmptyUintPtrOnly opType = 701 - opStructFieldHeadStringTagUintPtr opType = 702 - opStructFieldHeadStringTagUintPtrOnly opType = 703 - opStructFieldAnonymousHeadUintPtr opType = 704 - opStructFieldAnonymousHeadUintPtrOnly opType = 705 - opStructFieldAnonymousHeadOmitEmptyUintPtr opType = 706 - opStructFieldAnonymousHeadOmitEmptyUintPtrOnly opType = 707 - opStructFieldAnonymousHeadStringTagUintPtr opType = 708 - opStructFieldAnonymousHeadStringTagUintPtrOnly opType = 709 - opStructFieldPtrHeadUintPtr opType = 710 - opStructFieldPtrHeadUintPtrOnly opType = 711 - opStructFieldPtrHeadOmitEmptyUintPtr opType = 712 - opStructFieldPtrHeadOmitEmptyUintPtrOnly opType = 713 - opStructFieldPtrHeadStringTagUintPtr opType = 714 - opStructFieldPtrHeadStringTagUintPtrOnly opType = 715 - opStructFieldPtrAnonymousHeadUintPtr opType = 716 - opStructFieldPtrAnonymousHeadUintPtrOnly opType = 717 - opStructFieldPtrAnonymousHeadOmitEmptyUintPtr opType = 718 - opStructFieldPtrAnonymousHeadOmitEmptyUintPtrOnly opType = 719 - opStructFieldPtrAnonymousHeadStringTagUintPtr opType = 720 - opStructFieldPtrAnonymousHeadStringTagUintPtrOnly opType = 721 - opStructFieldNPtrHeadUintPtr opType = 722 - opStructFieldNPtrHeadUintPtrOnly opType = 723 - opStructFieldNPtrHeadOmitEmptyUintPtr opType = 724 - opStructFieldNPtrHeadOmitEmptyUintPtrOnly opType = 725 - opStructFieldNPtrHeadStringTagUintPtr opType = 726 - opStructFieldNPtrHeadStringTagUintPtrOnly opType = 727 - opStructFieldNPtrAnonymousHeadUintPtr opType = 728 - opStructFieldNPtrAnonymousHeadUintPtrOnly opType = 729 - opStructFieldNPtrAnonymousHeadOmitEmptyUintPtr opType = 730 - opStructFieldNPtrAnonymousHeadOmitEmptyUintPtrOnly opType = 731 - opStructFieldNPtrAnonymousHeadStringTagUintPtr opType = 732 - opStructFieldNPtrAnonymousHeadStringTagUintPtrOnly opType = 733 - opStructFieldHeadFloat32Ptr opType = 734 - opStructFieldHeadFloat32PtrOnly opType = 735 - opStructFieldHeadOmitEmptyFloat32Ptr opType = 736 - opStructFieldHeadOmitEmptyFloat32PtrOnly opType = 737 - opStructFieldHeadStringTagFloat32Ptr opType = 738 - opStructFieldHeadStringTagFloat32PtrOnly opType = 739 - opStructFieldAnonymousHeadFloat32Ptr opType = 740 - opStructFieldAnonymousHeadFloat32PtrOnly opType = 741 - opStructFieldAnonymousHeadOmitEmptyFloat32Ptr opType = 742 - opStructFieldAnonymousHeadOmitEmptyFloat32PtrOnly opType = 743 - opStructFieldAnonymousHeadStringTagFloat32Ptr opType = 744 - opStructFieldAnonymousHeadStringTagFloat32PtrOnly opType = 745 - opStructFieldPtrHeadFloat32Ptr opType = 746 - opStructFieldPtrHeadFloat32PtrOnly opType = 747 - opStructFieldPtrHeadOmitEmptyFloat32Ptr opType = 748 - opStructFieldPtrHeadOmitEmptyFloat32PtrOnly opType = 749 - opStructFieldPtrHeadStringTagFloat32Ptr opType = 750 - opStructFieldPtrHeadStringTagFloat32PtrOnly opType = 751 - opStructFieldPtrAnonymousHeadFloat32Ptr opType = 752 - opStructFieldPtrAnonymousHeadFloat32PtrOnly opType = 753 - opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr opType = 754 - opStructFieldPtrAnonymousHeadOmitEmptyFloat32PtrOnly opType = 755 - opStructFieldPtrAnonymousHeadStringTagFloat32Ptr opType = 756 - opStructFieldPtrAnonymousHeadStringTagFloat32PtrOnly opType = 757 - opStructFieldNPtrHeadFloat32Ptr opType = 758 - opStructFieldNPtrHeadFloat32PtrOnly opType = 759 - opStructFieldNPtrHeadOmitEmptyFloat32Ptr opType = 760 - opStructFieldNPtrHeadOmitEmptyFloat32PtrOnly opType = 761 - opStructFieldNPtrHeadStringTagFloat32Ptr opType = 762 - opStructFieldNPtrHeadStringTagFloat32PtrOnly opType = 763 - opStructFieldNPtrAnonymousHeadFloat32Ptr opType = 764 - opStructFieldNPtrAnonymousHeadFloat32PtrOnly opType = 765 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat32Ptr opType = 766 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat32PtrOnly opType = 767 - opStructFieldNPtrAnonymousHeadStringTagFloat32Ptr opType = 768 - opStructFieldNPtrAnonymousHeadStringTagFloat32PtrOnly opType = 769 - opStructFieldHeadFloat64Ptr opType = 770 - opStructFieldHeadFloat64PtrOnly opType = 771 - opStructFieldHeadOmitEmptyFloat64Ptr opType = 772 - opStructFieldHeadOmitEmptyFloat64PtrOnly opType = 773 - opStructFieldHeadStringTagFloat64Ptr opType = 774 - opStructFieldHeadStringTagFloat64PtrOnly opType = 775 - opStructFieldAnonymousHeadFloat64Ptr opType = 776 - opStructFieldAnonymousHeadFloat64PtrOnly opType = 777 - opStructFieldAnonymousHeadOmitEmptyFloat64Ptr opType = 778 - opStructFieldAnonymousHeadOmitEmptyFloat64PtrOnly opType = 779 - opStructFieldAnonymousHeadStringTagFloat64Ptr opType = 780 - opStructFieldAnonymousHeadStringTagFloat64PtrOnly opType = 781 - opStructFieldPtrHeadFloat64Ptr opType = 782 - opStructFieldPtrHeadFloat64PtrOnly opType = 783 - opStructFieldPtrHeadOmitEmptyFloat64Ptr opType = 784 - opStructFieldPtrHeadOmitEmptyFloat64PtrOnly opType = 785 - opStructFieldPtrHeadStringTagFloat64Ptr opType = 786 - opStructFieldPtrHeadStringTagFloat64PtrOnly opType = 787 - opStructFieldPtrAnonymousHeadFloat64Ptr opType = 788 - opStructFieldPtrAnonymousHeadFloat64PtrOnly opType = 789 - opStructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr opType = 790 - opStructFieldPtrAnonymousHeadOmitEmptyFloat64PtrOnly opType = 791 - opStructFieldPtrAnonymousHeadStringTagFloat64Ptr opType = 792 - opStructFieldPtrAnonymousHeadStringTagFloat64PtrOnly opType = 793 - opStructFieldNPtrHeadFloat64Ptr opType = 794 - opStructFieldNPtrHeadFloat64PtrOnly opType = 795 - opStructFieldNPtrHeadOmitEmptyFloat64Ptr opType = 796 - opStructFieldNPtrHeadOmitEmptyFloat64PtrOnly opType = 797 - opStructFieldNPtrHeadStringTagFloat64Ptr opType = 798 - opStructFieldNPtrHeadStringTagFloat64PtrOnly opType = 799 - opStructFieldNPtrAnonymousHeadFloat64Ptr opType = 800 - opStructFieldNPtrAnonymousHeadFloat64PtrOnly opType = 801 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat64Ptr opType = 802 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat64PtrOnly opType = 803 - opStructFieldNPtrAnonymousHeadStringTagFloat64Ptr opType = 804 - opStructFieldNPtrAnonymousHeadStringTagFloat64PtrOnly opType = 805 - opStructFieldHeadBoolPtr opType = 806 - opStructFieldHeadBoolPtrOnly opType = 807 - opStructFieldHeadOmitEmptyBoolPtr opType = 808 - opStructFieldHeadOmitEmptyBoolPtrOnly opType = 809 - opStructFieldHeadStringTagBoolPtr opType = 810 - opStructFieldHeadStringTagBoolPtrOnly opType = 811 - opStructFieldAnonymousHeadBoolPtr opType = 812 - opStructFieldAnonymousHeadBoolPtrOnly opType = 813 - opStructFieldAnonymousHeadOmitEmptyBoolPtr opType = 814 - opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly opType = 815 - opStructFieldAnonymousHeadStringTagBoolPtr opType = 816 - opStructFieldAnonymousHeadStringTagBoolPtrOnly opType = 817 - opStructFieldPtrHeadBoolPtr opType = 818 - opStructFieldPtrHeadBoolPtrOnly opType = 819 - opStructFieldPtrHeadOmitEmptyBoolPtr opType = 820 - opStructFieldPtrHeadOmitEmptyBoolPtrOnly opType = 821 - opStructFieldPtrHeadStringTagBoolPtr opType = 822 - opStructFieldPtrHeadStringTagBoolPtrOnly opType = 823 - opStructFieldPtrAnonymousHeadBoolPtr opType = 824 - opStructFieldPtrAnonymousHeadBoolPtrOnly opType = 825 - opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr opType = 826 - opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly opType = 827 - opStructFieldPtrAnonymousHeadStringTagBoolPtr opType = 828 - opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly opType = 829 - opStructFieldNPtrHeadBoolPtr opType = 830 - opStructFieldNPtrHeadBoolPtrOnly opType = 831 - opStructFieldNPtrHeadOmitEmptyBoolPtr opType = 832 - opStructFieldNPtrHeadOmitEmptyBoolPtrOnly opType = 833 - opStructFieldNPtrHeadStringTagBoolPtr opType = 834 - opStructFieldNPtrHeadStringTagBoolPtrOnly opType = 835 - opStructFieldNPtrAnonymousHeadBoolPtr opType = 836 - opStructFieldNPtrAnonymousHeadBoolPtrOnly opType = 837 - opStructFieldNPtrAnonymousHeadOmitEmptyBoolPtr opType = 838 - opStructFieldNPtrAnonymousHeadOmitEmptyBoolPtrOnly opType = 839 - opStructFieldNPtrAnonymousHeadStringTagBoolPtr opType = 840 - opStructFieldNPtrAnonymousHeadStringTagBoolPtrOnly opType = 841 - opStructFieldHeadStringPtr opType = 842 - opStructFieldHeadStringPtrOnly opType = 843 - opStructFieldHeadOmitEmptyStringPtr opType = 844 - opStructFieldHeadOmitEmptyStringPtrOnly opType = 845 - opStructFieldHeadStringTagStringPtr opType = 846 - opStructFieldHeadStringTagStringPtrOnly opType = 847 - opStructFieldAnonymousHeadStringPtr opType = 848 - opStructFieldAnonymousHeadStringPtrOnly opType = 849 - opStructFieldAnonymousHeadOmitEmptyStringPtr opType = 850 - opStructFieldAnonymousHeadOmitEmptyStringPtrOnly opType = 851 - opStructFieldAnonymousHeadStringTagStringPtr opType = 852 - opStructFieldAnonymousHeadStringTagStringPtrOnly opType = 853 - opStructFieldPtrHeadStringPtr opType = 854 - opStructFieldPtrHeadStringPtrOnly opType = 855 - opStructFieldPtrHeadOmitEmptyStringPtr opType = 856 - opStructFieldPtrHeadOmitEmptyStringPtrOnly opType = 857 - opStructFieldPtrHeadStringTagStringPtr opType = 858 - opStructFieldPtrHeadStringTagStringPtrOnly opType = 859 - opStructFieldPtrAnonymousHeadStringPtr opType = 860 - opStructFieldPtrAnonymousHeadStringPtrOnly opType = 861 - opStructFieldPtrAnonymousHeadOmitEmptyStringPtr opType = 862 - opStructFieldPtrAnonymousHeadOmitEmptyStringPtrOnly opType = 863 - opStructFieldPtrAnonymousHeadStringTagStringPtr opType = 864 - opStructFieldPtrAnonymousHeadStringTagStringPtrOnly opType = 865 - opStructFieldNPtrHeadStringPtr opType = 866 - opStructFieldNPtrHeadStringPtrOnly opType = 867 - opStructFieldNPtrHeadOmitEmptyStringPtr opType = 868 - opStructFieldNPtrHeadOmitEmptyStringPtrOnly opType = 869 - opStructFieldNPtrHeadStringTagStringPtr opType = 870 - opStructFieldNPtrHeadStringTagStringPtrOnly opType = 871 - opStructFieldNPtrAnonymousHeadStringPtr opType = 872 - opStructFieldNPtrAnonymousHeadStringPtrOnly opType = 873 - opStructFieldNPtrAnonymousHeadOmitEmptyStringPtr opType = 874 - opStructFieldNPtrAnonymousHeadOmitEmptyStringPtrOnly opType = 875 - opStructFieldNPtrAnonymousHeadStringTagStringPtr opType = 876 - opStructFieldNPtrAnonymousHeadStringTagStringPtrOnly opType = 877 - opStructFieldHeadBytesPtr opType = 878 - opStructFieldHeadBytesPtrOnly opType = 879 - opStructFieldHeadOmitEmptyBytesPtr opType = 880 - opStructFieldHeadOmitEmptyBytesPtrOnly opType = 881 - opStructFieldHeadStringTagBytesPtr opType = 882 - opStructFieldHeadStringTagBytesPtrOnly opType = 883 - opStructFieldAnonymousHeadBytesPtr opType = 884 - opStructFieldAnonymousHeadBytesPtrOnly opType = 885 - opStructFieldAnonymousHeadOmitEmptyBytesPtr opType = 886 - opStructFieldAnonymousHeadOmitEmptyBytesPtrOnly opType = 887 - opStructFieldAnonymousHeadStringTagBytesPtr opType = 888 - opStructFieldAnonymousHeadStringTagBytesPtrOnly opType = 889 - opStructFieldPtrHeadBytesPtr opType = 890 - opStructFieldPtrHeadBytesPtrOnly opType = 891 - opStructFieldPtrHeadOmitEmptyBytesPtr opType = 892 - opStructFieldPtrHeadOmitEmptyBytesPtrOnly opType = 893 - opStructFieldPtrHeadStringTagBytesPtr opType = 894 - opStructFieldPtrHeadStringTagBytesPtrOnly opType = 895 - opStructFieldPtrAnonymousHeadBytesPtr opType = 896 - opStructFieldPtrAnonymousHeadBytesPtrOnly opType = 897 - opStructFieldPtrAnonymousHeadOmitEmptyBytesPtr opType = 898 - opStructFieldPtrAnonymousHeadOmitEmptyBytesPtrOnly opType = 899 - opStructFieldPtrAnonymousHeadStringTagBytesPtr opType = 900 - opStructFieldPtrAnonymousHeadStringTagBytesPtrOnly opType = 901 - opStructFieldNPtrHeadBytesPtr opType = 902 - opStructFieldNPtrHeadBytesPtrOnly opType = 903 - opStructFieldNPtrHeadOmitEmptyBytesPtr opType = 904 - opStructFieldNPtrHeadOmitEmptyBytesPtrOnly opType = 905 - opStructFieldNPtrHeadStringTagBytesPtr opType = 906 - opStructFieldNPtrHeadStringTagBytesPtrOnly opType = 907 - opStructFieldNPtrAnonymousHeadBytesPtr opType = 908 - opStructFieldNPtrAnonymousHeadBytesPtrOnly opType = 909 - opStructFieldNPtrAnonymousHeadOmitEmptyBytesPtr opType = 910 - opStructFieldNPtrAnonymousHeadOmitEmptyBytesPtrOnly opType = 911 - opStructFieldNPtrAnonymousHeadStringTagBytesPtr opType = 912 - opStructFieldNPtrAnonymousHeadStringTagBytesPtrOnly opType = 913 - opStructFieldHeadIntNPtr opType = 914 - opStructFieldHeadIntNPtrOnly opType = 915 - opStructFieldHeadOmitEmptyIntNPtr opType = 916 - opStructFieldHeadOmitEmptyIntNPtrOnly opType = 917 - opStructFieldHeadStringTagIntNPtr opType = 918 - opStructFieldHeadStringTagIntNPtrOnly opType = 919 - opStructFieldAnonymousHeadIntNPtr opType = 920 - opStructFieldAnonymousHeadIntNPtrOnly opType = 921 - opStructFieldAnonymousHeadOmitEmptyIntNPtr opType = 922 - opStructFieldAnonymousHeadOmitEmptyIntNPtrOnly opType = 923 - opStructFieldAnonymousHeadStringTagIntNPtr opType = 924 - opStructFieldAnonymousHeadStringTagIntNPtrOnly opType = 925 - opStructFieldPtrHeadIntNPtr opType = 926 - opStructFieldPtrHeadIntNPtrOnly opType = 927 - opStructFieldPtrHeadOmitEmptyIntNPtr opType = 928 - opStructFieldPtrHeadOmitEmptyIntNPtrOnly opType = 929 - opStructFieldPtrHeadStringTagIntNPtr opType = 930 - opStructFieldPtrHeadStringTagIntNPtrOnly opType = 931 - opStructFieldPtrAnonymousHeadIntNPtr opType = 932 - opStructFieldPtrAnonymousHeadIntNPtrOnly opType = 933 - opStructFieldPtrAnonymousHeadOmitEmptyIntNPtr opType = 934 - opStructFieldPtrAnonymousHeadOmitEmptyIntNPtrOnly opType = 935 - opStructFieldPtrAnonymousHeadStringTagIntNPtr opType = 936 - opStructFieldPtrAnonymousHeadStringTagIntNPtrOnly opType = 937 - opStructFieldNPtrHeadIntNPtr opType = 938 - opStructFieldNPtrHeadIntNPtrOnly opType = 939 - opStructFieldNPtrHeadOmitEmptyIntNPtr opType = 940 - opStructFieldNPtrHeadOmitEmptyIntNPtrOnly opType = 941 - opStructFieldNPtrHeadStringTagIntNPtr opType = 942 - opStructFieldNPtrHeadStringTagIntNPtrOnly opType = 943 - opStructFieldNPtrAnonymousHeadIntNPtr opType = 944 - opStructFieldNPtrAnonymousHeadIntNPtrOnly opType = 945 - opStructFieldNPtrAnonymousHeadOmitEmptyIntNPtr opType = 946 - opStructFieldNPtrAnonymousHeadOmitEmptyIntNPtrOnly opType = 947 - opStructFieldNPtrAnonymousHeadStringTagIntNPtr opType = 948 - opStructFieldNPtrAnonymousHeadStringTagIntNPtrOnly opType = 949 - opStructFieldHeadUintNPtr opType = 950 - opStructFieldHeadUintNPtrOnly opType = 951 - opStructFieldHeadOmitEmptyUintNPtr opType = 952 - opStructFieldHeadOmitEmptyUintNPtrOnly opType = 953 - opStructFieldHeadStringTagUintNPtr opType = 954 - opStructFieldHeadStringTagUintNPtrOnly opType = 955 - opStructFieldAnonymousHeadUintNPtr opType = 956 - opStructFieldAnonymousHeadUintNPtrOnly opType = 957 - opStructFieldAnonymousHeadOmitEmptyUintNPtr opType = 958 - opStructFieldAnonymousHeadOmitEmptyUintNPtrOnly opType = 959 - opStructFieldAnonymousHeadStringTagUintNPtr opType = 960 - opStructFieldAnonymousHeadStringTagUintNPtrOnly opType = 961 - opStructFieldPtrHeadUintNPtr opType = 962 - opStructFieldPtrHeadUintNPtrOnly opType = 963 - opStructFieldPtrHeadOmitEmptyUintNPtr opType = 964 - opStructFieldPtrHeadOmitEmptyUintNPtrOnly opType = 965 - opStructFieldPtrHeadStringTagUintNPtr opType = 966 - opStructFieldPtrHeadStringTagUintNPtrOnly opType = 967 - opStructFieldPtrAnonymousHeadUintNPtr opType = 968 - opStructFieldPtrAnonymousHeadUintNPtrOnly opType = 969 - opStructFieldPtrAnonymousHeadOmitEmptyUintNPtr opType = 970 - opStructFieldPtrAnonymousHeadOmitEmptyUintNPtrOnly opType = 971 - opStructFieldPtrAnonymousHeadStringTagUintNPtr opType = 972 - opStructFieldPtrAnonymousHeadStringTagUintNPtrOnly opType = 973 - opStructFieldNPtrHeadUintNPtr opType = 974 - opStructFieldNPtrHeadUintNPtrOnly opType = 975 - opStructFieldNPtrHeadOmitEmptyUintNPtr opType = 976 - opStructFieldNPtrHeadOmitEmptyUintNPtrOnly opType = 977 - opStructFieldNPtrHeadStringTagUintNPtr opType = 978 - opStructFieldNPtrHeadStringTagUintNPtrOnly opType = 979 - opStructFieldNPtrAnonymousHeadUintNPtr opType = 980 - opStructFieldNPtrAnonymousHeadUintNPtrOnly opType = 981 - opStructFieldNPtrAnonymousHeadOmitEmptyUintNPtr opType = 982 - opStructFieldNPtrAnonymousHeadOmitEmptyUintNPtrOnly opType = 983 - opStructFieldNPtrAnonymousHeadStringTagUintNPtr opType = 984 - opStructFieldNPtrAnonymousHeadStringTagUintNPtrOnly opType = 985 - opStructFieldHeadFloat32NPtr opType = 986 - opStructFieldHeadFloat32NPtrOnly opType = 987 - opStructFieldHeadOmitEmptyFloat32NPtr opType = 988 - opStructFieldHeadOmitEmptyFloat32NPtrOnly opType = 989 - opStructFieldHeadStringTagFloat32NPtr opType = 990 - opStructFieldHeadStringTagFloat32NPtrOnly opType = 991 - opStructFieldAnonymousHeadFloat32NPtr opType = 992 - opStructFieldAnonymousHeadFloat32NPtrOnly opType = 993 - opStructFieldAnonymousHeadOmitEmptyFloat32NPtr opType = 994 - opStructFieldAnonymousHeadOmitEmptyFloat32NPtrOnly opType = 995 - opStructFieldAnonymousHeadStringTagFloat32NPtr opType = 996 - opStructFieldAnonymousHeadStringTagFloat32NPtrOnly opType = 997 - opStructFieldPtrHeadFloat32NPtr opType = 998 - opStructFieldPtrHeadFloat32NPtrOnly opType = 999 - opStructFieldPtrHeadOmitEmptyFloat32NPtr opType = 1000 - opStructFieldPtrHeadOmitEmptyFloat32NPtrOnly opType = 1001 - opStructFieldPtrHeadStringTagFloat32NPtr opType = 1002 - opStructFieldPtrHeadStringTagFloat32NPtrOnly opType = 1003 - opStructFieldPtrAnonymousHeadFloat32NPtr opType = 1004 - opStructFieldPtrAnonymousHeadFloat32NPtrOnly opType = 1005 - opStructFieldPtrAnonymousHeadOmitEmptyFloat32NPtr opType = 1006 - opStructFieldPtrAnonymousHeadOmitEmptyFloat32NPtrOnly opType = 1007 - opStructFieldPtrAnonymousHeadStringTagFloat32NPtr opType = 1008 - opStructFieldPtrAnonymousHeadStringTagFloat32NPtrOnly opType = 1009 - opStructFieldNPtrHeadFloat32NPtr opType = 1010 - opStructFieldNPtrHeadFloat32NPtrOnly opType = 1011 - opStructFieldNPtrHeadOmitEmptyFloat32NPtr opType = 1012 - opStructFieldNPtrHeadOmitEmptyFloat32NPtrOnly opType = 1013 - opStructFieldNPtrHeadStringTagFloat32NPtr opType = 1014 - opStructFieldNPtrHeadStringTagFloat32NPtrOnly opType = 1015 - opStructFieldNPtrAnonymousHeadFloat32NPtr opType = 1016 - opStructFieldNPtrAnonymousHeadFloat32NPtrOnly opType = 1017 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat32NPtr opType = 1018 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat32NPtrOnly opType = 1019 - opStructFieldNPtrAnonymousHeadStringTagFloat32NPtr opType = 1020 - opStructFieldNPtrAnonymousHeadStringTagFloat32NPtrOnly opType = 1021 - opStructFieldHeadFloat64NPtr opType = 1022 - opStructFieldHeadFloat64NPtrOnly opType = 1023 - opStructFieldHeadOmitEmptyFloat64NPtr opType = 1024 - opStructFieldHeadOmitEmptyFloat64NPtrOnly opType = 1025 - opStructFieldHeadStringTagFloat64NPtr opType = 1026 - opStructFieldHeadStringTagFloat64NPtrOnly opType = 1027 - opStructFieldAnonymousHeadFloat64NPtr opType = 1028 - opStructFieldAnonymousHeadFloat64NPtrOnly opType = 1029 - opStructFieldAnonymousHeadOmitEmptyFloat64NPtr opType = 1030 - opStructFieldAnonymousHeadOmitEmptyFloat64NPtrOnly opType = 1031 - opStructFieldAnonymousHeadStringTagFloat64NPtr opType = 1032 - opStructFieldAnonymousHeadStringTagFloat64NPtrOnly opType = 1033 - opStructFieldPtrHeadFloat64NPtr opType = 1034 - opStructFieldPtrHeadFloat64NPtrOnly opType = 1035 - opStructFieldPtrHeadOmitEmptyFloat64NPtr opType = 1036 - opStructFieldPtrHeadOmitEmptyFloat64NPtrOnly opType = 1037 - opStructFieldPtrHeadStringTagFloat64NPtr opType = 1038 - opStructFieldPtrHeadStringTagFloat64NPtrOnly opType = 1039 - opStructFieldPtrAnonymousHeadFloat64NPtr opType = 1040 - opStructFieldPtrAnonymousHeadFloat64NPtrOnly opType = 1041 - opStructFieldPtrAnonymousHeadOmitEmptyFloat64NPtr opType = 1042 - opStructFieldPtrAnonymousHeadOmitEmptyFloat64NPtrOnly opType = 1043 - opStructFieldPtrAnonymousHeadStringTagFloat64NPtr opType = 1044 - opStructFieldPtrAnonymousHeadStringTagFloat64NPtrOnly opType = 1045 - opStructFieldNPtrHeadFloat64NPtr opType = 1046 - opStructFieldNPtrHeadFloat64NPtrOnly opType = 1047 - opStructFieldNPtrHeadOmitEmptyFloat64NPtr opType = 1048 - opStructFieldNPtrHeadOmitEmptyFloat64NPtrOnly opType = 1049 - opStructFieldNPtrHeadStringTagFloat64NPtr opType = 1050 - opStructFieldNPtrHeadStringTagFloat64NPtrOnly opType = 1051 - opStructFieldNPtrAnonymousHeadFloat64NPtr opType = 1052 - opStructFieldNPtrAnonymousHeadFloat64NPtrOnly opType = 1053 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat64NPtr opType = 1054 - opStructFieldNPtrAnonymousHeadOmitEmptyFloat64NPtrOnly opType = 1055 - opStructFieldNPtrAnonymousHeadStringTagFloat64NPtr opType = 1056 - opStructFieldNPtrAnonymousHeadStringTagFloat64NPtrOnly opType = 1057 - opStructFieldHeadBoolNPtr opType = 1058 - opStructFieldHeadBoolNPtrOnly opType = 1059 - opStructFieldHeadOmitEmptyBoolNPtr opType = 1060 - opStructFieldHeadOmitEmptyBoolNPtrOnly opType = 1061 - opStructFieldHeadStringTagBoolNPtr opType = 1062 - opStructFieldHeadStringTagBoolNPtrOnly opType = 1063 - opStructFieldAnonymousHeadBoolNPtr opType = 1064 - opStructFieldAnonymousHeadBoolNPtrOnly opType = 1065 - opStructFieldAnonymousHeadOmitEmptyBoolNPtr opType = 1066 - opStructFieldAnonymousHeadOmitEmptyBoolNPtrOnly opType = 1067 - opStructFieldAnonymousHeadStringTagBoolNPtr opType = 1068 - opStructFieldAnonymousHeadStringTagBoolNPtrOnly opType = 1069 - opStructFieldPtrHeadBoolNPtr opType = 1070 - opStructFieldPtrHeadBoolNPtrOnly opType = 1071 - opStructFieldPtrHeadOmitEmptyBoolNPtr opType = 1072 - opStructFieldPtrHeadOmitEmptyBoolNPtrOnly opType = 1073 - opStructFieldPtrHeadStringTagBoolNPtr opType = 1074 - opStructFieldPtrHeadStringTagBoolNPtrOnly opType = 1075 - opStructFieldPtrAnonymousHeadBoolNPtr opType = 1076 - opStructFieldPtrAnonymousHeadBoolNPtrOnly opType = 1077 - opStructFieldPtrAnonymousHeadOmitEmptyBoolNPtr opType = 1078 - opStructFieldPtrAnonymousHeadOmitEmptyBoolNPtrOnly opType = 1079 - opStructFieldPtrAnonymousHeadStringTagBoolNPtr opType = 1080 - opStructFieldPtrAnonymousHeadStringTagBoolNPtrOnly opType = 1081 - opStructFieldNPtrHeadBoolNPtr opType = 1082 - opStructFieldNPtrHeadBoolNPtrOnly opType = 1083 - opStructFieldNPtrHeadOmitEmptyBoolNPtr opType = 1084 - opStructFieldNPtrHeadOmitEmptyBoolNPtrOnly opType = 1085 - opStructFieldNPtrHeadStringTagBoolNPtr opType = 1086 - opStructFieldNPtrHeadStringTagBoolNPtrOnly opType = 1087 - opStructFieldNPtrAnonymousHeadBoolNPtr opType = 1088 - opStructFieldNPtrAnonymousHeadBoolNPtrOnly opType = 1089 - opStructFieldNPtrAnonymousHeadOmitEmptyBoolNPtr opType = 1090 - opStructFieldNPtrAnonymousHeadOmitEmptyBoolNPtrOnly opType = 1091 - opStructFieldNPtrAnonymousHeadStringTagBoolNPtr opType = 1092 - opStructFieldNPtrAnonymousHeadStringTagBoolNPtrOnly opType = 1093 - opStructFieldHeadStringNPtr opType = 1094 - opStructFieldHeadStringNPtrOnly opType = 1095 - opStructFieldHeadOmitEmptyStringNPtr opType = 1096 - opStructFieldHeadOmitEmptyStringNPtrOnly opType = 1097 - opStructFieldHeadStringTagStringNPtr opType = 1098 - opStructFieldHeadStringTagStringNPtrOnly opType = 1099 - opStructFieldAnonymousHeadStringNPtr opType = 1100 - opStructFieldAnonymousHeadStringNPtrOnly opType = 1101 - opStructFieldAnonymousHeadOmitEmptyStringNPtr opType = 1102 - opStructFieldAnonymousHeadOmitEmptyStringNPtrOnly opType = 1103 - opStructFieldAnonymousHeadStringTagStringNPtr opType = 1104 - opStructFieldAnonymousHeadStringTagStringNPtrOnly opType = 1105 - opStructFieldPtrHeadStringNPtr opType = 1106 - opStructFieldPtrHeadStringNPtrOnly opType = 1107 - opStructFieldPtrHeadOmitEmptyStringNPtr opType = 1108 - opStructFieldPtrHeadOmitEmptyStringNPtrOnly opType = 1109 - opStructFieldPtrHeadStringTagStringNPtr opType = 1110 - opStructFieldPtrHeadStringTagStringNPtrOnly opType = 1111 - opStructFieldPtrAnonymousHeadStringNPtr opType = 1112 - opStructFieldPtrAnonymousHeadStringNPtrOnly opType = 1113 - opStructFieldPtrAnonymousHeadOmitEmptyStringNPtr opType = 1114 - opStructFieldPtrAnonymousHeadOmitEmptyStringNPtrOnly opType = 1115 - opStructFieldPtrAnonymousHeadStringTagStringNPtr opType = 1116 - opStructFieldPtrAnonymousHeadStringTagStringNPtrOnly opType = 1117 - opStructFieldNPtrHeadStringNPtr opType = 1118 - opStructFieldNPtrHeadStringNPtrOnly opType = 1119 - opStructFieldNPtrHeadOmitEmptyStringNPtr opType = 1120 - opStructFieldNPtrHeadOmitEmptyStringNPtrOnly opType = 1121 - opStructFieldNPtrHeadStringTagStringNPtr opType = 1122 - opStructFieldNPtrHeadStringTagStringNPtrOnly opType = 1123 - opStructFieldNPtrAnonymousHeadStringNPtr opType = 1124 - opStructFieldNPtrAnonymousHeadStringNPtrOnly opType = 1125 - opStructFieldNPtrAnonymousHeadOmitEmptyStringNPtr opType = 1126 - opStructFieldNPtrAnonymousHeadOmitEmptyStringNPtrOnly opType = 1127 - opStructFieldNPtrAnonymousHeadStringTagStringNPtr opType = 1128 - opStructFieldNPtrAnonymousHeadStringTagStringNPtrOnly opType = 1129 - opStructFieldHeadBytesNPtr opType = 1130 - opStructFieldHeadBytesNPtrOnly opType = 1131 - opStructFieldHeadOmitEmptyBytesNPtr opType = 1132 - opStructFieldHeadOmitEmptyBytesNPtrOnly opType = 1133 - opStructFieldHeadStringTagBytesNPtr opType = 1134 - opStructFieldHeadStringTagBytesNPtrOnly opType = 1135 - opStructFieldAnonymousHeadBytesNPtr opType = 1136 - opStructFieldAnonymousHeadBytesNPtrOnly opType = 1137 - opStructFieldAnonymousHeadOmitEmptyBytesNPtr opType = 1138 - opStructFieldAnonymousHeadOmitEmptyBytesNPtrOnly opType = 1139 - opStructFieldAnonymousHeadStringTagBytesNPtr opType = 1140 - opStructFieldAnonymousHeadStringTagBytesNPtrOnly opType = 1141 - opStructFieldPtrHeadBytesNPtr opType = 1142 - opStructFieldPtrHeadBytesNPtrOnly opType = 1143 - opStructFieldPtrHeadOmitEmptyBytesNPtr opType = 1144 - opStructFieldPtrHeadOmitEmptyBytesNPtrOnly opType = 1145 - opStructFieldPtrHeadStringTagBytesNPtr opType = 1146 - opStructFieldPtrHeadStringTagBytesNPtrOnly opType = 1147 - opStructFieldPtrAnonymousHeadBytesNPtr opType = 1148 - opStructFieldPtrAnonymousHeadBytesNPtrOnly opType = 1149 - opStructFieldPtrAnonymousHeadOmitEmptyBytesNPtr opType = 1150 - opStructFieldPtrAnonymousHeadOmitEmptyBytesNPtrOnly opType = 1151 - opStructFieldPtrAnonymousHeadStringTagBytesNPtr opType = 1152 - opStructFieldPtrAnonymousHeadStringTagBytesNPtrOnly opType = 1153 - opStructFieldNPtrHeadBytesNPtr opType = 1154 - opStructFieldNPtrHeadBytesNPtrOnly opType = 1155 - opStructFieldNPtrHeadOmitEmptyBytesNPtr opType = 1156 - opStructFieldNPtrHeadOmitEmptyBytesNPtrOnly opType = 1157 - opStructFieldNPtrHeadStringTagBytesNPtr opType = 1158 - opStructFieldNPtrHeadStringTagBytesNPtrOnly opType = 1159 - opStructFieldNPtrAnonymousHeadBytesNPtr opType = 1160 - opStructFieldNPtrAnonymousHeadBytesNPtrOnly opType = 1161 - opStructFieldNPtrAnonymousHeadOmitEmptyBytesNPtr opType = 1162 - opStructFieldNPtrAnonymousHeadOmitEmptyBytesNPtrOnly opType = 1163 - opStructFieldNPtrAnonymousHeadStringTagBytesNPtr opType = 1164 - opStructFieldNPtrAnonymousHeadStringTagBytesNPtrOnly opType = 1165 - opStructFieldHead opType = 1166 - opStructFieldHeadOnly opType = 1167 - opStructFieldHeadOmitEmpty opType = 1168 - opStructFieldHeadOmitEmptyOnly opType = 1169 - opStructFieldHeadStringTag opType = 1170 - opStructFieldHeadStringTagOnly opType = 1171 - opStructFieldAnonymousHead opType = 1172 - opStructFieldAnonymousHeadOnly opType = 1173 - opStructFieldAnonymousHeadOmitEmpty opType = 1174 - opStructFieldAnonymousHeadOmitEmptyOnly opType = 1175 - opStructFieldAnonymousHeadStringTag opType = 1176 - opStructFieldAnonymousHeadStringTagOnly opType = 1177 - opStructFieldPtrHead opType = 1178 - opStructFieldPtrHeadOnly opType = 1179 - opStructFieldPtrHeadOmitEmpty opType = 1180 - opStructFieldPtrHeadOmitEmptyOnly opType = 1181 - opStructFieldPtrHeadStringTag opType = 1182 - opStructFieldPtrHeadStringTagOnly opType = 1183 - opStructFieldPtrAnonymousHead opType = 1184 - opStructFieldPtrAnonymousHeadOnly opType = 1185 - opStructFieldPtrAnonymousHeadOmitEmpty opType = 1186 - opStructFieldPtrAnonymousHeadOmitEmptyOnly opType = 1187 - opStructFieldPtrAnonymousHeadStringTag opType = 1188 - opStructFieldPtrAnonymousHeadStringTagOnly opType = 1189 - opStructFieldNPtrHead opType = 1190 - opStructFieldNPtrHeadOnly opType = 1191 - opStructFieldNPtrHeadOmitEmpty opType = 1192 - opStructFieldNPtrHeadOmitEmptyOnly opType = 1193 - opStructFieldNPtrHeadStringTag opType = 1194 - opStructFieldNPtrHeadStringTagOnly opType = 1195 - opStructFieldNPtrAnonymousHead opType = 1196 - opStructFieldNPtrAnonymousHeadOnly opType = 1197 - opStructFieldNPtrAnonymousHeadOmitEmpty opType = 1198 - opStructFieldNPtrAnonymousHeadOmitEmptyOnly opType = 1199 - opStructFieldNPtrAnonymousHeadStringTag opType = 1200 - opStructFieldNPtrAnonymousHeadStringTagOnly opType = 1201 - opStructFieldInt opType = 1202 - opStructFieldOmitEmptyInt opType = 1203 - opStructFieldStringTagInt opType = 1204 - opStructFieldUint opType = 1205 - opStructFieldOmitEmptyUint opType = 1206 - opStructFieldStringTagUint opType = 1207 - opStructFieldFloat32 opType = 1208 - opStructFieldOmitEmptyFloat32 opType = 1209 - opStructFieldStringTagFloat32 opType = 1210 - opStructFieldFloat64 opType = 1211 - opStructFieldOmitEmptyFloat64 opType = 1212 - opStructFieldStringTagFloat64 opType = 1213 - opStructFieldBool opType = 1214 - opStructFieldOmitEmptyBool opType = 1215 - opStructFieldStringTagBool opType = 1216 - opStructFieldString opType = 1217 - opStructFieldOmitEmptyString opType = 1218 - opStructFieldStringTagString opType = 1219 - opStructFieldBytes opType = 1220 - opStructFieldOmitEmptyBytes opType = 1221 - opStructFieldStringTagBytes opType = 1222 - opStructFieldArray opType = 1223 - opStructFieldOmitEmptyArray opType = 1224 - opStructFieldStringTagArray opType = 1225 - opStructFieldMap opType = 1226 - opStructFieldOmitEmptyMap opType = 1227 - opStructFieldStringTagMap opType = 1228 - opStructFieldMapLoad opType = 1229 - opStructFieldOmitEmptyMapLoad opType = 1230 - opStructFieldStringTagMapLoad opType = 1231 - opStructFieldSlice opType = 1232 - opStructFieldOmitEmptySlice opType = 1233 - opStructFieldStringTagSlice opType = 1234 - opStructFieldStruct opType = 1235 - opStructFieldOmitEmptyStruct opType = 1236 - opStructFieldStringTagStruct opType = 1237 - opStructFieldMarshalJSON opType = 1238 - opStructFieldOmitEmptyMarshalJSON opType = 1239 - opStructFieldStringTagMarshalJSON opType = 1240 - opStructFieldMarshalText opType = 1241 - opStructFieldOmitEmptyMarshalText opType = 1242 - opStructFieldStringTagMarshalText opType = 1243 - opStructFieldRecursive opType = 1244 - opStructFieldOmitEmptyRecursive opType = 1245 - opStructFieldStringTagRecursive opType = 1246 - opStructFieldIntString opType = 1247 - opStructFieldOmitEmptyIntString opType = 1248 - opStructFieldStringTagIntString opType = 1249 - opStructFieldUintString opType = 1250 - opStructFieldOmitEmptyUintString opType = 1251 - opStructFieldStringTagUintString opType = 1252 - opStructFieldIntPtr opType = 1253 - opStructFieldOmitEmptyIntPtr opType = 1254 - opStructFieldStringTagIntPtr opType = 1255 - opStructFieldUintPtr opType = 1256 - opStructFieldOmitEmptyUintPtr opType = 1257 - opStructFieldStringTagUintPtr opType = 1258 - opStructFieldFloat32Ptr opType = 1259 - opStructFieldOmitEmptyFloat32Ptr opType = 1260 - opStructFieldStringTagFloat32Ptr opType = 1261 - opStructFieldFloat64Ptr opType = 1262 - opStructFieldOmitEmptyFloat64Ptr opType = 1263 - opStructFieldStringTagFloat64Ptr opType = 1264 - opStructFieldBoolPtr opType = 1265 - opStructFieldOmitEmptyBoolPtr opType = 1266 - opStructFieldStringTagBoolPtr opType = 1267 - opStructFieldStringPtr opType = 1268 - opStructFieldOmitEmptyStringPtr opType = 1269 - opStructFieldStringTagStringPtr opType = 1270 - opStructFieldBytesPtr opType = 1271 - opStructFieldOmitEmptyBytesPtr opType = 1272 - opStructFieldStringTagBytesPtr opType = 1273 - opStructFieldIntNPtr opType = 1274 - opStructFieldOmitEmptyIntNPtr opType = 1275 - opStructFieldStringTagIntNPtr opType = 1276 - opStructFieldUintNPtr opType = 1277 - opStructFieldOmitEmptyUintNPtr opType = 1278 - opStructFieldStringTagUintNPtr opType = 1279 - opStructFieldFloat32NPtr opType = 1280 - opStructFieldOmitEmptyFloat32NPtr opType = 1281 - opStructFieldStringTagFloat32NPtr opType = 1282 - opStructFieldFloat64NPtr opType = 1283 - opStructFieldOmitEmptyFloat64NPtr opType = 1284 - opStructFieldStringTagFloat64NPtr opType = 1285 - opStructFieldBoolNPtr opType = 1286 - opStructFieldOmitEmptyBoolNPtr opType = 1287 - opStructFieldStringTagBoolNPtr opType = 1288 - opStructFieldStringNPtr opType = 1289 - opStructFieldOmitEmptyStringNPtr opType = 1290 - opStructFieldStringTagStringNPtr opType = 1291 - opStructFieldBytesNPtr opType = 1292 - opStructFieldOmitEmptyBytesNPtr opType = 1293 - opStructFieldStringTagBytesNPtr opType = 1294 - opStructField opType = 1295 - opStructFieldOmitEmpty opType = 1296 - opStructFieldStringTag opType = 1297 - opStructEndInt opType = 1298 - opStructEndOmitEmptyInt opType = 1299 - opStructEndStringTagInt opType = 1300 - opStructEndUint opType = 1301 - opStructEndOmitEmptyUint opType = 1302 - opStructEndStringTagUint opType = 1303 - opStructEndFloat32 opType = 1304 - opStructEndOmitEmptyFloat32 opType = 1305 - opStructEndStringTagFloat32 opType = 1306 - opStructEndFloat64 opType = 1307 - opStructEndOmitEmptyFloat64 opType = 1308 - opStructEndStringTagFloat64 opType = 1309 - opStructEndBool opType = 1310 - opStructEndOmitEmptyBool opType = 1311 - opStructEndStringTagBool opType = 1312 - opStructEndString opType = 1313 - opStructEndOmitEmptyString opType = 1314 - opStructEndStringTagString opType = 1315 - opStructEndBytes opType = 1316 - opStructEndOmitEmptyBytes opType = 1317 - opStructEndStringTagBytes opType = 1318 - opStructEndArray opType = 1319 - opStructEndOmitEmptyArray opType = 1320 - opStructEndStringTagArray opType = 1321 - opStructEndMap opType = 1322 - opStructEndOmitEmptyMap opType = 1323 - opStructEndStringTagMap opType = 1324 - opStructEndMapLoad opType = 1325 - opStructEndOmitEmptyMapLoad opType = 1326 - opStructEndStringTagMapLoad opType = 1327 - opStructEndSlice opType = 1328 - opStructEndOmitEmptySlice opType = 1329 - opStructEndStringTagSlice opType = 1330 - opStructEndStruct opType = 1331 - opStructEndOmitEmptyStruct opType = 1332 - opStructEndStringTagStruct opType = 1333 - opStructEndMarshalJSON opType = 1334 - opStructEndOmitEmptyMarshalJSON opType = 1335 - opStructEndStringTagMarshalJSON opType = 1336 - opStructEndMarshalText opType = 1337 - opStructEndOmitEmptyMarshalText opType = 1338 - opStructEndStringTagMarshalText opType = 1339 - opStructEndRecursive opType = 1340 - opStructEndOmitEmptyRecursive opType = 1341 - opStructEndStringTagRecursive opType = 1342 - opStructEndIntString opType = 1343 - opStructEndOmitEmptyIntString opType = 1344 - opStructEndStringTagIntString opType = 1345 - opStructEndUintString opType = 1346 - opStructEndOmitEmptyUintString opType = 1347 - opStructEndStringTagUintString opType = 1348 - opStructEndIntPtr opType = 1349 - opStructEndOmitEmptyIntPtr opType = 1350 - opStructEndStringTagIntPtr opType = 1351 - opStructEndUintPtr opType = 1352 - opStructEndOmitEmptyUintPtr opType = 1353 - opStructEndStringTagUintPtr opType = 1354 - opStructEndFloat32Ptr opType = 1355 - opStructEndOmitEmptyFloat32Ptr opType = 1356 - opStructEndStringTagFloat32Ptr opType = 1357 - opStructEndFloat64Ptr opType = 1358 - opStructEndOmitEmptyFloat64Ptr opType = 1359 - opStructEndStringTagFloat64Ptr opType = 1360 - opStructEndBoolPtr opType = 1361 - opStructEndOmitEmptyBoolPtr opType = 1362 - opStructEndStringTagBoolPtr opType = 1363 - opStructEndStringPtr opType = 1364 - opStructEndOmitEmptyStringPtr opType = 1365 - opStructEndStringTagStringPtr opType = 1366 - opStructEndBytesPtr opType = 1367 - opStructEndOmitEmptyBytesPtr opType = 1368 - opStructEndStringTagBytesPtr opType = 1369 - opStructEndIntNPtr opType = 1370 - opStructEndOmitEmptyIntNPtr opType = 1371 - opStructEndStringTagIntNPtr opType = 1372 - opStructEndUintNPtr opType = 1373 - opStructEndOmitEmptyUintNPtr opType = 1374 - opStructEndStringTagUintNPtr opType = 1375 - opStructEndFloat32NPtr opType = 1376 - opStructEndOmitEmptyFloat32NPtr opType = 1377 - opStructEndStringTagFloat32NPtr opType = 1378 - opStructEndFloat64NPtr opType = 1379 - opStructEndOmitEmptyFloat64NPtr opType = 1380 - opStructEndStringTagFloat64NPtr opType = 1381 - opStructEndBoolNPtr opType = 1382 - opStructEndOmitEmptyBoolNPtr opType = 1383 - opStructEndStringTagBoolNPtr opType = 1384 - opStructEndStringNPtr opType = 1385 - opStructEndOmitEmptyStringNPtr opType = 1386 - opStructEndStringTagStringNPtr opType = 1387 - opStructEndBytesNPtr opType = 1388 - opStructEndOmitEmptyBytesNPtr opType = 1389 - opStructEndStringTagBytesNPtr opType = 1390 - opStructEnd opType = 1391 - opStructEndOmitEmpty opType = 1392 - opStructEndStringTag opType = 1393 + opEnd opType = 0 + opInterface opType = 1 + opPtr opType = 2 + opRootSliceHead opType = 3 + opSliceElem opType = 4 + opRootSliceElem opType = 5 + opSliceEnd opType = 6 + opArrayElem opType = 7 + opArrayEnd opType = 8 + opMapKey opType = 9 + opMapValue opType = 10 + opMapEnd opType = 11 + opStructFieldRecursiveEnd opType = 12 + opStructAnonymousEnd opType = 13 + opInt opType = 14 + opUint opType = 15 + opFloat32 opType = 16 + opFloat64 opType = 17 + opBool opType = 18 + opString opType = 19 + opBytes opType = 20 + opNumber opType = 21 + opArray opType = 22 + opMap opType = 23 + opSlice opType = 24 + opStruct opType = 25 + opMarshalJSON opType = 26 + opMarshalText opType = 27 + opRecursive opType = 28 + opIntString opType = 29 + opUintString opType = 30 + opIntPtr opType = 31 + opUintPtr opType = 32 + opFloat32Ptr opType = 33 + opFloat64Ptr opType = 34 + opBoolPtr opType = 35 + opStringPtr opType = 36 + opBytesPtr opType = 37 + opNumberPtr opType = 38 + opArrayPtr opType = 39 + opMapPtr opType = 40 + opSlicePtr opType = 41 + opMarshalJSONPtr opType = 42 + opMarshalTextPtr opType = 43 + opInterfacePtr opType = 44 + opRecursivePtr opType = 45 + opStructFieldHeadInt opType = 46 + opStructFieldHeadOmitEmptyInt opType = 47 + opStructFieldHeadStringTagInt opType = 48 + opStructFieldPtrHeadInt opType = 49 + opStructFieldPtrHeadOmitEmptyInt opType = 50 + opStructFieldPtrHeadStringTagInt opType = 51 + opStructFieldHeadUint opType = 52 + opStructFieldHeadOmitEmptyUint opType = 53 + opStructFieldHeadStringTagUint opType = 54 + opStructFieldPtrHeadUint opType = 55 + opStructFieldPtrHeadOmitEmptyUint opType = 56 + opStructFieldPtrHeadStringTagUint opType = 57 + opStructFieldHeadFloat32 opType = 58 + opStructFieldHeadOmitEmptyFloat32 opType = 59 + opStructFieldHeadStringTagFloat32 opType = 60 + opStructFieldPtrHeadFloat32 opType = 61 + opStructFieldPtrHeadOmitEmptyFloat32 opType = 62 + opStructFieldPtrHeadStringTagFloat32 opType = 63 + opStructFieldHeadFloat64 opType = 64 + opStructFieldHeadOmitEmptyFloat64 opType = 65 + opStructFieldHeadStringTagFloat64 opType = 66 + opStructFieldPtrHeadFloat64 opType = 67 + opStructFieldPtrHeadOmitEmptyFloat64 opType = 68 + opStructFieldPtrHeadStringTagFloat64 opType = 69 + opStructFieldHeadBool opType = 70 + opStructFieldHeadOmitEmptyBool opType = 71 + opStructFieldHeadStringTagBool opType = 72 + opStructFieldPtrHeadBool opType = 73 + opStructFieldPtrHeadOmitEmptyBool opType = 74 + opStructFieldPtrHeadStringTagBool opType = 75 + opStructFieldHeadString opType = 76 + opStructFieldHeadOmitEmptyString opType = 77 + opStructFieldHeadStringTagString opType = 78 + opStructFieldPtrHeadString opType = 79 + opStructFieldPtrHeadOmitEmptyString opType = 80 + opStructFieldPtrHeadStringTagString opType = 81 + opStructFieldHeadBytes opType = 82 + opStructFieldHeadOmitEmptyBytes opType = 83 + opStructFieldHeadStringTagBytes opType = 84 + opStructFieldPtrHeadBytes opType = 85 + opStructFieldPtrHeadOmitEmptyBytes opType = 86 + opStructFieldPtrHeadStringTagBytes opType = 87 + opStructFieldHeadNumber opType = 88 + opStructFieldHeadOmitEmptyNumber opType = 89 + opStructFieldHeadStringTagNumber opType = 90 + opStructFieldPtrHeadNumber opType = 91 + opStructFieldPtrHeadOmitEmptyNumber opType = 92 + opStructFieldPtrHeadStringTagNumber opType = 93 + opStructFieldHeadArray opType = 94 + opStructFieldHeadOmitEmptyArray opType = 95 + opStructFieldHeadStringTagArray opType = 96 + opStructFieldPtrHeadArray opType = 97 + opStructFieldPtrHeadOmitEmptyArray opType = 98 + opStructFieldPtrHeadStringTagArray opType = 99 + opStructFieldHeadMap opType = 100 + opStructFieldHeadOmitEmptyMap opType = 101 + opStructFieldHeadStringTagMap opType = 102 + opStructFieldPtrHeadMap opType = 103 + opStructFieldPtrHeadOmitEmptyMap opType = 104 + opStructFieldPtrHeadStringTagMap opType = 105 + opStructFieldHeadSlice opType = 106 + opStructFieldHeadOmitEmptySlice opType = 107 + opStructFieldHeadStringTagSlice opType = 108 + opStructFieldPtrHeadSlice opType = 109 + opStructFieldPtrHeadOmitEmptySlice opType = 110 + opStructFieldPtrHeadStringTagSlice opType = 111 + opStructFieldHeadStruct opType = 112 + opStructFieldHeadOmitEmptyStruct opType = 113 + opStructFieldHeadStringTagStruct opType = 114 + opStructFieldPtrHeadStruct opType = 115 + opStructFieldPtrHeadOmitEmptyStruct opType = 116 + opStructFieldPtrHeadStringTagStruct opType = 117 + opStructFieldHeadMarshalJSON opType = 118 + opStructFieldHeadOmitEmptyMarshalJSON opType = 119 + opStructFieldHeadStringTagMarshalJSON opType = 120 + opStructFieldPtrHeadMarshalJSON opType = 121 + opStructFieldPtrHeadOmitEmptyMarshalJSON opType = 122 + opStructFieldPtrHeadStringTagMarshalJSON opType = 123 + opStructFieldHeadMarshalText opType = 124 + opStructFieldHeadOmitEmptyMarshalText opType = 125 + opStructFieldHeadStringTagMarshalText opType = 126 + opStructFieldPtrHeadMarshalText opType = 127 + opStructFieldPtrHeadOmitEmptyMarshalText opType = 128 + opStructFieldPtrHeadStringTagMarshalText opType = 129 + opStructFieldHeadRecursive opType = 130 + opStructFieldHeadOmitEmptyRecursive opType = 131 + opStructFieldHeadStringTagRecursive opType = 132 + opStructFieldPtrHeadRecursive opType = 133 + opStructFieldPtrHeadOmitEmptyRecursive opType = 134 + opStructFieldPtrHeadStringTagRecursive opType = 135 + opStructFieldHeadIntString opType = 136 + opStructFieldHeadOmitEmptyIntString opType = 137 + opStructFieldHeadStringTagIntString opType = 138 + opStructFieldPtrHeadIntString opType = 139 + opStructFieldPtrHeadOmitEmptyIntString opType = 140 + opStructFieldPtrHeadStringTagIntString opType = 141 + opStructFieldHeadUintString opType = 142 + opStructFieldHeadOmitEmptyUintString opType = 143 + opStructFieldHeadStringTagUintString opType = 144 + opStructFieldPtrHeadUintString opType = 145 + opStructFieldPtrHeadOmitEmptyUintString opType = 146 + opStructFieldPtrHeadStringTagUintString opType = 147 + opStructFieldHeadIntPtr opType = 148 + opStructFieldHeadOmitEmptyIntPtr opType = 149 + opStructFieldHeadStringTagIntPtr opType = 150 + opStructFieldPtrHeadIntPtr opType = 151 + opStructFieldPtrHeadOmitEmptyIntPtr opType = 152 + opStructFieldPtrHeadStringTagIntPtr opType = 153 + opStructFieldHeadUintPtr opType = 154 + opStructFieldHeadOmitEmptyUintPtr opType = 155 + opStructFieldHeadStringTagUintPtr opType = 156 + opStructFieldPtrHeadUintPtr opType = 157 + opStructFieldPtrHeadOmitEmptyUintPtr opType = 158 + opStructFieldPtrHeadStringTagUintPtr opType = 159 + opStructFieldHeadFloat32Ptr opType = 160 + opStructFieldHeadOmitEmptyFloat32Ptr opType = 161 + opStructFieldHeadStringTagFloat32Ptr opType = 162 + opStructFieldPtrHeadFloat32Ptr opType = 163 + opStructFieldPtrHeadOmitEmptyFloat32Ptr opType = 164 + opStructFieldPtrHeadStringTagFloat32Ptr opType = 165 + opStructFieldHeadFloat64Ptr opType = 166 + opStructFieldHeadOmitEmptyFloat64Ptr opType = 167 + opStructFieldHeadStringTagFloat64Ptr opType = 168 + opStructFieldPtrHeadFloat64Ptr opType = 169 + opStructFieldPtrHeadOmitEmptyFloat64Ptr opType = 170 + opStructFieldPtrHeadStringTagFloat64Ptr opType = 171 + opStructFieldHeadBoolPtr opType = 172 + opStructFieldHeadOmitEmptyBoolPtr opType = 173 + opStructFieldHeadStringTagBoolPtr opType = 174 + opStructFieldPtrHeadBoolPtr opType = 175 + opStructFieldPtrHeadOmitEmptyBoolPtr opType = 176 + opStructFieldPtrHeadStringTagBoolPtr opType = 177 + opStructFieldHeadStringPtr opType = 178 + opStructFieldHeadOmitEmptyStringPtr opType = 179 + opStructFieldHeadStringTagStringPtr opType = 180 + opStructFieldPtrHeadStringPtr opType = 181 + opStructFieldPtrHeadOmitEmptyStringPtr opType = 182 + opStructFieldPtrHeadStringTagStringPtr opType = 183 + opStructFieldHeadBytesPtr opType = 184 + opStructFieldHeadOmitEmptyBytesPtr opType = 185 + opStructFieldHeadStringTagBytesPtr opType = 186 + opStructFieldPtrHeadBytesPtr opType = 187 + opStructFieldPtrHeadOmitEmptyBytesPtr opType = 188 + opStructFieldPtrHeadStringTagBytesPtr opType = 189 + opStructFieldHeadNumberPtr opType = 190 + opStructFieldHeadOmitEmptyNumberPtr opType = 191 + opStructFieldHeadStringTagNumberPtr opType = 192 + opStructFieldPtrHeadNumberPtr opType = 193 + opStructFieldPtrHeadOmitEmptyNumberPtr opType = 194 + opStructFieldPtrHeadStringTagNumberPtr opType = 195 + opStructFieldHeadArrayPtr opType = 196 + opStructFieldHeadOmitEmptyArrayPtr opType = 197 + opStructFieldHeadStringTagArrayPtr opType = 198 + opStructFieldPtrHeadArrayPtr opType = 199 + opStructFieldPtrHeadOmitEmptyArrayPtr opType = 200 + opStructFieldPtrHeadStringTagArrayPtr opType = 201 + opStructFieldHeadMapPtr opType = 202 + opStructFieldHeadOmitEmptyMapPtr opType = 203 + opStructFieldHeadStringTagMapPtr opType = 204 + opStructFieldPtrHeadMapPtr opType = 205 + opStructFieldPtrHeadOmitEmptyMapPtr opType = 206 + opStructFieldPtrHeadStringTagMapPtr opType = 207 + opStructFieldHeadSlicePtr opType = 208 + opStructFieldHeadOmitEmptySlicePtr opType = 209 + opStructFieldHeadStringTagSlicePtr opType = 210 + opStructFieldPtrHeadSlicePtr opType = 211 + opStructFieldPtrHeadOmitEmptySlicePtr opType = 212 + opStructFieldPtrHeadStringTagSlicePtr opType = 213 + opStructFieldHeadMarshalJSONPtr opType = 214 + opStructFieldHeadOmitEmptyMarshalJSONPtr opType = 215 + opStructFieldHeadStringTagMarshalJSONPtr opType = 216 + opStructFieldPtrHeadMarshalJSONPtr opType = 217 + opStructFieldPtrHeadOmitEmptyMarshalJSONPtr opType = 218 + opStructFieldPtrHeadStringTagMarshalJSONPtr opType = 219 + opStructFieldHeadMarshalTextPtr opType = 220 + opStructFieldHeadOmitEmptyMarshalTextPtr opType = 221 + opStructFieldHeadStringTagMarshalTextPtr opType = 222 + opStructFieldPtrHeadMarshalTextPtr opType = 223 + opStructFieldPtrHeadOmitEmptyMarshalTextPtr opType = 224 + opStructFieldPtrHeadStringTagMarshalTextPtr opType = 225 + opStructFieldHeadInterfacePtr opType = 226 + opStructFieldHeadOmitEmptyInterfacePtr opType = 227 + opStructFieldHeadStringTagInterfacePtr opType = 228 + opStructFieldPtrHeadInterfacePtr opType = 229 + opStructFieldPtrHeadOmitEmptyInterfacePtr opType = 230 + opStructFieldPtrHeadStringTagInterfacePtr opType = 231 + opStructFieldHeadRecursivePtr opType = 232 + opStructFieldHeadOmitEmptyRecursivePtr opType = 233 + opStructFieldHeadStringTagRecursivePtr opType = 234 + opStructFieldPtrHeadRecursivePtr opType = 235 + opStructFieldPtrHeadOmitEmptyRecursivePtr opType = 236 + opStructFieldPtrHeadStringTagRecursivePtr opType = 237 + opStructFieldHead opType = 238 + opStructFieldHeadOmitEmpty opType = 239 + opStructFieldHeadStringTag opType = 240 + opStructFieldPtrHead opType = 241 + opStructFieldPtrHeadOmitEmpty opType = 242 + opStructFieldPtrHeadStringTag opType = 243 + opStructFieldInt opType = 244 + opStructFieldOmitEmptyInt opType = 245 + opStructFieldStringTagInt opType = 246 + opStructFieldUint opType = 247 + opStructFieldOmitEmptyUint opType = 248 + opStructFieldStringTagUint opType = 249 + opStructFieldFloat32 opType = 250 + opStructFieldOmitEmptyFloat32 opType = 251 + opStructFieldStringTagFloat32 opType = 252 + opStructFieldFloat64 opType = 253 + opStructFieldOmitEmptyFloat64 opType = 254 + opStructFieldStringTagFloat64 opType = 255 + opStructFieldBool opType = 256 + opStructFieldOmitEmptyBool opType = 257 + opStructFieldStringTagBool opType = 258 + opStructFieldString opType = 259 + opStructFieldOmitEmptyString opType = 260 + opStructFieldStringTagString opType = 261 + opStructFieldBytes opType = 262 + opStructFieldOmitEmptyBytes opType = 263 + opStructFieldStringTagBytes opType = 264 + opStructFieldNumber opType = 265 + opStructFieldOmitEmptyNumber opType = 266 + opStructFieldStringTagNumber opType = 267 + opStructFieldArray opType = 268 + opStructFieldOmitEmptyArray opType = 269 + opStructFieldStringTagArray opType = 270 + opStructFieldMap opType = 271 + opStructFieldOmitEmptyMap opType = 272 + opStructFieldStringTagMap opType = 273 + opStructFieldSlice opType = 274 + opStructFieldOmitEmptySlice opType = 275 + opStructFieldStringTagSlice opType = 276 + opStructFieldStruct opType = 277 + opStructFieldOmitEmptyStruct opType = 278 + opStructFieldStringTagStruct opType = 279 + opStructFieldMarshalJSON opType = 280 + opStructFieldOmitEmptyMarshalJSON opType = 281 + opStructFieldStringTagMarshalJSON opType = 282 + opStructFieldMarshalText opType = 283 + opStructFieldOmitEmptyMarshalText opType = 284 + opStructFieldStringTagMarshalText opType = 285 + opStructFieldRecursive opType = 286 + opStructFieldOmitEmptyRecursive opType = 287 + opStructFieldStringTagRecursive opType = 288 + opStructFieldIntString opType = 289 + opStructFieldOmitEmptyIntString opType = 290 + opStructFieldStringTagIntString opType = 291 + opStructFieldUintString opType = 292 + opStructFieldOmitEmptyUintString opType = 293 + opStructFieldStringTagUintString opType = 294 + opStructFieldIntPtr opType = 295 + opStructFieldOmitEmptyIntPtr opType = 296 + opStructFieldStringTagIntPtr opType = 297 + opStructFieldUintPtr opType = 298 + opStructFieldOmitEmptyUintPtr opType = 299 + opStructFieldStringTagUintPtr opType = 300 + opStructFieldFloat32Ptr opType = 301 + opStructFieldOmitEmptyFloat32Ptr opType = 302 + opStructFieldStringTagFloat32Ptr opType = 303 + opStructFieldFloat64Ptr opType = 304 + opStructFieldOmitEmptyFloat64Ptr opType = 305 + opStructFieldStringTagFloat64Ptr opType = 306 + opStructFieldBoolPtr opType = 307 + opStructFieldOmitEmptyBoolPtr opType = 308 + opStructFieldStringTagBoolPtr opType = 309 + opStructFieldStringPtr opType = 310 + opStructFieldOmitEmptyStringPtr opType = 311 + opStructFieldStringTagStringPtr opType = 312 + opStructFieldBytesPtr opType = 313 + opStructFieldOmitEmptyBytesPtr opType = 314 + opStructFieldStringTagBytesPtr opType = 315 + opStructFieldNumberPtr opType = 316 + opStructFieldOmitEmptyNumberPtr opType = 317 + opStructFieldStringTagNumberPtr opType = 318 + opStructFieldArrayPtr opType = 319 + opStructFieldOmitEmptyArrayPtr opType = 320 + opStructFieldStringTagArrayPtr opType = 321 + opStructFieldMapPtr opType = 322 + opStructFieldOmitEmptyMapPtr opType = 323 + opStructFieldStringTagMapPtr opType = 324 + opStructFieldSlicePtr opType = 325 + opStructFieldOmitEmptySlicePtr opType = 326 + opStructFieldStringTagSlicePtr opType = 327 + opStructFieldMarshalJSONPtr opType = 328 + opStructFieldOmitEmptyMarshalJSONPtr opType = 329 + opStructFieldStringTagMarshalJSONPtr opType = 330 + opStructFieldMarshalTextPtr opType = 331 + opStructFieldOmitEmptyMarshalTextPtr opType = 332 + opStructFieldStringTagMarshalTextPtr opType = 333 + opStructFieldInterfacePtr opType = 334 + opStructFieldOmitEmptyInterfacePtr opType = 335 + opStructFieldStringTagInterfacePtr opType = 336 + opStructFieldRecursivePtr opType = 337 + opStructFieldOmitEmptyRecursivePtr opType = 338 + opStructFieldStringTagRecursivePtr opType = 339 + opStructField opType = 340 + opStructFieldOmitEmpty opType = 341 + opStructFieldStringTag opType = 342 + opStructEndInt opType = 343 + opStructEndOmitEmptyInt opType = 344 + opStructEndStringTagInt opType = 345 + opStructEndUint opType = 346 + opStructEndOmitEmptyUint opType = 347 + opStructEndStringTagUint opType = 348 + opStructEndFloat32 opType = 349 + opStructEndOmitEmptyFloat32 opType = 350 + opStructEndStringTagFloat32 opType = 351 + opStructEndFloat64 opType = 352 + opStructEndOmitEmptyFloat64 opType = 353 + opStructEndStringTagFloat64 opType = 354 + opStructEndBool opType = 355 + opStructEndOmitEmptyBool opType = 356 + opStructEndStringTagBool opType = 357 + opStructEndString opType = 358 + opStructEndOmitEmptyString opType = 359 + opStructEndStringTagString opType = 360 + opStructEndBytes opType = 361 + opStructEndOmitEmptyBytes opType = 362 + opStructEndStringTagBytes opType = 363 + opStructEndNumber opType = 364 + opStructEndOmitEmptyNumber opType = 365 + opStructEndStringTagNumber opType = 366 + opStructEndArray opType = 367 + opStructEndOmitEmptyArray opType = 368 + opStructEndStringTagArray opType = 369 + opStructEndMap opType = 370 + opStructEndOmitEmptyMap opType = 371 + opStructEndStringTagMap opType = 372 + opStructEndSlice opType = 373 + opStructEndOmitEmptySlice opType = 374 + opStructEndStringTagSlice opType = 375 + opStructEndStruct opType = 376 + opStructEndOmitEmptyStruct opType = 377 + opStructEndStringTagStruct opType = 378 + opStructEndMarshalJSON opType = 379 + opStructEndOmitEmptyMarshalJSON opType = 380 + opStructEndStringTagMarshalJSON opType = 381 + opStructEndMarshalText opType = 382 + opStructEndOmitEmptyMarshalText opType = 383 + opStructEndStringTagMarshalText opType = 384 + opStructEndRecursive opType = 385 + opStructEndOmitEmptyRecursive opType = 386 + opStructEndStringTagRecursive opType = 387 + opStructEndIntString opType = 388 + opStructEndOmitEmptyIntString opType = 389 + opStructEndStringTagIntString opType = 390 + opStructEndUintString opType = 391 + opStructEndOmitEmptyUintString opType = 392 + opStructEndStringTagUintString opType = 393 + opStructEndIntPtr opType = 394 + opStructEndOmitEmptyIntPtr opType = 395 + opStructEndStringTagIntPtr opType = 396 + opStructEndUintPtr opType = 397 + opStructEndOmitEmptyUintPtr opType = 398 + opStructEndStringTagUintPtr opType = 399 + opStructEndFloat32Ptr opType = 400 + opStructEndOmitEmptyFloat32Ptr opType = 401 + opStructEndStringTagFloat32Ptr opType = 402 + opStructEndFloat64Ptr opType = 403 + opStructEndOmitEmptyFloat64Ptr opType = 404 + opStructEndStringTagFloat64Ptr opType = 405 + opStructEndBoolPtr opType = 406 + opStructEndOmitEmptyBoolPtr opType = 407 + opStructEndStringTagBoolPtr opType = 408 + opStructEndStringPtr opType = 409 + opStructEndOmitEmptyStringPtr opType = 410 + opStructEndStringTagStringPtr opType = 411 + opStructEndBytesPtr opType = 412 + opStructEndOmitEmptyBytesPtr opType = 413 + opStructEndStringTagBytesPtr opType = 414 + opStructEndNumberPtr opType = 415 + opStructEndOmitEmptyNumberPtr opType = 416 + opStructEndStringTagNumberPtr opType = 417 + opStructEndArrayPtr opType = 418 + opStructEndOmitEmptyArrayPtr opType = 419 + opStructEndStringTagArrayPtr opType = 420 + opStructEndMapPtr opType = 421 + opStructEndOmitEmptyMapPtr opType = 422 + opStructEndStringTagMapPtr opType = 423 + opStructEndSlicePtr opType = 424 + opStructEndOmitEmptySlicePtr opType = 425 + opStructEndStringTagSlicePtr opType = 426 + opStructEndMarshalJSONPtr opType = 427 + opStructEndOmitEmptyMarshalJSONPtr opType = 428 + opStructEndStringTagMarshalJSONPtr opType = 429 + opStructEndMarshalTextPtr opType = 430 + opStructEndOmitEmptyMarshalTextPtr opType = 431 + opStructEndStringTagMarshalTextPtr opType = 432 + opStructEndInterfacePtr opType = 433 + opStructEndOmitEmptyInterfacePtr opType = 434 + opStructEndStringTagInterfacePtr opType = 435 + opStructEndRecursivePtr opType = 436 + opStructEndOmitEmptyRecursivePtr opType = 437 + opStructEndStringTagRecursivePtr opType = 438 + opStructEnd opType = 439 + opStructEndOmitEmpty opType = 440 + opStructEndStringTag opType = 441 ) func (t opType) String() string { - if int(t) >= 1394 { + if int(t) >= 442 { return "" } return opTypeStrings[int(t)] @@ -2832,19 +928,19 @@ func (t opType) codeType() codeType { } return codeStructField } - if strings.Contains(t.String(), "ArrayHead") { + if t.String() == "Array" || t.String() == "ArrayPtr" { return codeArrayHead } if strings.Contains(t.String(), "ArrayElem") { return codeArrayElem } - if strings.Contains(t.String(), "SliceHead") { + if t.String() == "Slice" || t.String() == "SlicePtr" { return codeSliceHead } if strings.Contains(t.String(), "SliceElem") { return codeSliceElem } - if strings.Contains(t.String(), "MapHead") { + if t.String() == "Map" || t.String() == "MapPtr" { return codeMapHead } if strings.Contains(t.String(), "MapKey") { @@ -2864,9 +960,6 @@ func (t opType) headToPtrHead() opType { if strings.Index(t.String(), "PtrHead") > 0 { return t } - if strings.Index(t.String(), "PtrAnonymousHead") > 0 { - return t - } idx := strings.Index(t.String(), "Field") if idx == -1 { @@ -2874,44 +967,15 @@ func (t opType) headToPtrHead() opType { } suffix := "Ptr" + t.String()[idx+len("Field"):] - const toPtrOffset = 12 + const toPtrOffset = 3 if strings.Contains(opType(int(t)+toPtrOffset).String(), suffix) { return opType(int(t) + toPtrOffset) } return t } -func (t opType) headToNPtrHead() opType { - if strings.Index(t.String(), "PtrHead") > 0 { - return t - } - if strings.Index(t.String(), "PtrAnonymousHead") > 0 { - return t - } - - idx := strings.Index(t.String(), "Field") - if idx == -1 { - return t - } - suffix := "NPtr" + t.String()[idx+len("Field"):] - - const toPtrOffset = 24 - if strings.Contains(opType(int(t)+toPtrOffset).String(), suffix) { - return opType(int(t) + toPtrOffset) - } - return t -} - -func (t opType) headToAnonymousHead() opType { - const toAnonymousOffset = 6 - if strings.Contains(opType(int(t)+toAnonymousOffset).String(), "Anonymous") { - return opType(int(t) + toAnonymousOffset) - } - return t -} - 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) } @@ -2920,25 +984,13 @@ 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) } return t } -func (t opType) headToOnlyHead() opType { - if strings.HasSuffix(t.String(), "Head") || strings.HasSuffix(t.String(), "HeadOmitEmpty") || strings.HasSuffix(t.String(), "HeadStringTag") { - return t - } - - const toOnlyOffset = 1 - if opType(int(t)+toOnlyOffset).String() == t.String()+"Only" { - return opType(int(t) + toOnlyOffset) - } - return t -} - func (t opType) ptrHeadToHead() opType { idx := strings.Index(t.String(), "Ptr") if idx == -1 { @@ -2946,7 +998,7 @@ func (t opType) ptrHeadToHead() opType { } suffix := t.String()[idx+len("Ptr"):] - const toPtrOffset = 12 + const toPtrOffset = 3 if strings.Contains(opType(int(t)-toPtrOffset).String(), suffix) { return opType(int(t) - toPtrOffset) } @@ -2997,6 +1049,12 @@ func (t opType) fieldToEnd() opType { return opStructEndOmitEmptyBytes case opStructFieldStringTagBytes: return opStructEndStringTagBytes + case opStructFieldNumber: + return opStructEndNumber + case opStructFieldOmitEmptyNumber: + return opStructEndOmitEmptyNumber + case opStructFieldStringTagNumber: + return opStructEndStringTagNumber case opStructFieldMarshalJSON: return opStructEndMarshalJSON case opStructFieldOmitEmptyMarshalJSON: @@ -3063,48 +1121,54 @@ func (t opType) fieldToEnd() opType { return opStructEndOmitEmptyBytesPtr case opStructFieldStringTagBytesPtr: return opStructEndStringTagBytesPtr - case opStructFieldIntNPtr: - return opStructEndIntNPtr - case opStructFieldOmitEmptyIntNPtr: - return opStructEndOmitEmptyIntNPtr - case opStructFieldStringTagIntNPtr: - return opStructEndStringTagIntNPtr - case opStructFieldUintNPtr: - return opStructEndUintNPtr - case opStructFieldOmitEmptyUintNPtr: - return opStructEndOmitEmptyUintNPtr - case opStructFieldStringTagUintNPtr: - return opStructEndStringTagUintNPtr - case opStructFieldFloat32NPtr: - return opStructEndFloat32NPtr - case opStructFieldOmitEmptyFloat32NPtr: - return opStructEndOmitEmptyFloat32NPtr - case opStructFieldStringTagFloat32NPtr: - return opStructEndStringTagFloat32NPtr - case opStructFieldFloat64NPtr: - return opStructEndFloat64NPtr - case opStructFieldOmitEmptyFloat64NPtr: - return opStructEndOmitEmptyFloat64NPtr - case opStructFieldStringTagFloat64NPtr: - return opStructEndStringTagFloat64NPtr - case opStructFieldBoolNPtr: - return opStructEndBoolNPtr - case opStructFieldOmitEmptyBoolNPtr: - return opStructEndOmitEmptyBoolNPtr - case opStructFieldStringTagBoolNPtr: - return opStructEndStringTagBoolNPtr - case opStructFieldStringNPtr: - return opStructEndStringNPtr - case opStructFieldOmitEmptyStringNPtr: - return opStructEndOmitEmptyStringNPtr - case opStructFieldStringTagStringNPtr: - return opStructEndStringTagStringNPtr - case opStructFieldBytesNPtr: - return opStructEndBytesNPtr - case opStructFieldOmitEmptyBytesNPtr: - return opStructEndOmitEmptyBytesNPtr - case opStructFieldStringTagBytesNPtr: - return opStructEndStringTagBytesNPtr + case opStructFieldNumberPtr: + return opStructEndNumberPtr + case opStructFieldOmitEmptyNumberPtr: + return opStructEndOmitEmptyNumberPtr + case opStructFieldStringTagNumberPtr: + return opStructEndStringTagNumberPtr + case opStructFieldArrayPtr: + return opStructEndArrayPtr + case opStructFieldOmitEmptyArrayPtr: + return opStructEndOmitEmptyArrayPtr + case opStructFieldStringTagArrayPtr: + return opStructEndStringTagArrayPtr + case opStructFieldMapPtr: + return opStructEndMapPtr + case opStructFieldOmitEmptyMapPtr: + return opStructEndOmitEmptyMapPtr + case opStructFieldStringTagMapPtr: + return opStructEndStringTagMapPtr + case opStructFieldSlicePtr: + return opStructEndSlicePtr + case opStructFieldOmitEmptySlicePtr: + return opStructEndOmitEmptySlicePtr + case opStructFieldStringTagSlicePtr: + return opStructEndStringTagSlicePtr + case opStructFieldMarshalJSONPtr: + return opStructEndMarshalJSONPtr + case opStructFieldOmitEmptyMarshalJSONPtr: + return opStructEndOmitEmptyMarshalJSONPtr + case opStructFieldStringTagMarshalJSONPtr: + return opStructEndStringTagMarshalJSONPtr + case opStructFieldMarshalTextPtr: + return opStructEndMarshalTextPtr + case opStructFieldOmitEmptyMarshalTextPtr: + return opStructEndOmitEmptyMarshalTextPtr + case opStructFieldStringTagMarshalTextPtr: + return opStructEndStringTagMarshalTextPtr + case opStructFieldInterfacePtr: + return opStructEndInterfacePtr + case opStructFieldOmitEmptyInterfacePtr: + return opStructEndOmitEmptyInterfacePtr + case opStructFieldStringTagInterfacePtr: + return opStructEndStringTagInterfacePtr + case opStructFieldRecursivePtr: + return opStructEndRecursivePtr + case opStructFieldOmitEmptyRecursivePtr: + return opStructEndOmitEmptyRecursivePtr + case opStructFieldStringTagRecursivePtr: + return opStructEndStringTagRecursivePtr } return t } diff --git a/encode_test.go b/encode_test.go index cfdfa6a..6409b85 100644 --- a/encode_test.go +++ b/encode_test.go @@ -3,6 +3,7 @@ package json_test import ( "bytes" "encoding" + stdjson "encoding/json" "errors" "fmt" "log" @@ -1674,3 +1675,117 @@ func TestOmitEmpty(t *testing.T) { t.Errorf(" got: %s\nwant: %s\n", got, optionalsExpected) } } + +type testNullStr string + +func (v *testNullStr) MarshalJSON() ([]byte, error) { + if *v == "" { + return []byte("null"), nil + } + + return []byte(*v), nil +} + +func TestIssue147(t *testing.T) { + type T struct { + Field1 string `json:"field1"` + Field2 testNullStr `json:"field2,omitempty"` + } + got, err := json.Marshal(T{ + Field1: "a", + Field2: "b", + }) + if err != nil { + t.Fatal(err) + } + expect, _ := stdjson.Marshal(T{ + Field1: "a", + Field2: "b", + }) + if !bytes.Equal(expect, got) { + t.Fatalf("expect %q but got %q", string(expect), string(got)) + } +} + +type testIssue144 struct { + name string + number int64 +} + +func (v *testIssue144) MarshalJSON() ([]byte, error) { + if v.name != "" { + return json.Marshal(v.name) + } + return json.Marshal(v.number) +} + +func TestIssue144(t *testing.T) { + type Embeded struct { + Field *testIssue144 `json:"field,omitempty"` + } + type T struct { + Embeded + } + { + v := T{ + Embeded: Embeded{Field: &testIssue144{name: "hoge"}}, + } + got, err := json.Marshal(v) + if err != nil { + t.Fatal(err) + } + expect, _ := stdjson.Marshal(v) + if !bytes.Equal(expect, got) { + t.Fatalf("expect %q but got %q", string(expect), string(got)) + } + } + { + v := &T{ + Embeded: Embeded{Field: &testIssue144{name: "hoge"}}, + } + got, err := json.Marshal(v) + if err != nil { + t.Fatal(err) + } + expect, _ := stdjson.Marshal(v) + if !bytes.Equal(expect, got) { + t.Fatalf("expect %q but got %q", string(expect), string(got)) + } + } +} + +func TestIssue118(t *testing.T) { + type data struct { + Columns []string `json:"columns"` + Rows1 [][]string `json:"rows1"` + Rows2 [][]string `json:"rows2"` + } + v := data{Columns: []string{"1", "2", "3"}} + got, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + expect, _ := stdjson.MarshalIndent(v, "", " ") + if !bytes.Equal(expect, got) { + t.Fatalf("expect %q but got %q", string(expect), string(got)) + } +} + +func TestIssue104(t *testing.T) { + type A struct { + Field1 string + Field2 int + Field3 float64 + } + type T struct { + Field A + } + got, err := json.Marshal(T{}) + if err != nil { + t.Fatal(err) + } + expect, _ := stdjson.Marshal(T{}) + if !bytes.Equal(expect, got) { + t.Fatalf("expect %q but got %q", string(expect), string(got)) + } +} diff --git a/encode_vm.go b/encode_vm.go index faf1c73..0488be3 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -1,14 +1,12 @@ package json import ( - "bytes" - "encoding" "fmt" "math" "reflect" - "runtime" "sort" "strconv" + "strings" "unsafe" ) @@ -29,6 +27,7 @@ func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) } func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) } func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } +func ptrToNumber(p uintptr) Number { return **(**Number)(unsafe.Pointer(&p)) } func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } func ptrToSlice(p uintptr) *sliceHeader { return *(**sliceHeader)(unsafe.Pointer(&p)) } func ptrToPtr(p uintptr) uintptr { @@ -124,15 +123,32 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next case opBytes: - ptr := load(ctxptr, code.idx) - slice := ptrToSlice(ptr) - if ptr == 0 || uintptr(slice.data) == 0 { + p := load(ctxptr, code.idx) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { b = encodeNull(b) } else { - b = encodeByteSlice(b, ptrToBytes(ptr)) + b = encodeByteSlice(b, ptrToBytes(p)) } b = encodeComma(b) code = code.next + case opNumber: + bb, err := encodeNumber(b, ptrToNumber(load(ctxptr, code.idx))) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opInterfacePtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough case opInterface: ptr := load(ctxptr, code.idx) if ptr == 0 { @@ -189,71 +205,62 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = bb code = code.next case opMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.next break } - v := ptrToInterface(code, ptr) - bb, err := v.(Marshaler).MarshalJSON() + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) if err != nil { - return nil, errMarshaler(code, err) - } - runtime.KeepAlive(v) - if len(bb) == 0 { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { return nil, err } - b = buf.Bytes() - b = encodeComma(b) + b = encodeComma(bb) code = code.next case opMarshalText: - ptr := load(ctxptr, code.idx) - isPtr := code.typ.Kind() == reflect.Ptr - p := ptrToUnsafePtr(ptr) - if p == nil || isPtr && *(*unsafe.Pointer)(p) == nil { - b = append(b, '"', '"', ',') - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{ - typ: code.typ, - ptr: p, - })) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - } - code = code.next - case opSliceHead: p := load(ctxptr, code.idx) - slice := ptrToSlice(p) - if p == 0 || uintptr(slice.data) == 0 { + if p == 0 { + b = append(b, `""`...) + b = encodeComma(b) + code = code.next + break + } + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next - } else { - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(slice.len)) + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opSlice: + p := load(ctxptr, code.idx) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.elemIdx, 0) + store(ctxptr, code.length, uintptr(slice.len)) + store(ctxptr, code.idx, uintptr(slice.data)) + if slice.len > 0 { + b = append(b, '[') + code = code.next store(ctxptr, code.idx, uintptr(slice.data)) - if slice.len > 0 { - b = append(b, '[') - code = code.next - store(ctxptr, code.idx, uintptr(slice.data)) - } else { - b = append(b, '[', ']', ',') - code = code.end.next - } + } else { + b = append(b, '[', ']', ',') + code = code.end.next } case opSliceElem: idx := load(ctxptr, code.elemIdx) @@ -271,7 +278,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.end.next } - case opArrayHead: + case opArray: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) @@ -303,73 +310,45 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.end.next } - case opMapHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + case opMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next - } else { - uptr := ptrToUnsafePtr(ptr) - mlen := maplen(uptr) - if mlen > 0 { - b = append(b, '{') - iter := mapiterinit(code.typ, uptr) - ctx.keepRefs = append(ctx.keepRefs, iter) - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(mlen)) - store(ctxptr, code.mapIter, uintptr(iter)) - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - b = append(b, '{', '}', ',') - code = code.end.next - } + break } - case opMapHeadLoad: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opMap: + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next + break + } + uptr := ptrToUnsafePtr(p) + mlen := maplen(uptr) + if mlen > 0 { + b = append(b, '{') + iter := mapiterinit(code.typ, uptr) + ctx.keepRefs = append(ctx.keepRefs, iter) + store(ctxptr, code.elemIdx, 0) + store(ctxptr, code.length, uintptr(mlen)) + store(ctxptr, code.mapIter, uintptr(iter)) + if (opt & EncodeOptionUnorderedMap) == 0 { + mapCtx := newMapContext(mlen) + mapCtx.pos = append(mapCtx.pos, len(b)) + ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) + store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) + } + key := mapiterkey(iter) + store(ctxptr, code.next.idx, uintptr(key)) + code = code.next } else { - // load pointer - ptr = ptrToPtr(ptr) - uptr := ptrToUnsafePtr(ptr) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - mlen := maplen(uptr) - if mlen > 0 { - b = append(b, '{') - iter := mapiterinit(code.typ, uptr) - ctx.keepRefs = append(ctx.keepRefs, iter) - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(mlen)) - store(ctxptr, code.mapIter, uintptr(iter)) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } - code = code.next - } else { - b = append(b, '{', '}', ',') - code = code.end.next - } + b = append(b, '{', '}', ',') + code = code.end.next } case opMapKey: idx := load(ctxptr, code.elemIdx) @@ -453,10 +432,13 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco mapCtx.buf = buf releaseMapContext(mapCtx) code = code.next - case opStructFieldPtrAnonymousHeadRecursive: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadRecursive: + case opStructFieldRecursivePtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldRecursive: ptr := load(ctxptr, code.idx) @@ -501,476 +483,269 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco case opStructFieldPtrHead: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.key...) + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) } - p := ptr + code.offset + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if !code.anonymousKey { + b = append(b, code.key...) + } + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmpty: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmpty: + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { + code = code.nextField + } else { + b = append(b, code.key...) code = code.next store(ctxptr, code.idx, p) } - case opStructFieldPtrHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmpty: - 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 - if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - code = code.next - store(ctxptr, code.idx, p) + case opStructFieldPtrHeadStringTag: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) } + code = code.end.next + break } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: - ptr := load(ctxptr, code.idx) - b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.key...) + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTag: + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break } - p := ptr + code.offset + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + b = append(b, code.key...) code = code.next store(ctxptr, code.idx, p) - case opStructFieldHeadOmitEmptyOnly: - 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 - } - } - case opStructFieldAnonymousHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - code = code.next - store(ctxptr, code.idx, ptr) - } - case opStructFieldPtrAnonymousHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - p := ptr + code.offset - if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - code = code.next - store(ctxptr, code.idx, p) - } - } 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) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = appendInt(b, ptrToUint64(p+code.offset), code) + b = encodeComma(b) + 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: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - 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) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next } - } - case opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - 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 + break } - 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) + if !code.anonymousHead { + b = append(b, '{') + } + u64 := ptrToUint64(p + code.offset) v := u64 & code.mask - if v != 0 { + if v == 0 { + code = code.nextField + } else { b = append(b, code.key...) b = appendInt(b, u64, code) b = encodeComma(b) + code = code.next } - code = code.next - case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly: + case opStructFieldPtrHeadStringTagInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagInt: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) + b = appendInt(b, ptrToUint64(p+code.offset), 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 { + if !code.anonymousHead { + 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 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) + } + b = append(b, code.key...) + if code.indirect { p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } + } + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + 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 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p + code.offset) - if p != 0 { - b = append(b, code.key...) - b = appendInt(b, ptrToUint64(p), code) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) + } + if code.indirect { p = ptrToPtr(p + code.offset) - 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 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: + case opStructFieldPtrHeadStringTagIntPtr: 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.key...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { + if !code.anonymousHead { b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadInt: - 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 opStructFieldPtrAnonymousHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyInt: - 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 } + code = code.end.next + break } - case opStructFieldPtrAnonymousHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadStringTagInt: - 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 = 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) + case opStructFieldHeadStringTagIntPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) 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 = 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 } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = appendInt(b, ptrToUint64(p), code) - b = encodeComma(b) - 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 - } - b = append(b, code.key...) - p = ptrToPtr(p + code.offset) if p == 0 { b = encodeNull(b) } else { @@ -980,438 +755,179 @@ 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = appendUint(b, ptrToUint64(p+code.offset), code) + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyUint: - 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 opStructFieldHeadOmitEmptyUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - 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) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next } - } - case opStructFieldPtrHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - 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 + break } - 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) + if !code.anonymousHead { + b = append(b, '{') + } + u64 := ptrToUint64(p + code.offset) v := u64 & code.mask - if v != 0 { + if v == 0 { + code = code.nextField + } else { b = append(b, code.key...) b = appendUint(b, u64, code) b = encodeComma(b) + code = code.next } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: + case opStructFieldPtrHeadStringTagUint: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagUint: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next case opStructFieldPtrHeadUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadUintPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) + } + b = append(b, code.key...) + if code.indirect { p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } + } + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyUintPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p + code.offset) - if p != 0 { - b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p), code) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next + code = code.end.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.key...) + b = appendUint(b, ptrToUint64(p), code) + b = encodeComma(b) + } + code = code.next case opStructFieldPtrHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringTagUintPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) + } + b = append(b, code.key...) + if code.indirect { p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.key...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadUint: - 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 opStructFieldPtrAnonymousHeadOmitEmptyUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUint: - 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 opStructFieldPtrAnonymousHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagUint: - 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 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 - case opStructFieldAnonymousHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p + code.offset) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p + code.offset) if p == 0 { b = encodeNull(b) } else { @@ -1421,703 +937,304 @@ 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = encodeFloat32(b, ptrToFloat32(p+code.offset)) + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyFloat32: - 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 opStructFieldHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeFloat32(b, v) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next } - } - case opStructFieldPtrHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next + break } - 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 { + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToFloat32(p + code.offset) + if v == 0 { + code = code.nextField + } else { b = append(b, code.key...) b = encodeFloat32(b, v) b = encodeComma(b) + code = code.next } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: + case opStructFieldPtrHeadStringTagFloat32: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat32: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) + b = encodeFloat32(b, ptrToFloat32(p+code.offset)) b = append(b, '"') b = encodeComma(b) code = code.next case opStructFieldPtrHeadFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeFloat32(b, ptrToFloat32(p)) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - b = append(b, code.key...) - b = encodeFloat32(b, ptrToFloat32(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - 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 opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.key...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat32: - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32: - 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 opStructFieldPtrAnonymousHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32: - 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 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 - case opStructFieldAnonymousHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - if p == 0 { - code = code.nextField - } else { b = append(b, code.key...) b = encodeFloat32(b, ptrToFloat32(p)) b = encodeComma(b) - code = code.next } - case opStructFieldPtrAnonymousHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadFloat32PtrOnly: + case opStructFieldPtrHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadFloat32PtrOnly: + case opStructFieldHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) + if code.indirect { + p = ptrToPtr(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 = encodeFloat32(b, ptrToFloat32(p)) b = append(b, '"') } b = encodeComma(b) code = code.next case opStructFieldPtrHeadFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '{') - b = append(b, code.key...) - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToFloat64(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, code.key...) - b = append(b, '"') - b = encodeFloat64(b, v) - b = append(b, '"') - 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 p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) b = encodeFloat64(b, v) b = encodeComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only: + case opStructFieldPtrHeadOmitEmptyFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyFloat64: p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToFloat64(p) - if v != 0 { + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToFloat64(p + code.offset) + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: + case opStructFieldPtrHeadStringTagFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat64: p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - v := ptrToFloat64(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } + b = append(b, code.key...) + b = append(b, '"') 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 - case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { + if !code.anonymousHead { 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 opStructFieldPtrHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - 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 opStructFieldPtrHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - 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 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: + case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { - v := ptrToFloat64(p + code.offset) + v := ptrToFloat64(p) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } @@ -2125,19 +1242,34 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: + case opStructFieldPtrHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: - b = append(b, '{') + case opStructFieldHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = append(b, code.key...) v := ptrToFloat64(p) @@ -2148,20 +1280,35 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) } code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: + case opStructFieldPtrHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: + case opStructFieldHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -2175,695 +1322,177 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldHeadFloat64NPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.key...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - 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 = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64: - 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 opStructFieldPtrAnonymousHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64: - 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 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 - case opStructFieldAnonymousHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - 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 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = encodeNoEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = encodeNoEscapedString(b, ptrToString(p+code.offset)) + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyString: - 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 opStructFieldHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToString(ptr + code.offset) - if v == "" { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeNoEscapedString(b, v) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next } - } - case opStructFieldPtrHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - s := ptrToString(ptr + code.offset) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s))) - b = encodeComma(b) - code = code.next + break } - 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 != "" { + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToString(p + code.offset) + if v == "" { + code = code.nextField + } else { b = append(b, code.key...) b = encodeNoEscapedString(b, v) b = encodeComma(b) + code = code.next } - code = code.next - case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly: + case opStructFieldPtrHeadStringTagString: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagString: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) + s := ptrToString(p + code.offset) + b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s))) b = encodeComma(b) code = code.next case opStructFieldPtrHeadStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeNoEscapedString(b, ptrToString(p)) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyStringPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - b = append(b, code.key...) - b = encodeNoEscapedString(b, ptrToString(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } } - 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 + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.key...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadString: - 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 opStructFieldPtrAnonymousHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyString: - 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 opStructFieldPtrAnonymousHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagString: - 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 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 - case opStructFieldAnonymousHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - if p == 0 { - code = code.nextField - } else { b = append(b, code.key...) b = encodeNoEscapedString(b, ptrToString(p)) b = encodeComma(b) - code = code.next } - case opStructFieldPtrAnonymousHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadStringPtrOnly: + case opStructFieldPtrHeadStringTagStringPtr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadStringPtrOnly: + case opStructFieldHeadStringTagStringPtr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) + if code.indirect { + p = ptrToPtr(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 { @@ -2872,1122 +1501,1280 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next case opStructFieldPtrHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyBool: - 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 opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToBool(ptr + code.offset) - if v { - b = append(b, code.key...) - b = encodeBool(b, v) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next - } else { - code = code.nextField } - } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next + break } - 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 !code.anonymousHead { + b = append(b, '{') + } + v := ptrToBool(p + code.offset) if v { b = append(b, code.key...) b = encodeBool(b, v) b = encodeComma(b) + code = code.next + } else { + code = code.nextField } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + case opStructFieldPtrHeadStringTagBool: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagBool: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) b = append(b, '"') - b = encodeBool(b, ptrToBool(p)) + b = encodeBool(b, ptrToBool(p+code.offset)) b = append(b, '"') b = encodeComma(b) code = code.next case opStructFieldPtrHeadBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - b = append(b, code.key...) - b = encodeBool(b, ptrToBool(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.key...) - p = ptrToPtr(p) - 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 opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.key...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadBool: - 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 opStructFieldPtrAnonymousHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBool: - 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 opStructFieldPtrAnonymousHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagBool: - 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 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 - case opStructFieldAnonymousHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - if p == 0 { - code = code.nextField - } else { b = append(b, code.key...) b = encodeBool(b, ptrToBool(p)) b = encodeComma(b) - code = code.next } - case opStructFieldPtrAnonymousHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.key...) - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadBoolPtrOnly: + case opStructFieldPtrHeadStringTagBoolPtr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadBoolPtrOnly: + case opStructFieldHeadStringTagBoolPtr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.key...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) + if code.indirect { + p = ptrToPtr(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 = encodeBool(b, ptrToBool(p)) b = append(b, '"') } b = encodeComma(b) code = code.next case opStructFieldPtrHeadBytes: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } - store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - if code.op == opStructFieldPtrHeadBytes { - b = encodeNull(b) - b = encodeComma(b) - } else { - b = append(b, '{', '}', ',') - } - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadBytes: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadArray: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBytes: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyBytes: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToBytes(p + code.offset) + if v == nil { + code = code.nextField + } else { + b = append(b, code.key...) + b = encodeByteSlice(b, ptrToBytes(p)) b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadStringTagBytes: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagBytes: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = append(b, '"') + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadArray: - ptr := load(ctxptr, code.idx) + code.offset - if ptr == 0 { - if code.op == opStructFieldPtrHeadArray { + case opStructFieldHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - } else { - b = append(b, '[', ']', ',') } code = code.end.next - } else { + break + } + if !code.anonymousHead { b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.key...) - } - code = code.next - store(ctxptr, code.idx, ptr) } - case opStructFieldPtrAnonymousHeadArray: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadArray: - ptr := load(ctxptr, code.idx) + code.offset - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - store(ctxptr, code.idx, ptr) - code = code.next + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) } - case opStructFieldPtrHeadSlice: - p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) - b = encodeComma(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadSlice: - ptr := load(ctxptr, code.idx) - p := ptr + code.offset - if p == 0 { - if code.op == opStructFieldPtrHeadSlice { + case opStructFieldHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - } else { - b = append(b, '[', ']', ',') } code = code.end.next - } else { + break + } + if !code.anonymousHead { b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.key...) + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.key...) + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldHeadNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToNumber(p + code.offset) + if v == "" { + code = code.nextField + } else { + b = append(b, code.key...) + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + } + case opStructFieldPtrHeadStringTagNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.key...) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeComma(bb) + } + code = code.next + case opStructFieldPtrHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray, + opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadArray, opStructFieldHeadStringTagArray, + opStructFieldHeadSlice, opStructFieldHeadStringTagSlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyArray: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyArray: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptySlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptySlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + slice := ptrToSlice(p) + if slice.data == nil { + code = code.nextField + } else { + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr, + opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr, + opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.nextField + } else { + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + code = code.nextField + } else { + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMap, opStructFieldHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + if maplen(ptrToUnsafePtr(p)) == 0 { + code = code.nextField + } else { + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.nextField + } else { + if code.indirect { + p = ptrToPtr(p) } code = code.next store(ctxptr, code.idx, p) } - case opStructFieldPtrAnonymousHeadSlice: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadSlice: - ptr := load(ctxptr, code.idx) - p := ptr + code.offset + case opStructFieldPtrHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if p == 0 { + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + code = code.nextField } else { + if code.indirect { + p = ptrToPtr(p) + } b = append(b, code.key...) - store(ctxptr, code.idx, p) code = code.next + store(ctxptr, code.idx, p) } case opStructFieldPtrHeadMarshalJSON: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { b = encodeNull(b) + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if p == 0 && code.nilcheck { + code = code.nextField + } else { + b = append(b, code.key...) + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { + case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) - code = code.end - break + b = encodeComma(b) } - bb, err := rv.Interface().(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - if len(bb) == 0 { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { - return nil, err - } - b = buf.Bytes() - b = encodeComma(b) - code = code.next + code = code.end.next + break } - case opStructFieldPtrAnonymousHeadMarshalJSON: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) } else { - b = append(b, code.key...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { - b = encodeNull(b) - code = code.end.next - break - } - bb, err := rv.Interface().(Marshaler).MarshalJSON() + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) if err != nil { - return nil, errMarshaler(code, err) - } - if len(bb) == 0 { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { return nil, err } - b = buf.Bytes() + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{') + } + if p == 0 { + code = code.nextField + } else { + b = append(b, code.key...) + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb b = encodeComma(b) code = code.next } case opStructFieldPtrHeadMarshalText: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if p == 0 && code.nilcheck { + code = code.nextField + } else { + b = append(b, code.key...) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { + case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - code = code.end - break } - bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadMarshalText: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.key...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) } else { - b = append(b, code.key...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - code = code.end.next - break } - bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText() + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{') + } + if p == 0 { + code = code.nextField + } else { + b = append(b, code.key...) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) if err != nil { - return nil, errMarshaler(code, err) + return nil, err } - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToBytes(ptr + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeByteSlice(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBytes(ptr + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeByteSlice(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - code = code.nextField - } else { - b = append(b, code.key...) - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { - return nil, err - } - b = buf.Bytes() - b = encodeComma(b) - code = code.next - } - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - code = code.nextField - } else { - b = append(b, code.key...) - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { - return nil, err - } - b = buf.Bytes() - b = encodeComma(b) - code = code.next - } - } - } - case opStructFieldPtrHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - 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 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - code = code.next - store(ctxptr, code.idx, ptr+code.offset) - } - case opStructFieldPtrHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - b = append(b, code.key...) - b = append(b, '"', '"') - b = encodeComma(b) - code = code.nextField - } else { - var buf bytes.Buffer - if err := compact(&buf, bb, false); err != nil { - return nil, err - } - b = append(b, code.key...) - b = encodeNoEscapedString(b, buf.String()) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - b = append(b, code.key...) - b = append(b, '"', '"') - b = encodeComma(b) - code = code.nextField - } else { - var buf bytes.Buffer - if err := compact(&buf, bb, false); err != nil { - return nil, err - } - b = append(b, code.key...) - b = encodeNoEscapedString(b, buf.String()) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) + b = bb b = encodeComma(b) code = code.next } @@ -4001,7 +2788,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco case opStructFieldOmitEmpty: ptr := load(ctxptr, code.headIdx) p := ptr + code.offset - if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 { + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { code = code.nextField } else { b = append(b, code.key...) @@ -4071,23 +2858,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldIntNPtr: - b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeComma(b) - code = code.next case opStructFieldUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -4444,174 +3214,303 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next - case opStructFieldMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructFieldNumber: + p := load(ctxptr, code.headIdx) b = append(b, code.key...) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { return nil, err } - b = buf.Bytes() + b = encodeComma(bb) + code = code.next + case opStructFieldOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { + b = append(b, code.key...) + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeComma(bb) + } + code = code.next + case opStructFieldStringTagNumber: + p := load(ctxptr, code.headIdx) + b = append(b, code.key...) + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') b = encodeComma(b) code = code.next - case opStructFieldStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - var buf bytes.Buffer - if err := compact(&buf, bb, false); err != nil { - return nil, err - } + case opStructFieldNumberPtr: b = append(b, code.key...) - b = encodeNoEscapedString(b, buf.String()) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.key...) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeComma(bb) + } + code = code.next + case opStructFieldStringTagNumberPtr: + b = append(b, code.key...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON: + p := load(ctxptr, code.headIdx) + b = append(b, code.key...) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } b = encodeComma(b) code = code.next case opStructFieldOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if code.typ.Kind() == reflect.Ptr && code.typ.Elem().Implements(marshalJSONType) { + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { p = ptrToPtr(p) } - v := ptrToInterface(code, p) - if v != nil && p != 0 { - bb, err := v.(Marshaler).MarshalJSON() + if p == 0 && code.nilcheck { + code = code.nextField + break + } + b = append(b, code.key...) + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + b = append(b, code.key...) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) if err != nil { - return nil, errMarshaler(code, err) - } - b = append(b, code.key...) - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { return nil, err } - b = buf.Bytes() - b = encodeComma(b) + b = bb } - code = code.next - case opStructFieldMarshalText: - ptr := load(ctxptr, code.headIdx) - b = append(b, code.key...) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) b = encodeComma(b) code = code.next - case opStructFieldStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) + case opStructFieldOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.key...) + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = encodeComma(bb) } + code = code.next + case opStructFieldMarshalText, opStructFieldStringTagMarshalText: + p := load(ctxptr, code.headIdx) b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } b = encodeComma(b) code = code.next case opStructFieldOmitEmptyMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - if v != nil { - bytes, err := v.(encoding.TextMarshaler).MarshalText() + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + code = code.nextField + break + } + b = append(b, code.key...) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr: + p := load(ctxptr, code.headIdx) + b = append(b, code.key...) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) if err != nil { - return nil, errMarshaler(code, err) + return nil, err } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = encodeComma(bb) } code = code.next - case opStructFieldArray: + case opStructFieldArray, opStructFieldStringTagArray: b = append(b, code.key...) ptr := load(ctxptr, code.headIdx) p := ptr + code.offset code = code.next store(ctxptr, code.idx, p) case opStructFieldOmitEmptyArray: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - array := ptrToSlice(p) - if p == 0 || uintptr(array.data) == 0 { - code = code.nextField - } else { + p := load(ctxptr, code.headIdx) + p += code.offset + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr: + b = append(b, code.key...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptyArrayPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { b = append(b, code.key...) code = code.next store(ctxptr, code.idx, p) + } else { + code = code.nextField } - case opStructFieldSlice: + case opStructFieldSlice, opStructFieldStringTagSlice: b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p += code.offset code = code.next store(ctxptr, code.idx, p) case opStructFieldOmitEmptySlice: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p += code.offset slice := ptrToSlice(p) - if p == 0 || uintptr(slice.data) == 0 { + if p == 0 || slice.data == nil { code = code.nextField } else { b = append(b, code.key...) code = code.next store(ctxptr, code.idx, p) } - case opStructFieldMap: + case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr: b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptySlicePtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) + } else { + code = code.nextField + } + case opStructFieldMap, opStructFieldStringTagMap: + b = append(b, code.key...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) code = code.next store(ctxptr, code.idx, p) case opStructFieldOmitEmptyMap: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { code = code.nextField } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - code = code.next - store(ctxptr, code.idx, p) - } + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) } - case opStructFieldMapLoad: + case opStructFieldMapPtr, opStructFieldStringTagMapPtr: b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + p = ptrToPtr(p) + } code = code.next store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyMapLoad: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - code = code.nextField + case opStructFieldOmitEmptyMapPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + p = ptrToPtr(p) + } + if p != 0 { + b = append(b, code.key...) + code = code.next + store(ctxptr, code.idx, p) } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = append(b, code.key...) - code = code.next - store(ctxptr, code.idx, p) - } + code = code.nextField } case opStructFieldStruct: b = append(b, code.key...) @@ -4703,23 +3602,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = appendStructEnd(b) code = code.next - case opStructEndIntNPtr: - b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = appendStructEnd(b) - code = code.next case opStructEndUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -4793,23 +3675,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = appendStructEnd(b) code = code.next - case opStructEndUintNPtr: - b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = appendStructEnd(b) - code = code.next case opStructEndFloat32: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -4882,23 +3747,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = appendStructEnd(b) code = code.next - case opStructEndFloat32NPtr: - b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = appendStructEnd(b) - code = code.next case opStructEndFloat64: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -4996,27 +3844,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = appendStructEnd(b) code = code.next - case opStructEndFloat64NPtr: - b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - 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 = appendStructEnd(b) - code = code.next case opStructEndString: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -5087,23 +3914,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = appendStructEnd(b) code = code.next - case opStructEndStringNPtr: - b = append(b, code.key...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p)) - } - b = appendStructEnd(b) - code = code.next case opStructEndBool: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -5206,40 +4016,25 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeByteSlice(b, v) b = appendStructEnd(b) code = code.next - case opStructEndMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructEndNumber: + p := load(ctxptr, code.headIdx) b = append(b, code.key...) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { return nil, err } - b = buf.Bytes() - b = appendStructEnd(b) + b = appendStructEnd(bb) code = code.next - case opStructEndOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - if v != nil && (code.typ.Kind() != reflect.Ptr || ptrToPtr(p) != 0) { - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } + case opStructEndOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { b = append(b, code.key...) - buf := bytes.NewBuffer(b) - //TODO: we should validate buffer with `compact` - if err := compact(buf, bb, false); err != nil { + bb, err := encodeNumber(b, v) + if err != nil { return nil, err } - b = buf.Bytes() - b = appendStructEnd(b) + b = appendStructEnd(bb) } else { last := len(b) - 1 if b[last] == ',' { @@ -5250,46 +4045,42 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } } code = code.next - case opStructEndStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + case opStructEndStringTagNumber: + p := load(ctxptr, code.headIdx) + b = append(b, code.key...) + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - var buf bytes.Buffer - if err := compact(&buf, bb, false); err != nil { return nil, err } - b = append(b, code.key...) - b = encodeNoEscapedString(b, buf.String()) + b = append(bb, '"') b = appendStructEnd(b) code = code.next - case opStructEndMarshalText: - ptr := load(ctxptr, code.headIdx) + case opStructEndNumberPtr: b = append(b, code.key...) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = appendStructEnd(b) - code = code.next - case opStructEndOmitEmptyMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - if v != nil { - bytes, err := v.(encoding.TextMarshaler).MarshalText() + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) if err != nil { - return nil, errMarshaler(code, err) + return nil, err } + b = bb + } + b = appendStructEnd(b) + code = code.next + case opStructEndOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = appendStructEnd(b) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendStructEnd(bb) } else { last := len(b) - 1 if b[last] == ',' { @@ -5300,16 +4091,20 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } } code = code.next - case opStructEndStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } + case opStructEndStringTagNumberPtr: b = append(b, code.key...) - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } b = appendStructEnd(b) code = code.next case opEnd: diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index 2c2c6d0..82c1953 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -1,13 +1,11 @@ package json import ( - "bytes" - "encoding" "fmt" "math" "reflect" - "runtime" "sort" + "strings" "unsafe" ) @@ -15,7 +13,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o recursiveLevel := 0 ptrOffset := uintptr(0) ctxptr := ctx.ptr() - code := codeSet.code for { @@ -76,6 +73,23 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opNumber: + bb, err := encodeNumber(b, ptrToNumber(load(ctxptr, code.idx))) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opInterfacePtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough case opInterface: ptr := load(ctxptr, code.idx) if ptr == 0 { @@ -131,71 +145,82 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = bb code = code.next - case opMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + case opMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.next break } - v := ptrToInterface(code, ptr) - bb, err := v.(Marshaler).MarshalJSON() + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.next + break + } + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) if err != nil { - return nil, errMarshaler(code, err) - } - runtime.KeepAlive(v) - if len(bb) == 0 { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { return nil, err } - b = buf.Bytes() - b = encodeComma(b) + b = encodeComma(bb) code = code.next - case opMarshalText: - ptr := load(ctxptr, code.idx) - isPtr := code.typ.Kind() == reflect.Ptr - p := ptrToUnsafePtr(ptr) - if p == nil || isPtr && **(**unsafe.Pointer)(unsafe.Pointer(&p)) == nil { - b = append(b, '"', '"', ',') - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{ - typ: code.typ, - ptr: p, - })) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - } - code = code.next - case opSliceHead: + case opMarshalTextPtr: p := load(ctxptr, code.idx) - slice := ptrToSlice(p) - if p == 0 || uintptr(slice.data) == 0 { + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + b = append(b, `""`...) + b = encodeComma(b) + code = code.next + break + } + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next - } else { - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(slice.len)) + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opSlice: + p := load(ctxptr, code.idx) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.elemIdx, 0) + store(ctxptr, code.length, uintptr(slice.len)) + store(ctxptr, code.idx, uintptr(slice.data)) + if slice.len > 0 { + b = append(b, '[') + code = code.next store(ctxptr, code.idx, uintptr(slice.data)) - if slice.len > 0 { - b = append(b, '[') - code = code.next - store(ctxptr, code.idx, uintptr(slice.data)) - } else { - b = append(b, '[', ']', ',') - code = code.end.next - } + } else { + b = append(b, '[', ']', ',') + code = code.end.next } case opSliceElem: idx := load(ctxptr, code.elemIdx) @@ -213,7 +238,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.end.next } - case opArrayHead: + case opArray: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) @@ -245,73 +270,45 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.end.next } - case opMapHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + case opMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next - } else { - uptr := ptrToUnsafePtr(ptr) - mlen := maplen(uptr) - if mlen > 0 { - b = append(b, '{') - iter := mapiterinit(code.typ, uptr) - ctx.keepRefs = append(ctx.keepRefs, iter) - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(mlen)) - store(ctxptr, code.mapIter, uintptr(iter)) - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - code = code.next - } else { - b = append(b, '{', '}', ',') - code = code.end.next - } + break } - case opMapHeadLoad: - ptr := load(ctxptr, code.idx) - if ptr == 0 { + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opMap: + p := load(ctxptr, code.idx) + if p == 0 { b = encodeNull(b) b = encodeComma(b) code = code.end.next + break + } + uptr := ptrToUnsafePtr(p) + mlen := maplen(uptr) + if mlen > 0 { + b = append(b, '{') + iter := mapiterinit(code.typ, uptr) + ctx.keepRefs = append(ctx.keepRefs, iter) + store(ctxptr, code.elemIdx, 0) + store(ctxptr, code.length, uintptr(mlen)) + store(ctxptr, code.mapIter, uintptr(iter)) + if (opt & EncodeOptionUnorderedMap) == 0 { + mapCtx := newMapContext(mlen) + mapCtx.pos = append(mapCtx.pos, len(b)) + ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) + store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) + } + key := mapiterkey(iter) + store(ctxptr, code.next.idx, uintptr(key)) + code = code.next } else { - // load pointer - ptr = ptrToPtr(ptr) - uptr := ptrToUnsafePtr(ptr) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - mlen := maplen(uptr) - if mlen > 0 { - b = append(b, '{') - iter := mapiterinit(code.typ, uptr) - ctx.keepRefs = append(ctx.keepRefs, iter) - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(mlen)) - store(ctxptr, code.mapIter, uintptr(iter)) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } - code = code.next - } else { - b = append(b, '{', '}', ',') - code = code.end.next - } + b = append(b, '{', '}', ',') + code = code.end.next } case opMapKey: idx := load(ctxptr, code.elemIdx) @@ -395,10 +392,13 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o mapCtx.buf = buf releaseMapContext(mapCtx) code = code.next - case opStructFieldPtrAnonymousHeadRecursive: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadRecursive: + case opStructFieldRecursivePtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldRecursive: ptr := load(ctxptr, code.idx) @@ -443,915 +443,458 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o case opStructFieldPtrHead: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.escapedKey...) + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) } - p := ptr + code.offset + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if !code.anonymousKey { + b = append(b, code.escapedKey...) + } + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmpty: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmpty: + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { + code = code.nextField + } else { + b = append(b, code.escapedKey...) code = code.next store(ctxptr, code.idx, p) } - case opStructFieldPtrHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmpty: - 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 - if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - code = code.next - store(ctxptr, code.idx, p) - } - } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: + case opStructFieldPtrHeadStringTag: p := load(ctxptr, code.idx) - b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.escapedKey...) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTag: + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + b = append(b, code.escapedKey...) 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 - } - } - case opStructFieldAnonymousHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - code = code.next - store(ctxptr, code.idx, ptr) - } - case opStructFieldPtrAnonymousHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - p := ptr + code.offset - if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - code = code.next - store(ctxptr, code.idx, p) - } - } case opStructFieldPtrHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - 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 opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - 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 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))) - fallthrough - case opStructFieldHeadIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - } - 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 - } else { - b = append(b, '{') - p = ptrToPtr(p + code.offset) - if p != 0 { - b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(p), code) - b = encodeComma(b) - } - code = code.next - } - case opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) - 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 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) + if code.indirect { + p := load(ctxptr, code.idx) for i := 0; i < code.ptrNum; i++ { if p == 0 { break } p = ptrToPtr(p) } - if p == 0 { + store(ctxptr, code.idx, p) + } + fallthrough + case opStructFieldHeadInt: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadInt: - 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 opStructFieldPtrAnonymousHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyInt: - 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 opStructFieldPtrAnonymousHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagInt: - 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 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 } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } + b = appendInt(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + case opStructFieldPtrHeadOmitEmptyInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough - case opStructFieldAnonymousHeadOmitEmptyIntPtr: + case opStructFieldHeadOmitEmptyInt: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } - p = ptrToPtr(p + code.offset) - if p == 0 { + if !code.anonymousHead { + b = append(b, '{') + } + u64 := ptrToUint64(p + code.offset) + v := u64 & code.mask + if v == 0 { code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(p), code) + b = appendInt(b, u64, code) b = encodeComma(b) code = code.next } - case opStructFieldPtrAnonymousHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + case opStructFieldPtrHeadStringTagInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough - case opStructFieldAnonymousHeadStringTagIntPtr: + case opStructFieldHeadStringTagInt: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) + b = append(b, '"') + b = appendInt(b, ptrToUint64(p+code.offset), code) + b = append(b, '"') + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadIntPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + 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 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } 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 opStructFieldPtrAnonymousHeadIntPtrOnly: + case opStructFieldPtrHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadIntPtrOnly: + case opStructFieldHeadOmitEmptyIntPtr: 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 { + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } 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 { + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { b = append(b, code.escapedKey...) - b = appendInt(b, ptrToUint64(p+code.offset), code) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) - code = code.next } - case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly: + code = code.next + case opStructFieldPtrHeadStringTagIntPtr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadStringTagIntPtrOnly: + case opStructFieldHeadStringTagIntPtr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { b = append(b, '"') - b = appendInt(b, ptrToUint64(p+code.offset), code) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) code = code.next case opStructFieldPtrHeadUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + b = appendUint(b, ptrToUint64(p+code.offset), code) + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyUint: - 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 opStructFieldHeadOmitEmptyUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - 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) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next } - } - case opStructFieldPtrHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - 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 + break } - 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) + if !code.anonymousHead { + b = append(b, '{') + } + u64 := ptrToUint64(p + code.offset) v := u64 & code.mask - if v != 0 { + if v == 0 { + code = code.nextField + } else { b = append(b, code.escapedKey...) b = appendUint(b, u64, code) b = encodeComma(b) + code = code.next } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: + case opStructFieldPtrHeadStringTagUint: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagUint: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next case opStructFieldPtrHeadUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadUintPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.escapedKey...) + } + b = append(b, code.escapedKey...) + if code.indirect { p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } + } + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyUintPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p + code.offset) - if p != 0 { - b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p), code) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next + code = code.end.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.escapedKey...) + b = appendUint(b, ptrToUint64(p), code) + b = encodeComma(b) + } + code = code.next case opStructFieldPtrHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringTagUintPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.escapedKey...) + } + b = append(b, code.escapedKey...) + if code.indirect { p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '"') - b = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadUint: - 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 opStructFieldPtrAnonymousHeadOmitEmptyUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUint: - 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 opStructFieldPtrAnonymousHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagUint: - 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 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 - case opStructFieldAnonymousHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p + code.offset) - if p == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p), code) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p + code.offset) if p == 0 { b = encodeNull(b) } else { @@ -1361,703 +904,304 @@ 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + b = encodeFloat32(b, ptrToFloat32(p+code.offset)) + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyFloat32: - 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 opStructFieldHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeFloat32(b, v) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next } - } - case opStructFieldPtrHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next + break } - 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 { + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToFloat32(p + code.offset) + if v == 0 { + code = code.nextField + } else { b = append(b, code.escapedKey...) b = encodeFloat32(b, v) b = encodeComma(b) + code = code.next } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: + case opStructFieldPtrHeadStringTagFloat32: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat32: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) b = append(b, '"') - b = encodeFloat32(b, ptrToFloat32(p)) + b = encodeFloat32(b, ptrToFloat32(p+code.offset)) b = append(b, '"') b = encodeComma(b) code = code.next case opStructFieldPtrHeadFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeFloat32(b, ptrToFloat32(p)) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - b = append(b, code.escapedKey...) - b = encodeFloat32(b, ptrToFloat32(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - 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 opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat32: - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32: - 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 opStructFieldPtrAnonymousHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32: - 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 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 - case opStructFieldAnonymousHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - if p == 0 { - code = code.nextField - } else { b = append(b, code.escapedKey...) b = encodeFloat32(b, ptrToFloat32(p)) b = encodeComma(b) - code = code.next } - case opStructFieldPtrAnonymousHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadFloat32PtrOnly: + case opStructFieldPtrHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadFloat32PtrOnly: + case opStructFieldHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p+code.offset)) + if code.indirect { + p = ptrToPtr(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 = encodeFloat32(b, ptrToFloat32(p)) b = append(b, '"') } b = encodeComma(b) code = code.next case opStructFieldPtrHeadFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeFloat64(b, v) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToFloat64(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeFloat64(b, v) - b = append(b, '"') - 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 p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) b = encodeFloat64(b, v) b = encodeComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64Only, opStructFieldHeadOmitEmptyFloat64Only: + case opStructFieldPtrHeadOmitEmptyFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyFloat64: p := load(ctxptr, code.idx) - b = append(b, '{') - v := ptrToFloat64(p) - if v != 0 { + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToFloat64(p + code.offset) + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: + case opStructFieldPtrHeadStringTagFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat64: p := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - v := ptrToFloat64(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } + b = append(b, code.escapedKey...) + b = append(b, '"') 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 - case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { + if !code.anonymousHead { 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 opStructFieldPtrHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - 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 opStructFieldPtrHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - 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 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: + case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { - v := ptrToFloat64(p + code.offset) + v := ptrToFloat64(p) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } @@ -2065,19 +1209,34 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: + case opStructFieldPtrHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: - b = append(b, '{') + case opStructFieldHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = append(b, code.escapedKey...) v := ptrToFloat64(p) @@ -2088,20 +1247,35 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) } code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: + case opStructFieldPtrHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: + case opStructFieldHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -2115,702 +1289,184 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldHeadFloat64NPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - 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 = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64: - 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 opStructFieldPtrAnonymousHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64: - 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 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 - case opStructFieldAnonymousHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - 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 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 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - store(ctxptr, code.idx, ptrToPtr(p)) - fallthrough - case opStructFieldHeadString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, ptrToString(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - 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 opStructFieldPtrHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - s := ptrToString(ptr + code.offset) - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s))) - 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 - case opStructFieldHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, ptrToString(p)) - b = encodeComma(b) - } - code = code.next - } - case opStructFieldPtrHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } - } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) + if code.indirect { + p := load(ctxptr, code.idx) for i := 0; i < code.ptrNum; i++ { if p == 0 { break } p = ptrToPtr(p) } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadString: - 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 opStructFieldPtrAnonymousHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + store(ctxptr, code.idx, p) } fallthrough - case opStructFieldAnonymousHeadOmitEmptyString: - 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 opStructFieldPtrAnonymousHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagString: - 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 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 - case opStructFieldAnonymousHeadStringPtr: + case opStructFieldHeadString: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) - p = ptrToPtr(p) + b = encodeEscapedString(b, ptrToString(p+code.offset)) + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyString: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyString: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToString(p + code.offset) + if v == "" { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + b = encodeEscapedString(b, v) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadStringTagString: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagString: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + s := ptrToString(p + code.offset) + b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s))) + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadStringPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) + b = encodeEscapedString(b, ptrToString(p)) } b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtr: + case opStructFieldPtrHeadOmitEmptyStringPtr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } - p = ptrToPtr(p) - if p == 0 { - code = code.nextField - } else { + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyStringPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { b = append(b, code.escapedKey...) b = encodeEscapedString(b, ptrToString(p)) b = encodeComma(b) - code = code.next } - case opStructFieldPtrAnonymousHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } - b = encodeComma(b) code = code.next - case opStructFieldPtrAnonymousHeadStringPtrOnly: + case opStructFieldPtrHeadStringTagStringPtr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadStringPtrOnly: + case opStructFieldHeadStringTagStringPtr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) + if code.indirect { + p = ptrToPtr(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 { @@ -2819,1118 +1475,1281 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next case opStructFieldPtrHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyBool: - 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 opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToBool(ptr + code.offset) - if v { - b = append(b, code.escapedKey...) - b = encodeBool(b, v) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) - code = code.next - } else { - code = code.nextField } - } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next + break } - 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 !code.anonymousHead { + b = append(b, '{') + } + v := ptrToBool(p + code.offset) if v { b = append(b, code.escapedKey...) b = encodeBool(b, v) b = encodeComma(b) + code = code.next + } else { + code = code.nextField } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + case opStructFieldPtrHeadStringTagBool: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagBool: p := load(ctxptr, code.idx) - b = append(b, '{') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) b = append(b, '"') - b = encodeBool(b, ptrToBool(p)) + b = encodeBool(b, ptrToBool(p+code.offset)) b = append(b, '"') b = encodeComma(b) code = code.next case opStructFieldPtrHeadBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) } b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - p = ptrToPtr(p) - if p != 0 { - b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{') - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - 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 opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 { - b = encodeNull(b) - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadBool: - 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 opStructFieldPtrAnonymousHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBool: - 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 opStructFieldPtrAnonymousHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagBool: - 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 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 - case opStructFieldAnonymousHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - if p == 0 { - code = code.nextField - } else { b = append(b, code.escapedKey...) b = encodeBool(b, ptrToBool(p)) b = encodeComma(b) - code = code.next } - case opStructFieldPtrAnonymousHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = append(b, code.escapedKey...) - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadBoolPtrOnly: + case opStructFieldPtrHeadStringTagBoolPtr: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldAnonymousHeadBoolPtrOnly: + case opStructFieldHeadStringTagBoolPtr: p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } b = append(b, code.escapedKey...) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) + if code.indirect { + p = ptrToPtr(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 = encodeBool(b, ptrToBool(p)) b = append(b, '"') } b = encodeComma(b) code = code.next case opStructFieldPtrHeadBytes: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } - store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - if code.op == opStructFieldPtrHeadBytes { - b = encodeNull(b) - b = encodeComma(b) - } else { - b = append(b, '{', '}', ',') - } - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadBytes: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadArray: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBytes: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyBytes: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToBytes(p + code.offset) + if v == nil { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + b = encodeByteSlice(b, ptrToBytes(p)) b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadStringTagBytes: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagBytes: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + b = append(b, '"') + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadArray: - ptr := load(ctxptr, code.idx) + code.offset - if ptr == 0 { - if code.op == opStructFieldPtrHeadArray { + case opStructFieldHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - } else { - b = append(b, '[', ']', ',') } code = code.end.next - } else { + break + } + if !code.anonymousHead { b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.escapedKey...) - } - code = code.next - store(ctxptr, code.idx, ptr) } - case opStructFieldPtrAnonymousHeadArray: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadArray: - ptr := load(ctxptr, code.idx) + code.offset - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - store(ctxptr, code.idx, ptr) - code = code.next + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) } - case opStructFieldPtrHeadSlice: - p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) - b = encodeComma(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadSlice: - ptr := load(ctxptr, code.idx) - p := ptr + code.offset - if p == 0 { - if code.op == opStructFieldPtrHeadSlice { + case opStructFieldHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - } else { - b = append(b, '[', ']', ',') } code = code.end.next - } else { + break + } + if !code.anonymousHead { b = append(b, '{') - if !code.anonymousKey { - b = append(b, code.escapedKey...) + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.escapedKey...) + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldHeadNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + v := ptrToNumber(p + code.offset) + if v == "" { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + } + case opStructFieldPtrHeadStringTagNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.escapedKey...) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeComma(bb) + } + code = code.next + case opStructFieldPtrHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray, + opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadArray, opStructFieldHeadStringTagArray, + opStructFieldHeadSlice, opStructFieldHeadStringTagSlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyArray: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyArray: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptySlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptySlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + p += code.offset + slice := ptrToSlice(p) + if slice.data == nil { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr, + opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr, + opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.nextField + } else { + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMap, opStructFieldHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + if maplen(ptrToUnsafePtr(p)) == 0 { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.nextField + } else { + if code.indirect { + p = ptrToPtr(p) } code = code.next store(ctxptr, code.idx, p) } - case opStructFieldPtrAnonymousHeadSlice: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadSlice: - ptr := load(ctxptr, code.idx) - p := ptr + code.offset + case opStructFieldPtrHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if p == 0 { + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + code = code.nextField } else { + if code.indirect { + p = ptrToPtr(p) + } b = append(b, code.escapedKey...) - store(ctxptr, code.idx, p) code = code.next + store(ctxptr, code.idx, p) } case opStructFieldPtrHeadMarshalJSON: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { b = encodeNull(b) + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + iface := ptrToInterface(code, p) + if code.nilcheck && encodeIsNilForMarshaler(iface) { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + bb, err := encodeMarshalJSON(code, b, iface, true) + if err != nil { + return nil, err + } + b = bb b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { + case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) - code = code.end - break + b = encodeComma(b) } - bb, err := rv.Interface().(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - if len(bb) == 0 { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { - return nil, err - } - b = buf.Bytes() - b = encodeComma(b) - code = code.next + code = code.end.next + break } - case opStructFieldPtrAnonymousHeadMarshalJSON: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) } else { - b = append(b, code.escapedKey...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { - b = encodeNull(b) - code = code.end.next - break - } - bb, err := rv.Interface().(Marshaler).MarshalJSON() + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) if err != nil { - return nil, errMarshaler(code, err) - } - if len(bb) == 0 { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { return nil, err } - b = buf.Bytes() + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{') + } + if p == 0 { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb b = encodeComma(b) code = code.next } case opStructFieldPtrHeadMarshalText: p := load(ctxptr, code.idx) if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if p == 0 && code.nilcheck { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { + case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - code = code.end - break } - bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadMarshalText: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{') + } + b = append(b, code.escapedKey...) + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) } else { - b = append(b, code.escapedKey...) - ptr += code.offset - v := ptrToInterface(code, ptr) - rv := reflect.ValueOf(v) - if rv.Type().Kind() == reflect.Interface && rv.IsNil() { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { b = encodeNull(b) b = encodeComma(b) - code = code.end.next - break } - bytes, err := rv.Interface().(encoding.TextMarshaler).MarshalText() + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{') + } + if p == 0 { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) if err != nil { - return nil, errMarshaler(code, err) + return nil, err } - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToBytes(ptr + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeByteSlice(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBytes(ptr + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeByteSlice(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - code = code.nextField - } else { - b = append(b, code.escapedKey...) - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { - return nil, err - } - b = buf.Bytes() - b = encodeComma(b) - code = code.next - } - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - code = code.nextField - } else { - b = append(b, code.escapedKey...) - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { - return nil, err - } - b = buf.Bytes() - b = encodeComma(b) - code = code.next - } - } - } - case opStructFieldPtrHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - if p == nil || (!isPtr && *(*unsafe.Pointer)(p) == nil) { - code = code.nextField - } else { - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - 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 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - code = code.next - store(ctxptr, code.idx, ptr+code.offset) - } - case opStructFieldPtrHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - b = append(b, code.escapedKey...) - b = append(b, '"', '"') - b = encodeComma(b) - code = code.nextField - } else { - var buf bytes.Buffer - if err := compact(&buf, bb, true); err != nil { - return nil, err - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, buf.String()) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagMarshalJSON: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - isPtr := code.typ.Kind() == reflect.Ptr - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - if len(bb) == 0 { - if isPtr { - return nil, errUnexpectedEndOfJSON( - fmt.Sprintf("error calling MarshalJSON for type %s", code.typ), - 0, - ) - } - b = append(b, code.escapedKey...) - b = append(b, '"', '"') - b = encodeComma(b) - code = code.nextField - } else { - var buf bytes.Buffer - if err := compact(&buf, bb, true); err != nil { - return nil, err - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, buf.String()) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - ptr += code.offset - p := ptrToUnsafePtr(ptr) - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, &MarshalerError{ - Type: rtype2type(code.typ), - Err: err, - } - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagMarshalText: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - ptr += code.offset - p := ptrToUnsafePtr(ptr) - v := *(*interface{})(unsafe.Pointer(&interfaceHeader{typ: code.typ, ptr: p})) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) + b = bb b = encodeComma(b) code = code.next } @@ -3944,7 +2763,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o case opStructFieldOmitEmpty: ptr := load(ctxptr, code.headIdx) p := ptr + code.offset - if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 { + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { code = code.nextField } else { b = append(b, code.escapedKey...) @@ -4014,23 +2833,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldIntNPtr: - b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = encodeComma(b) - code = code.next case opStructFieldUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -4263,7 +3065,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.escapedKey...) - b = encodeNoEscapedString(b, ptrToString(p)) + b = encodeEscapedString(b, ptrToString(p)) b = encodeComma(b) } code = code.next @@ -4387,126 +3189,234 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next - case opStructFieldMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructFieldNumber: + p := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - p := ptr + code.offset + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opStructFieldOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { + b = append(b, code.escapedKey...) + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeComma(bb) + } + code = code.next + case opStructFieldStringTagNumber: + p := load(ctxptr, code.headIdx) + b = append(b, code.escapedKey...) + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = encodeComma(b) + code = code.next + case opStructFieldNumberPtr: + b = append(b, code.escapedKey...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = encodeComma(b) + code = code.next + case opStructFieldOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeComma(bb) + } + code = code.next + case opStructFieldStringTagNumberPtr: + b = append(b, code.escapedKey...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON: + p := load(ctxptr, code.headIdx) + b = append(b, code.escapedKey...) + p += code.offset if code.typ.Kind() == reflect.Ptr { p = ptrToPtr(p) } - if p == 0 { + if p == 0 && code.nilcheck { b = encodeNull(b) - b = encodeComma(b) - code = code.next - break + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb } - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { - return nil, err - } - b = buf.Bytes() b = encodeComma(b) code = code.next case opStructFieldOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p += code.offset if code.typ.Kind() == reflect.Ptr { p = ptrToPtr(p) } - if p == 0 { - code = code.next + if p == 0 && code.nilcheck { + code = code.nextField break } - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } b = append(b, code.escapedKey...) - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) + if err != nil { return nil, err } - b = buf.Bytes() + b = encodeComma(bb) + code = code.next + case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + b = append(b, code.escapedKey...) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } b = encodeComma(b) code = code.next - case opStructFieldStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) + case opStructFieldOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = encodeComma(bb) } - var buf bytes.Buffer - if err := compact(&buf, bb, true); err != nil { - return nil, err - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, buf.String()) - b = encodeComma(b) code = code.next - case opStructFieldMarshalText: - ptr := load(ctxptr, code.headIdx) + case opStructFieldMarshalText, opStructFieldStringTagMarshalText: + p := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb } - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) b = encodeComma(b) code = code.next case opStructFieldOmitEmptyMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - if v != nil { - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeComma(b) + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) } - code = code.next - case opStructFieldStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) + if p == 0 && code.nilcheck { + code = code.nextField + break } b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = encodeComma(bb) + code = code.next + case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr: + p := load(ctxptr, code.headIdx) + b = append(b, code.escapedKey...) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } b = encodeComma(b) code = code.next - case opStructFieldArray: + case opStructFieldOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = encodeComma(bb) + } + code = code.next + case opStructFieldArray, opStructFieldStringTagArray: b = append(b, code.escapedKey...) ptr := load(ctxptr, code.headIdx) p := ptr + code.offset code = code.next store(ctxptr, code.idx, p) case opStructFieldOmitEmptyArray: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - array := ptrToSlice(p) - if p == 0 || uintptr(array.data) == 0 { - code = code.nextField - } else { + p := load(ctxptr, code.headIdx) + p += code.offset + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr: + b = append(b, code.escapedKey...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptyArrayPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { b = append(b, code.escapedKey...) code = code.next store(ctxptr, code.idx, p) + } else { + code = code.nextField } - case opStructFieldSlice: + case opStructFieldSlice, opStructFieldStringTagSlice: b = append(b, code.escapedKey...) ptr := load(ctxptr, code.headIdx) p := ptr + code.offset @@ -4523,47 +3433,59 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next store(ctxptr, code.idx, p) } - case opStructFieldMap: + case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr: b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptySlicePtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) + } else { + code = code.nextField + } + case opStructFieldMap, opStructFieldStringTagMap: + b = append(b, code.escapedKey...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) code = code.next store(ctxptr, code.idx, p) case opStructFieldOmitEmptyMap: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { code = code.nextField } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - code = code.next - store(ctxptr, code.idx, p) - } + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) } - case opStructFieldMapLoad: + case opStructFieldMapPtr, opStructFieldStringTagMapPtr: b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + p = ptrToPtr(p) + } code = code.next store(ctxptr, code.idx, p) - case opStructFieldOmitEmptyMapLoad: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - code = code.nextField + case opStructFieldOmitEmptyMapPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + p = ptrToPtr(p) + } + if p != 0 { + b = append(b, code.escapedKey...) + code = code.next + store(ctxptr, code.idx, p) } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - code = code.next - store(ctxptr, code.idx, p) - } + code = code.nextField } case opStructFieldStruct: b = append(b, code.escapedKey...) @@ -4655,23 +3577,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = appendStructEnd(b) code = code.next - case opStructEndIntNPtr: - b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - b = appendStructEnd(b) - code = code.next case opStructEndUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -4745,23 +3650,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = appendStructEnd(b) code = code.next - case opStructEndUintNPtr: - b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - b = appendStructEnd(b) - code = code.next case opStructEndFloat32: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -4834,23 +3722,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = appendStructEnd(b) code = code.next - case opStructEndFloat32NPtr: - b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - b = appendStructEnd(b) - code = code.next case opStructEndFloat64: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -4948,27 +3819,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = appendStructEnd(b) code = code.next - case opStructEndFloat64NPtr: - b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - 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 = appendStructEnd(b) - code = code.next case opStructEndString: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -5039,23 +3889,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = appendStructEnd(b) code = code.next - case opStructEndStringNPtr: - b = append(b, code.escapedKey...) - ptr := load(ctxptr, code.headIdx) - p := ptrToPtr(ptr + code.offset) - for i := 0; i < code.ptrNum-1; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p)) - } - b = appendStructEnd(b) - code = code.next case opStructEndBool: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -5158,92 +3991,25 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeByteSlice(b, v) b = appendStructEnd(b) code = code.next - case opStructEndMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructEndNumber: + p := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { return nil, err } - b = buf.Bytes() - b = appendStructEnd(b) + b = appendStructEnd(bb) code = code.next - case opStructEndOmitEmptyMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if code.typ.Kind() == reflect.Ptr { - p = ptrToPtr(p) - } - if p == 0 { - last := len(b) - 1 - if b[last] == ',' { - b[last] = '}' - b = encodeComma(b) - } else { - b = appendStructEnd(b) - } - code = code.next - break - } - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - b = append(b, code.escapedKey...) - buf := bytes.NewBuffer(b) - if err := compact(buf, bb, true); err != nil { - return nil, err - } - b = buf.Bytes() - b = appendStructEnd(b) - code = code.next - case opStructEndStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - var buf bytes.Buffer - if err := compact(&buf, bb, true); err != nil { - return nil, err - } - b = append(b, code.escapedKey...) - b = encodeEscapedString(b, buf.String()) - b = appendStructEnd(b) - code = code.next - case opStructEndMarshalText: - ptr := load(ctxptr, code.headIdx) - b = append(b, code.escapedKey...) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = appendStructEnd(b) - code = code.next - case opStructEndOmitEmptyMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - if v != nil { - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } + case opStructEndOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = appendStructEnd(b) + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = appendStructEnd(bb) } else { last := len(b) - 1 if b[last] == ',' { @@ -5254,16 +4020,66 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } } code = code.next - case opStructEndStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } + case opStructEndStringTagNumber: + p := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = appendStructEnd(b) + code = code.next + case opStructEndNumberPtr: + b = append(b, code.escapedKey...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = appendStructEnd(b) + code = code.next + case opStructEndOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendStructEnd(bb) + } else { + last := len(b) - 1 + if b[last] == ',' { + b[last] = '}' + b = encodeComma(b) + } else { + b = appendStructEnd(b) + } + } + code = code.next + case opStructEndStringTagNumberPtr: + b = append(b, code.escapedKey...) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } b = appendStructEnd(b) code = code.next case opEnd: diff --git a/encode_vm_escaped_indent.go b/encode_vm_escaped_indent.go index 0a24438..71c5506 100644 --- a/encode_vm_escaped_indent.go +++ b/encode_vm_escaped_indent.go @@ -13,6 +13,7 @@ import ( ) func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) { + recursiveLevel := 0 ptrOffset := uintptr(0) ctxptr := ctx.ptr() code := codeSet.code @@ -66,15 +67,22 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opBytes: - ptr := load(ctxptr, code.idx) - slice := ptrToSlice(ptr) - if ptr == 0 || uintptr(slice.data) == 0 { + p := load(ctxptr, code.idx) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { b = encodeNull(b) } else { - b = encodeByteSlice(b, ptrToBytes(ptr)) + b = encodeByteSlice(b, ptrToBytes(p)) } b = encodeIndentComma(b) code = code.next + case opNumber: + bb, err := encodeNumber(b, ptrToNumber(load(ctxptr, code.idx))) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next case opInterface: ptr := load(ctxptr, code.idx) if ptr == 0 { @@ -194,15 +202,14 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) } code = code.next - case opSliceHead: + case opSlice: p := load(ctxptr, code.idx) - if p == 0 { - b = appendIndent(ctx, b, code.indent) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next } else { - slice := ptrToSlice(p) store(ctxptr, code.elemIdx, 0) store(ctxptr, code.length, uintptr(slice.len)) store(ctxptr, code.idx, uintptr(slice.data)) @@ -213,19 +220,18 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode store(ctxptr, code.idx, uintptr(slice.data)) } else { b = appendIndent(ctx, b, code.indent) - b = append(b, '[', ']', '\n') + b = append(b, '[', ']', ',', '\n') code = code.end.next } } case opRootSliceHead: p := load(ctxptr, code.idx) - if p == 0 { - b = appendIndent(ctx, b, code.indent) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next } else { - slice := ptrToSlice(p) store(ctxptr, code.elemIdx, 0) store(ctxptr, code.length, uintptr(slice.len)) store(ctxptr, code.idx, uintptr(slice.data)) @@ -274,10 +280,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, ']') code = code.end.next } - case opArrayHead: + case opArray: p := load(ctxptr, code.idx) if p == 0 { - b = appendIndent(ctx, b, code.indent) b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -311,10 +316,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, ']', ',', '\n') code = code.end.next } - case opMapHead: + case opMap: ptr := load(ctxptr, code.idx) if ptr == 0 { - b = appendIndent(ctx, b, code.indent) b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -342,51 +346,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode store(ctxptr, code.next.idx, uintptr(key)) code = code.next } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '}', ',', '\n') - code = code.end.next - } - } - case opMapHeadLoad: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - code = code.end.next - } else { - // load pointer - ptr = ptrToPtr(ptr) - uptr := ptrToUnsafePtr(ptr) - if uintptr(uptr) == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - mlen := maplen(uptr) - if mlen > 0 { - b = append(b, '{', '\n') - iter := mapiterinit(code.typ, uptr) - ctx.keepRefs = append(ctx.keepRefs, iter) - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(mlen)) - store(ctxptr, code.mapIter, uintptr(iter)) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } else { - b = appendIndent(ctx, b, code.next.indent) - } - - code = code.next - } else { - b = appendIndent(ctx, b, code.indent) b = append(b, '{', '}', ',', '\n') code = code.end.next } @@ -481,276 +440,257 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode mapCtx.buf = buf releaseMapContext(mapCtx) code = code.next + case opStructFieldPtrHeadRecursive: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + case opStructFieldRecursive: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + if recursiveLevel > startDetectingCyclesAfter { + for _, seen := range ctx.seenPtr { + if ptr == seen { + return nil, errUnsupportedValue(code, ptr) + } + } + } + } + ctx.seenPtr = append(ctx.seenPtr, ptr) + c := code.jmp.code + curlen := uintptr(len(ctx.ptrs)) + offsetNum := ptrOffset / uintptrSize + oldOffset := ptrOffset + ptrOffset += code.jmp.curLen * uintptrSize + + newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen + if curlen < newLen { + ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...) + } + ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr + + store(ctxptr, c.idx, ptr) + store(ctxptr, c.end.next.idx, oldOffset) + store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next))) + code = c + recursiveLevel++ + case opStructFieldRecursiveEnd: + recursiveLevel-- + + // restore ctxptr + offset := load(ctxptr, code.idx) + ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1] + + codePtr := load(ctxptr, code.elemIdx) + code = (*opcode)(ptrToUnsafePtr(codePtr)) + ctxptr = ctx.ptr() + offset + ptrOffset = offset case opStructFieldPtrHead: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else if code.next == code.end { - // not exists fields - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '}', ',', '\n') - code = code.end.next - store(ctxptr, code.idx, ptr) - } else { - b = append(b, '{', '\n') - if !code.anonymousKey { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) } - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - p := ptr + code.offset - if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } + break } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: - ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey { + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if !code.anonymousKey && len(code.escapedKey) > 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') } - p := ptr + code.offset + p += code.offset code = code.next store(ctxptr, code.idx, p) - case opStructFieldHeadOmitEmptyOnly: - ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey && ptr != 0 { - 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))) - fallthrough - case opStructFieldHeadInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - 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))) - fallthrough - case opStructFieldHeadIntPtr: + case opStructFieldPtrHeadOmitEmpty: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { + if !code.anonymousHead { b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - } - 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 - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p + code.offset) - 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 opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - 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, '"') - } - } - 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: + case opStructFieldHeadOmitEmpty: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += code.offset + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadStringTag: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTag: + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += 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 opStructFieldPtrHeadInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadInt: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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.offset), code) + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyInt: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.offset) + v := u64 & code.mask + if v == 0 { + code = code.nextField + } else { + 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 opStructFieldPtrHeadStringTagInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagInt: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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.offset), code) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadIntPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + 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 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -758,19 +698,34 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtrOnly: + case opStructFieldPtrHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyIntPtrOnly: + case opStructFieldHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) @@ -779,266 +734,37 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagIntPtrOnly: + case opStructFieldPtrHeadStringTagIntPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagIntPtrOnly: + case opStructFieldHeadStringTagIntPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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, '"') + if code.indirect { + p = ptrToPtr(p + code.offset) } - b = encodeIndentComma(b) - code = code.next - case opStructFieldHeadIntNPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadInt: - 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 opStructFieldPtrAnonymousHeadOmitEmptyInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyInt: - 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 = 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 opStructFieldPtrAnonymousHeadStringTagInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagInt: - 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.offset), code) - b = append(b, '"') - 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))) - fallthrough - case opStructFieldAnonymousHeadIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - 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 = appendInt(b, ptrToUint64(p), code) - } - 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) - 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 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 - } - 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, '"') - } - 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 { @@ -1049,191 +775,115 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadUintOnly, opStructFieldHeadUintOnly: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = appendUint(b, ptrToUint64(p+code.offset), code) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: + case opStructFieldPtrHeadOmitEmptyUint: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyUint: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - u64 := ptrToUint64(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.offset) v := u64 & code.mask - if v != 0 { + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: + case opStructFieldPtrHeadStringTagUint: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagUint: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadUintPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { + if !code.anonymousHead { b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p + code.offset) - 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 opStructFieldPtrHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - 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 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: + case opStructFieldHeadUintPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -1241,19 +891,34 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtrOnly: + case opStructFieldPtrHeadOmitEmptyUintPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyUintPtrOnly: + case opStructFieldHeadOmitEmptyUintPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) @@ -1262,266 +927,37 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagUintPtrOnly: + case opStructFieldPtrHeadStringTagUintPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagUintPtrOnly: + case opStructFieldHeadStringTagUintPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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, '"') + if code.indirect { + p = ptrToPtr(p + code.offset) } - b = encodeIndentComma(b) - code = code.next - case opStructFieldHeadUintNPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadUint: - 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.offset), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUint: - 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 = 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 opStructFieldPtrAnonymousHeadStringTagUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagUint: - 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.offset), code) - b = append(b, '"') - 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 - case opStructFieldAnonymousHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - 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 = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p + code.offset) - 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 opStructFieldPtrAnonymousHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - 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 = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - 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 { @@ -1532,596 +968,279 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeFloat32(b, ptrToFloat32(p+code.offset)) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only: + case opStructFieldPtrHeadOmitEmptyFloat32: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyFloat32: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat32(p) - if v != 0 { + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat32(p + code.offset) + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: + case opStructFieldPtrHeadStringTagFloat32: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat32: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeFloat32(b, ptrToFloat32(p+code.offset)) b = append(b, '"') b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeFloat32(b, ptrToFloat32(p)) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 = encodeFloat32(b, ptrToFloat32(p)) b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagFloat32PtrOnly: + case opStructFieldPtrHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagFloat32PtrOnly: + case opStructFieldHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } 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 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat32: - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32: - 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 opStructFieldPtrAnonymousHeadStringTagFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32: - 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 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 - case opStructFieldAnonymousHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '{', '\n') - 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 opStructFieldPtrHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - 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 = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + v := ptrToFloat64(p + code.offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + if !code.anonymousHead { + 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: + case opStructFieldPtrHeadOmitEmptyFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyFloat64: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat64(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } - if v != 0 { + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: + case opStructFieldPtrHeadStringTagFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat64: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - v := ptrToFloat64(p) + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } @@ -2130,104 +1249,36 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { + if !code.anonymousHead { 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 opStructFieldPtrHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - 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 opStructFieldPtrHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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: + case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -2239,19 +1290,34 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: + case opStructFieldPtrHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: + case opStructFieldHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) @@ -2264,315 +1330,37 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: + case opStructFieldPtrHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: + case opStructFieldHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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, '"') + if code.indirect { + p = ptrToPtr(p + code.offset) } - b = encodeIndentComma(b) - code = code.next - case opStructFieldHeadFloat64NPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - 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 opStructFieldPtrAnonymousHeadFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat64: - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64: - 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 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 - case opStructFieldAnonymousHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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 { @@ -2587,1038 +1375,1539 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToString(ptr + code.offset) - if v == "" { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - v := ptrToString(ptr + code.offset) - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, v))) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeEscapedString(b, ptrToString(p+code.offset)) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly: + case opStructFieldPtrHeadOmitEmptyString: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyString: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToString(p) - if v != "" { + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToString(p + code.offset) + if v == "" { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly: + case opStructFieldPtrHeadStringTagString: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagString: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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)))) + v := ptrToString(p + code.offset) + b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, v))) b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p)) - } + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeEscapedString(b, ptrToString(p)) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyStringPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeEscapedString(b, ptrToString(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) - } } - 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 + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 = encodeEscapedString(b, ptrToString(p)) b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagStringPtrOnly: + case opStructFieldPtrHeadStringTagStringPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagStringPtrOnly: + case opStructFieldHeadStringTagStringPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } 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 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadString: - 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 opStructFieldPtrAnonymousHeadOmitEmptyString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyString: - 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 opStructFieldPtrAnonymousHeadStringTagString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagString: - 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 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 - case opStructFieldAnonymousHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p+code.offset)))) - } - 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 = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p)))) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToBool(ptr + code.offset) - 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 - } else { - code = code.nextField - } - } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeBool(b, ptrToBool(p+code.offset)) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: + case opStructFieldPtrHeadOmitEmptyBool: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyBool: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToBool(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBool(p + code.offset) 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 + } else { + code = code.nextField } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + case opStructFieldPtrHeadStringTagBool: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagBool: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeBool(b, ptrToBool(p+code.offset)) b = append(b, '"') b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 = encodeBool(b, ptrToBool(p)) b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagBoolPtrOnly: + case opStructFieldPtrHeadStringTagBoolPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagBoolPtrOnly: + case opStructFieldHeadStringTagBoolPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } 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 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadBool: - 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 opStructFieldPtrAnonymousHeadOmitEmptyBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBool: - 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 opStructFieldPtrAnonymousHeadStringTagBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagBool: - 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 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 - case opStructFieldAnonymousHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr)) - b = encodeIndentComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = encodeIndentComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyBytes: - 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 opStructFieldHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - v := ptrToBytes(ptr + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeByteSlice(b, v) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) - code = code.next } + code = code.end.next + break } - case opStructFieldPtrHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBytes(p + code.offset) + if len(v) == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeByteSlice(b, v) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadStringTagBytes: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough - case opStructFieldHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + case opStructFieldHeadStringTagBytes: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next - } else { + break + } + if !code.anonymousHead { b = append(b, '{', '\n') - p := ptr + code.offset + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldHeadNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToNumber(p + code.offset) + if v == "" { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + } + case opStructFieldPtrHeadStringTagNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.escapedKey...) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldPtrHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray, + opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadArray, opStructFieldHeadStringTagArray, + opStructFieldHeadSlice, opStructFieldHeadStringTagSlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyArray: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyArray: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += 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 opStructFieldPtrHeadOmitEmptySlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptySlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += code.offset + slice := ptrToSlice(p) + if slice.data == nil { + code = code.nextField + } else { 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 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr, + opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) + case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr, + opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { b = encodeNull(b) b = encodeIndentComma(b) - code = code.end.next + code = code.nextField } else { + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + code = code.nextField + } else { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMap, opStructFieldHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + if maplen(ptrToUnsafePtr(p)) == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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) + b = encodeIndentComma(b) + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.nextField + } else { + if code.indirect { + p = ptrToPtr(p) + } + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + code = code.nextField + } else { + if code.indirect { + p = ptrToPtr(p) + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if p == 0 && code.nilcheck { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = bb + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = bb + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if p == 0 && code.nilcheck { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb b = encodeIndentComma(b) code = code.next } @@ -3633,7 +2922,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode case opStructFieldOmitEmpty: ptr := load(ctxptr, code.headIdx) p := ptr + code.offset - if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 { + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) @@ -3991,7 +3280,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p)) + b = encodeEscapedString(b, ptrToString(p)) b = encodeIndentComma(b) } code = code.next @@ -4139,197 +3428,355 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } b = encodeIndentComma(b) code = code.next - case opStructFieldMarshalJSON: + case opStructFieldNumber: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, true); err != nil { return nil, err } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { + b = encodeIndentComma(bb) + code = code.next + case opStructFieldOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldStringTagNumber: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { return nil, err } - b = append(b, indentBuf.Bytes()...) + b = append(bb, '"') b = encodeIndentComma(b) code = code.next - case opStructFieldStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructFieldNumberPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, true); err != nil { - return nil, err - } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { - return nil, err - } - b = append(b, indentBuf.Bytes()...) - b = encodeEscapedString(b, indentBuf.String()) - b = encodeIndentComma(b) - code = code.next - case opStructFieldStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeIndentComma(b) - code = code.next - case opStructFieldArray: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - array := ptrToSlice(p) - if p == 0 || uintptr(array.data) == 0 { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField } else { - code = code.next + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldStringTagNumberPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalJSON: + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + code = code.nextField + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + 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 { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, true) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldMarshalText, opStructFieldStringTagMarshalText: + p := load(ctxptr, code.headIdx) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalText: + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + code = code.nextField + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr: + p := load(ctxptr, code.headIdx) + 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 { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), true) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldArray, opStructFieldStringTagArray: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) case opStructFieldOmitEmptyArray: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - array := ptrToSlice(p) - if p == 0 || uintptr(array.data) == 0 { - code = code.nextField - } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptyArrayPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') code = code.next + store(ctxptr, code.idx, p) + } else { + code = code.nextField } - case opStructFieldSlice: + case opStructFieldSlice, opStructFieldStringTagSlice: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - slice := ptrToSlice(p) - if p == 0 || uintptr(slice.data) == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - } else { - code = code.next - } + p := load(ctxptr, code.headIdx) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) case opStructFieldOmitEmptySlice: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p += code.offset slice := ptrToSlice(p) - if p == 0 || uintptr(slice.data) == 0 { + if slice.data == nil { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') code = code.next + store(ctxptr, code.idx, p) } - case opStructFieldMap: + case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - b = encodeNull(b) - code = code.nextField + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptySlicePtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) } else { - p = ptrToPtr(p) - mlen := maplen(ptrToUnsafePtr(p)) - if mlen == 0 { - b = append(b, '{', '}', ',', '\n') - mapCode := code.next - code = mapCode.end.next - } else { - code = code.next - } + code = code.nextField } + case opStructFieldMap, opStructFieldStringTagMap: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) case opStructFieldOmitEmptyMap: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { code = code.nextField } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) } - case opStructFieldMapLoad: + case opStructFieldMapPtr, opStructFieldStringTagMapPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - b = encodeNull(b) - code = code.nextField - } else { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { p = ptrToPtr(p) - mlen := maplen(ptrToUnsafePtr(p)) - if mlen == 0 { - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - code = code.next - } } - case opStructFieldOmitEmptyMapLoad: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - code = code.nextField + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptyMapPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + p = ptrToPtr(p) + } + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.escapedKey...) - b = append(b, ' ') - code = code.next - } + code = code.nextField } case opStructFieldStruct: ptr := load(ctxptr, code.headIdx) @@ -5016,79 +4463,126 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode } code = code.next case opStructEndStringTagBytes: - ptr := load(ctxptr, code.headIdx) b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) + p := load(ctxptr, code.headIdx) + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next - case opStructEndMarshalJSON: + case opStructEndNumber: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, true); err != nil { return nil, err } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { + b = appendStructEndIndent(ctx, bb, code.indent-1) + code = code.next + case opStructEndOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = appendStructEndIndent(ctx, bb, code.indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.indent-1) + b = append(b, '}') + } + b = encodeIndentComma(b) + } + code = code.next + case opStructEndStringTagNumber: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { return nil, err } - b = append(b, indentBuf.Bytes()...) + b = append(bb, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next - case opStructEndStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructEndNumberPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, true); err != nil { - return nil, err - } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { - return nil, err - } - b = encodeEscapedString(b, indentBuf.String()) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next - case opStructEndStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) + case opStructEndOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendStructEndIndent(ctx, bb, code.indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.indent-1) + b = append(b, '}') + } + b = encodeIndentComma(b) + } + code = code.next + case opStructEndStringTagNumberPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') } - b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next case opEnd: diff --git a/encode_vm_indent.go b/encode_vm_indent.go index a05bc9e..fcaf9a1 100644 --- a/encode_vm_indent.go +++ b/encode_vm_indent.go @@ -13,6 +13,7 @@ import ( ) func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) { + recursiveLevel := 0 ptrOffset := uintptr(0) ctxptr := ctx.ptr() code := codeSet.code @@ -75,6 +76,13 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next + case opNumber: + bb, err := encodeNumber(b, ptrToNumber(load(ctxptr, code.idx))) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next case opInterface: ptr := load(ctxptr, code.idx) if ptr == 0 { @@ -194,15 +202,14 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) } code = code.next - case opSliceHead: + case opSlice: p := load(ctxptr, code.idx) - if p == 0 { - b = appendIndent(ctx, b, code.indent) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next } else { - slice := ptrToSlice(p) store(ctxptr, code.elemIdx, 0) store(ctxptr, code.length, uintptr(slice.len)) store(ctxptr, code.idx, uintptr(slice.data)) @@ -213,19 +220,18 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op store(ctxptr, code.idx, uintptr(slice.data)) } else { b = appendIndent(ctx, b, code.indent) - b = append(b, '[', ']', '\n') + b = append(b, '[', ']', ',', '\n') code = code.end.next } } case opRootSliceHead: p := load(ctxptr, code.idx) - if p == 0 { - b = appendIndent(ctx, b, code.indent) + slice := ptrToSlice(p) + if p == 0 || slice.data == nil { b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next } else { - slice := ptrToSlice(p) store(ctxptr, code.elemIdx, 0) store(ctxptr, code.length, uintptr(slice.len)) store(ctxptr, code.idx, uintptr(slice.data)) @@ -274,10 +280,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, ']') code = code.end.next } - case opArrayHead: + case opArray: p := load(ctxptr, code.idx) if p == 0 { - b = appendIndent(ctx, b, code.indent) b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -311,10 +316,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, ']', ',', '\n') code = code.end.next } - case opMapHead: + case opMap: ptr := load(ctxptr, code.idx) if ptr == 0 { - b = appendIndent(ctx, b, code.indent) b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next @@ -342,51 +346,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op store(ctxptr, code.next.idx, uintptr(key)) code = code.next } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '}', ',', '\n') - code = code.end.next - } - } - case opMapHeadLoad: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - code = code.end.next - } else { - // load pointer - ptr = ptrToPtr(ptr) - uptr := ptrToUnsafePtr(ptr) - if uintptr(uptr) == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } - mlen := maplen(uptr) - if mlen > 0 { - b = append(b, '{', '\n') - iter := mapiterinit(code.typ, uptr) - ctx.keepRefs = append(ctx.keepRefs, iter) - store(ctxptr, code.elemIdx, 0) - store(ctxptr, code.length, uintptr(mlen)) - store(ctxptr, code.mapIter, uintptr(iter)) - key := mapiterkey(iter) - store(ctxptr, code.next.idx, uintptr(key)) - - if (opt & EncodeOptionUnorderedMap) == 0 { - mapCtx := newMapContext(mlen) - mapCtx.pos = append(mapCtx.pos, len(b)) - ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx))) - } else { - b = appendIndent(ctx, b, code.next.indent) - } - - code = code.next - } else { - b = appendIndent(ctx, b, code.indent) b = append(b, '{', '}', ',', '\n') code = code.end.next } @@ -481,276 +440,257 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op mapCtx.buf = buf releaseMapContext(mapCtx) code = code.next + case opStructFieldPtrHeadRecursive: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + case opStructFieldRecursive: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + if recursiveLevel > startDetectingCyclesAfter { + for _, seen := range ctx.seenPtr { + if ptr == seen { + return nil, errUnsupportedValue(code, ptr) + } + } + } + } + ctx.seenPtr = append(ctx.seenPtr, ptr) + c := code.jmp.code + curlen := uintptr(len(ctx.ptrs)) + offsetNum := ptrOffset / uintptrSize + oldOffset := ptrOffset + ptrOffset += code.jmp.curLen * uintptrSize + + newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen + if curlen < newLen { + ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...) + } + ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr + + store(ctxptr, c.idx, ptr) + store(ctxptr, c.end.next.idx, oldOffset) + store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next))) + code = c + recursiveLevel++ + case opStructFieldRecursiveEnd: + recursiveLevel-- + + // restore ctxptr + offset := load(ctxptr, code.idx) + ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1] + + codePtr := load(ctxptr, code.elemIdx) + code = (*opcode)(ptrToUnsafePtr(codePtr)) + ctxptr = ctx.ptr() + offset + ptrOffset = offset case opStructFieldPtrHead: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHead: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else if code.next == code.end { - // not exists fields - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '}', ',', '\n') - code = code.end.next - store(ctxptr, code.idx, ptr) - } else { - b = append(b, '{', '\n') - if !code.anonymousKey { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) } - p := ptr + code.offset - code = code.next - store(ctxptr, code.idx, p) - } - case opStructFieldPtrHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmpty: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - p := ptr + code.offset - if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - store(ctxptr, code.idx, p) - } + break } - case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly: - ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey { + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if !code.anonymousKey && len(code.key) > 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') } - p := ptr + code.offset + p += code.offset code = code.next store(ctxptr, code.idx, p) - case opStructFieldHeadOmitEmptyOnly: - ptr := load(ctxptr, code.idx) - b = append(b, '{', '\n') - if !code.anonymousKey && ptr != 0 { + case opStructFieldPtrHeadOmitEmpty: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmpty: + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += code.offset + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { + code = code.nextField + } else { 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))) - fallthrough - case opStructFieldHeadInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagInt: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendInt(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly: + case opStructFieldPtrHeadStringTag: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTag: + p := load(ctxptr, code.idx) + if p == 0 && (code.indirect || code.next.op == opStructEnd) { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += code.offset b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendInt(b, ptrToUint64(p), code) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadInt: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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.offset), code) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: + case opStructFieldPtrHeadOmitEmptyInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyInt: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - u64 := ptrToUint64(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.offset) v := u64 & code.mask - if v != 0 { + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly: + case opStructFieldPtrHeadStringTagInt: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagInt: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = appendInt(b, ptrToUint64(p+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadIntPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { + if !code.anonymousHead { b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - } - 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 - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p + code.offset) - 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 opStructFieldPtrHeadStringTagIntPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - 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, '"') - } - } - 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: + case opStructFieldHeadIntPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -758,19 +698,34 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyIntPtrOnly: + case opStructFieldPtrHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyIntPtrOnly: + case opStructFieldHeadOmitEmptyIntPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) @@ -779,22 +734,37 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagIntPtrOnly: + case opStructFieldPtrHeadStringTagIntPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagIntPtrOnly: + case opStructFieldHeadStringTagIntPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -804,436 +774,117 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldHeadIntNPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendInt(b, ptrToUint64(p), code) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadInt: - 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 opStructFieldPtrAnonymousHeadOmitEmptyInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyInt: - 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 = 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 opStructFieldPtrAnonymousHeadStringTagInt: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagInt: - 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.offset), code) - b = append(b, '"') - 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))) - fallthrough - case opStructFieldAnonymousHeadIntPtr: - p := load(ctxptr, code.idx) - if p == 0 { - 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 = appendInt(b, ptrToUint64(p), code) - } - 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) - 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 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 - } - 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, '"') - } - 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 { - b = append(b, '"') - b = appendInt(b, ptrToUint64(p), code) - b = append(b, '"') - } - b = encodeIndentComma(b) - code = code.next + case opStructFieldPtrHeadUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = encodeIndentComma(b) - code = code.next + break } + if !code.anonymousHead { + 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.offset), code) + b = encodeIndentComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyUint: - 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 opStructFieldHeadOmitEmptyUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - u64 := ptrToUint64(ptr + code.offset) - v := u64 & code.mask - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = appendUint(b, u64, code) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) - code = code.next } - } - case opStructFieldPtrHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagUint: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset), code) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next + break } - 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) + if !code.anonymousHead { + b = append(b, '{', '\n') + } + u64 := ptrToUint64(p + code.offset) v := u64 & code.mask - if v != 0 { + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagUintOnly, opStructFieldHeadStringTagUintOnly: + case opStructFieldPtrHeadStringTagUint: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagUint: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadUintPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - if p == 0 { + if !code.anonymousHead { b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p + code.offset) - 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 opStructFieldPtrHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p + code.offset) - 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 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: + case opStructFieldHeadUintPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -1241,19 +892,34 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyUintPtrOnly: + case opStructFieldPtrHeadOmitEmptyUintPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyUintPtrOnly: + case opStructFieldHeadOmitEmptyUintPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) @@ -1262,266 +928,37 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagUintPtrOnly: + case opStructFieldPtrHeadStringTagUintPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagUintPtrOnly: + case opStructFieldHeadStringTagUintPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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, '"') + if code.indirect { + p = ptrToPtr(p + code.offset) } - b = encodeIndentComma(b) - code = code.next - case opStructFieldHeadUintNPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = appendUint(b, ptrToUint64(p), code) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadUint: - 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.offset), code) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadOmitEmptyUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUint: - 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 = 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 opStructFieldPtrAnonymousHeadStringTagUint: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagUint: - 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.offset), code) - b = append(b, '"') - 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 - case opStructFieldAnonymousHeadUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - 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 = appendUint(b, ptrToUint64(p), code) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p + code.offset) - 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 opStructFieldPtrAnonymousHeadStringTagUintPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagUintPtr: - p := load(ctxptr, code.idx) - if p == 0 { - 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 = appendUint(b, ptrToUint64(p), code) - b = append(b, '"') - } - 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 { @@ -1532,596 +969,279 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToFloat32(ptr + code.offset) - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat32: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeFloat32(b, ptrToFloat32(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadFloat32Only, opStructFieldHeadFloat32Only: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeFloat32(b, ptrToFloat32(p+code.offset)) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat32Only, opStructFieldHeadOmitEmptyFloat32Only: + case opStructFieldPtrHeadOmitEmptyFloat32: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyFloat32: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat32(p) - if v != 0 { + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat32(p + code.offset) + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagFloat32Only, opStructFieldHeadStringTagFloat32Only: + case opStructFieldPtrHeadStringTagFloat32: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat32: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeFloat32(b, ptrToFloat32(p+code.offset)) b = append(b, '"') b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeFloat32(b, ptrToFloat32(p)) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyFloat32Ptr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat32(b, ptrToFloat32(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 opStructFieldPtrHeadFloat32PtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 = encodeFloat32(b, ptrToFloat32(p)) b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagFloat32PtrOnly: + case opStructFieldPtrHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagFloat32PtrOnly: + case opStructFieldHeadStringTagFloat32Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } 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 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeFloat32(b, ptrToFloat32(p)) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat32: - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32: - 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 opStructFieldPtrAnonymousHeadStringTagFloat32: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32: - 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 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 - case opStructFieldAnonymousHeadFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { b = encodeFloat32(b, ptrToFloat32(p)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagFloat32Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat32Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - v := ptrToFloat64(ptr) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '{', '\n') - 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 opStructFieldPtrHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v == 0 { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - 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 = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadFloat64Only, opStructFieldHeadFloat64Only: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + v := ptrToFloat64(p + code.offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + if !code.anonymousHead { + 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: + case opStructFieldPtrHeadOmitEmptyFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyFloat64: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToFloat64(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } - if v != 0 { + if v == 0 { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagFloat64Only, opStructFieldHeadStringTagFloat64Only: + case opStructFieldPtrHeadStringTagFloat64: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagFloat64: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ', '"') - v := ptrToFloat64(p) + v := ptrToFloat64(p + code.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return nil, errUnsupportedFloat(v) } @@ -2130,104 +1250,36 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { + if !code.anonymousHead { 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 opStructFieldPtrHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - 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 opStructFieldPtrHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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: + case opStructFieldHeadFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p == 0 { b = encodeNull(b) } else { @@ -2239,19 +1291,34 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyFloat64PtrOnly: + case opStructFieldPtrHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadOmitEmptyFloat64PtrOnly: + case opStructFieldHeadOmitEmptyFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } if p != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) @@ -2264,315 +1331,37 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagFloat64PtrOnly: + case opStructFieldPtrHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagFloat64PtrOnly: + case opStructFieldHeadStringTagFloat64Ptr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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, '"') + if code.indirect { + p = ptrToPtr(p + code.offset) } - b = encodeIndentComma(b) - code = code.next - case opStructFieldHeadFloat64NPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - 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 opStructFieldPtrAnonymousHeadFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadFloat64: - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToFloat64(ptr + code.offset) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if v == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeFloat64(b, v) - b = encodeIndentComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadStringTagFloat64: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64: - 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 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 - case opStructFieldAnonymousHeadFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadOmitEmptyFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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 opStructFieldPtrAnonymousHeadStringTagFloat64Ptr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagFloat64Ptr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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 { @@ -2587,1038 +1376,1539 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToString(ptr + code.offset) - if v == "" { - code = code.nextField - } else { - 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 opStructFieldPtrHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagString: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - v := ptrToString(ptr + code.offset) - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, v))) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadStringOnly, opStructFieldHeadStringOnly: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeNoEscapedString(b, ptrToString(p+code.offset)) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyStringOnly, opStructFieldHeadOmitEmptyStringOnly: + case opStructFieldPtrHeadOmitEmptyString: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyString: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToString(p) - if v != "" { + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToString(p + code.offset) + if v == "" { + code = code.nextField + } else { 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 } - code = code.next - case opStructFieldPtrHeadStringTagStringOnly, opStructFieldHeadStringTagStringOnly: + case opStructFieldPtrHeadStringTagString: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagString: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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)))) + v := ptrToString(p + code.offset) + b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, v))) b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadStringPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p)) - } + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeNoEscapedString(b, ptrToString(p)) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyStringPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeNoEscapedString(b, ptrToString(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) - } } - 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 + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 = encodeNoEscapedString(b, ptrToString(p)) b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagStringPtrOnly: + case opStructFieldPtrHeadStringTagStringPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagStringPtrOnly: + case opStructFieldHeadStringTagStringPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } 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 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadString: - 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 opStructFieldPtrAnonymousHeadOmitEmptyString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyString: - 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 opStructFieldPtrAnonymousHeadStringTagString: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagString: - 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 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 - case opStructFieldAnonymousHeadStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, ptrToString(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagStringPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagStringPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p+code.offset)))) - } - 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 = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p)))) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(ptr)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - v := ptrToBool(ptr + code.offset) - 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 - } else { - code = code.nextField - } - } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeBool(b, ptrToBool(p+code.offset)) b = encodeIndentComma(b) code = code.next - case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: + case opStructFieldPtrHeadOmitEmptyBool: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyBool: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') - v := ptrToBool(p) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBool(p + code.offset) 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 + } else { + code = code.nextField } - code = code.next - case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + case opStructFieldPtrHeadStringTagBool: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagBool: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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 = encodeBool(b, ptrToBool(p+code.offset)) b = append(b, '"') b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) } b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough case opStructFieldHeadOmitEmptyBoolPtr: p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - p = ptrToPtr(p) - if p != 0 { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, ptrToBool(p)) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) } - code = code.next - } - case opStructFieldPtrHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) code = code.end.next break - } else { + } + if !code.anonymousHead { b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 opStructFieldPtrHeadBoolPtrOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - break + if code.indirect { + p = ptrToPtr(p + code.offset) } - 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 = encodeBool(b, ptrToBool(p)) b = encodeIndentComma(b) } code = code.next - case opStructFieldPtrHeadStringTagBoolPtrOnly: + case opStructFieldPtrHeadStringTagBoolPtr: p := load(ctxptr, code.idx) if p == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next break } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagBoolPtrOnly: + case opStructFieldHeadStringTagBoolPtr: p := load(ctxptr, code.idx) - b = append(b, '{', '\n') + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } 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 { - b = encodeNull(b) - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - for i := 0; i < code.ptrNum; i++ { - if p == 0 { - break - } - p = ptrToPtr(p) - } - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadBool: - 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 opStructFieldPtrAnonymousHeadOmitEmptyBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBool: - 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 opStructFieldPtrAnonymousHeadStringTagBool: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagBool: - 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 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 - case opStructFieldAnonymousHeadBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - if p == 0 { - b = encodeNull(b) - } else { - b = encodeBool(b, ptrToBool(p+code.offset)) - } - b = encodeIndentComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - p = ptrToPtr(p) - 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)) - b = encodeIndentComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBoolPtr: - store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) - fallthrough - case opStructFieldAnonymousHeadStringTagBoolPtr: - p := load(ctxptr, code.idx) - if p == 0 { - code = code.end.next - break - } - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p = ptrToPtr(p) - 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 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))) + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } fallthrough case opStructFieldHeadBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr)) - b = encodeIndentComma(b) - code = code.next + break } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = encodeIndentComma(b) + code = code.next case opStructFieldPtrHeadOmitEmptyBytes: - 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 opStructFieldHeadOmitEmptyBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - v := ptrToBytes(ptr + code.offset) - if len(v) == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeByteSlice(b, v) + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) b = encodeIndentComma(b) - code = code.next } + code = code.end.next + break } - case opStructFieldPtrHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToBytes(p + code.offset) + if len(v) == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeByteSlice(b, v) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadStringTagBytes: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) } fallthrough - case opStructFieldHeadStringTag: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) + case opStructFieldHeadStringTagBytes: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } code = code.end.next - } else { + break + } + if !code.anonymousHead { b = append(b, '{', '\n') - p := ptr + code.offset + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p+code.offset)) + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBytesPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeByteSlice(b, ptrToBytes(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldHeadNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + v := ptrToNumber(p + code.offset) + if v == "" { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + } + case opStructFieldPtrHeadStringTagNumber: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadStringTagNumber: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { + return nil, err + } + b = append(bb, '"') + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p != 0 { + b = append(b, code.key...) + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldPtrHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagNumberPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray, + opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadArray, opStructFieldHeadStringTagArray, + opStructFieldHeadSlice, opStructFieldHeadStringTagSlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyArray: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptyArray: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += 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 opStructFieldPtrHeadOmitEmptySlice: + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + } + fallthrough + case opStructFieldHeadOmitEmptySlice: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + p += code.offset + slice := ptrToSlice(p) + if slice.data == nil { + code = code.nextField + } else { 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 { - store(ctxptr, code.idx, ptrToPtr(ptr)) + case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr, + opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadStringTagBytes: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) + case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr, + opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { b = encodeNull(b) b = encodeIndentComma(b) - code = code.end.next + code = code.nextField } else { + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { b = append(b, '{', '\n') + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + code = code.nextField + } else { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMap, opStructFieldHeadStringTagMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldPtrHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMap: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p != 0 && code.indirect { + p = ptrToPtr(p + code.offset) + } + if maplen(ptrToUnsafePtr(p)) == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + 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) + b = encodeIndentComma(b) + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.nextField + } else { + if code.indirect { + p = ptrToPtr(p) + } + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMapPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.nextField + break + } + p = ptrToPtr(p + code.offset) + if p == 0 { + code = code.nextField + } else { + if code.indirect { + p = ptrToPtr(p) + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) + } + case opStructFieldPtrHeadMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSON: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON { + p = ptrToPtr(p + code.offset) + } + } + if p == 0 && code.nilcheck { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = bb + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = bb + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadStringTagMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if code.nilcheck && p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + store(ctxptr, code.idx, ptrToPtr(p)) + } + fallthrough + case opStructFieldHeadOmitEmptyMarshalText: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if code.typ.Kind() == reflect.Ptr { + if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText { + p = ptrToPtr(p + code.offset) + } + } + if p == 0 && code.nilcheck { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.idx) + if p == 0 && code.indirect { + if !code.anonymousHead { + b = encodeNull(b) + b = encodeIndentComma(b) + } + code = code.end.next + break + } + if code.indirect { + p = ptrToPtr(p + code.offset) + } + if !code.anonymousHead { + b = append(b, '{', '\n') + } + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb b = encodeIndentComma(b) code = code.next } @@ -3633,7 +2923,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op case opStructFieldOmitEmpty: ptr := load(ctxptr, code.headIdx) p := ptr + code.offset - if p == 0 || **(**uintptr)(unsafe.Pointer(&p)) == 0 { + if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) @@ -4139,196 +3429,355 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op } b = encodeIndentComma(b) code = code.next - case opStructFieldMarshalJSON: + case opStructFieldNumber: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, false); err != nil { return nil, err } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { + b = encodeIndentComma(bb) + code = code.next + case opStructFieldOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldStringTagNumber: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { return nil, err } - b = append(b, indentBuf.Bytes()...) + b = append(bb, '"') b = encodeIndentComma(b) code = code.next - case opStructFieldStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructFieldNumberPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) - } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, false); err != nil { - return nil, err - } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { - return nil, err - } - b = encodeNoEscapedString(b, indentBuf.String()) - b = encodeIndentComma(b) - code = code.next - case opStructFieldStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) - } - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) - b = encodeIndentComma(b) - code = code.next - case opStructFieldArray: - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - array := ptrToSlice(p) - if p == 0 || uintptr(array.data) == 0 { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField } else { - code = code.next + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldStringTagNumberPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + b = encodeNull(b) + } else { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalJSON: + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + code = code.nextField + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + 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 { + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalJSONPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalJSONIndent(ctx, code, b, ptrToInterface(code, p), code.indent, false) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldMarshalText, opStructFieldStringTagMarshalText: + p := load(ctxptr, code.headIdx) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + b = encodeNull(b) + } else { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalText: + p := load(ctxptr, code.headIdx) + p += code.offset + if code.typ.Kind() == reflect.Ptr { + p = ptrToPtr(p) + } + if p == 0 && code.nilcheck { + code = code.nextField + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + code = code.next + case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr: + p := load(ctxptr, code.headIdx) + 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 { + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = bb + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyMarshalTextPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeMarshalTextIndent(code, b, ptrToInterface(code, p), false) + if err != nil { + return nil, err + } + b = encodeIndentComma(bb) + } + code = code.next + case opStructFieldArray, opStructFieldStringTagArray: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) case opStructFieldOmitEmptyArray: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - array := ptrToSlice(p) - if p == 0 || uintptr(array.data) == 0 { - code = code.nextField - } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptyArrayPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') code = code.next + store(ctxptr, code.idx, p) + } else { + code = code.nextField } - case opStructFieldSlice: + case opStructFieldSlice, opStructFieldStringTagSlice: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - slice := ptrToSlice(p) - if p == 0 || uintptr(slice.data) == 0 { - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.nextField - } else { - code = code.next - } + p := load(ctxptr, code.headIdx) + p += code.offset + code = code.next + store(ctxptr, code.idx, p) case opStructFieldOmitEmptySlice: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset + p := load(ctxptr, code.headIdx) + p += code.offset slice := ptrToSlice(p) - if p == 0 || uintptr(slice.data) == 0 { + if slice.data == nil { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') code = code.next + store(ctxptr, code.idx, p) } - case opStructFieldMap: + case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - b = encodeNull(b) - code = code.nextField + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptySlicePtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) } else { - p = ptrToPtr(p) - mlen := maplen(ptrToUnsafePtr(p)) - if mlen == 0 { - b = append(b, '{', '}', ',', '\n') - mapCode := code.next - code = mapCode.end.next - } else { - code = code.next - } + code = code.nextField } + case opStructFieldMap, opStructFieldStringTagMap: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + code = code.next + store(ctxptr, code.idx, p) case opStructFieldOmitEmptyMap: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { code = code.nextField } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) } - case opStructFieldMapLoad: + case opStructFieldMapPtr, opStructFieldStringTagMapPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - b = encodeNull(b) - code = code.nextField - } else { + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { p = ptrToPtr(p) - mlen := maplen(ptrToUnsafePtr(p)) - if mlen == 0 { - b = append(b, '{', '}', ',', '\n') - code = code.nextField - } else { - code = code.next - } } - case opStructFieldOmitEmptyMapLoad: - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - if p == 0 { - code = code.nextField + code = code.next + store(ctxptr, code.idx, p) + case opStructFieldOmitEmptyMapPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + p = ptrToPtr(p) + } + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + code = code.next + store(ctxptr, code.idx, p) } else { - mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p))) - if mlen == 0 { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, code.key...) - b = append(b, ' ') - code = code.next - } + code = code.nextField } case opStructFieldStruct: ptr := load(ctxptr, code.headIdx) @@ -5022,72 +4471,119 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next - case opStructEndMarshalJSON: + case opStructEndNumber: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - ptr := load(ctxptr, code.headIdx) - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) if err != nil { - return nil, errMarshaler(code, err) - } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, false); err != nil { return nil, err } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { + b = appendStructEndIndent(ctx, bb, code.indent-1) + code = code.next + case opStructEndOmitEmptyNumber: + p := load(ctxptr, code.headIdx) + v := ptrToNumber(p + code.offset) + if v != "" { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeNumber(b, v) + if err != nil { + return nil, err + } + b = appendStructEndIndent(ctx, bb, code.indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.indent-1) + b = append(b, '}') + } + b = encodeIndentComma(b) + } + code = code.next + case opStructEndStringTagNumber: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = append(b, '"') + p := load(ctxptr, code.headIdx) + bb, err := encodeNumber(b, ptrToNumber(p+code.offset)) + if err != nil { return nil, err } - b = append(b, indentBuf.Bytes()...) + b = append(bb, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next - case opStructEndStringTagMarshalJSON: - ptr := load(ctxptr, code.headIdx) + case opStructEndNumberPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bb, err := v.(Marshaler).MarshalJSON() - if err != nil { - return nil, errMarshaler(code, err) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = bb } - var compactBuf bytes.Buffer - if err := compact(&compactBuf, bb, false); err != nil { - return nil, err - } - var indentBuf bytes.Buffer - if err := encodeWithIndent( - &indentBuf, - compactBuf.Bytes(), - string(ctx.prefix)+strings.Repeat(string(ctx.indentStr), ctx.baseIndent+code.indent), - string(ctx.indentStr), - ); err != nil { - return nil, err - } - b = encodeNoEscapedString(b, indentBuf.String()) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next - case opStructEndStringTagMarshalText: - ptr := load(ctxptr, code.headIdx) + case opStructEndOmitEmptyNumberPtr: + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = appendStructEndIndent(ctx, bb, code.indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.indent-1) + b = append(b, '}') + } + b = encodeIndentComma(b) + } + code = code.next + case opStructEndStringTagNumberPtr: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - p := ptr + code.offset - v := ptrToInterface(code, p) - bytes, err := v.(encoding.TextMarshaler).MarshalText() - if err != nil { - return nil, errMarshaler(code, err) + p := load(ctxptr, code.headIdx) + p = ptrToPtr(p + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + bb, err := encodeNumber(b, ptrToNumber(p)) + if err != nil { + return nil, err + } + b = append(bb, '"') } - b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next case opEnd: diff --git a/json.go b/json.go index b3f7ae6..d4a92d6 100644 --- a/json.go +++ b/json.go @@ -2,8 +2,8 @@ package json import ( "bytes" + "encoding/json" "errors" - "strconv" ) // Marshaler is the interface implemented by types that @@ -281,39 +281,7 @@ func UnmarshalNoEscape(data []byte, v interface{}) error { type Token interface{} // A Number represents a JSON number literal. -type Number string - -// String returns the literal text of the number. -func (n Number) String() string { return string(n) } - -// Float64 returns the number as a float64. -func (n Number) Float64() (float64, error) { - return strconv.ParseFloat(string(n), 64) -} - -// Int64 returns the number as an int64. -func (n Number) Int64() (int64, error) { - return strconv.ParseInt(string(n), 10, 64) -} - -func (n Number) MarshalJSON() ([]byte, error) { - if n == "" { - return []byte("0"), nil - } - if _, err := n.Float64(); err != nil { - return nil, err - } - return []byte(n), nil -} - -func (n *Number) UnmarshalJSON(b []byte) error { - s := string(b) - if _, err := strconv.ParseFloat(s, 64); err != nil { - return &SyntaxError{msg: err.Error()} - } - *n = Number(s) - return nil -} +type Number = json.Number // RawMessage is a raw encoded JSON value. // It implements Marshaler and Unmarshaler and can 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