Refactor StringTag operation

This commit is contained in:
Masaaki Goshima 2021-05-06 20:54:22 +09:00
parent 46bdba4a65
commit 56dabe2da4
11 changed files with 1013 additions and 2207 deletions

View File

@ -100,7 +100,7 @@ func (t OpType) HeadToPtrHead() OpType {
} }
suffix := "PtrHead"+t.String()[idx+len("Head"):] suffix := "PtrHead"+t.String()[idx+len("Head"):]
const toPtrOffset = 3 const toPtrOffset = 2
if strings.Contains(OpType(int(t) + toPtrOffset).String(), suffix) { if strings.Contains(OpType(int(t) + toPtrOffset).String(), suffix) {
return OpType(int(t) + toPtrOffset) return OpType(int(t) + toPtrOffset)
} }
@ -116,14 +116,6 @@ func (t OpType) HeadToOmitEmptyHead() OpType {
return t return t
} }
func (t OpType) HeadToStringTagHead() OpType {
const toStringTagOffset = 2
if strings.Contains(OpType(int(t) + toStringTagOffset).String(), "StringTag") {
return OpType(int(t) + toStringTagOffset)
}
return t
}
func (t OpType) PtrHeadToHead() OpType { func (t OpType) PtrHeadToHead() OpType {
idx := strings.Index(t.String(), "Ptr") idx := strings.Index(t.String(), "Ptr")
if idx == -1 { if idx == -1 {
@ -131,7 +123,7 @@ func (t OpType) PtrHeadToHead() OpType {
} }
suffix := t.String()[idx+len("Ptr"):] suffix := t.String()[idx+len("Ptr"):]
const toPtrOffset = 3 const toPtrOffset = 2
if strings.Contains(OpType(int(t) - toPtrOffset).String(), suffix) { if strings.Contains(OpType(int(t) - toPtrOffset).String(), suffix) {
return OpType(int(t) - toPtrOffset) return OpType(int(t) - toPtrOffset)
} }
@ -144,10 +136,10 @@ func (t OpType) FieldToEnd() OpType {
return t return t
} }
suffix := t.String()[idx+len("Field"):] suffix := t.String()[idx+len("Field"):]
if suffix == "" || suffix == "OmitEmpty" || suffix == "StringTag" { if suffix == "" || suffix == "OmitEmpty" {
return t return t
} }
const toEndOffset = 3 const toEndOffset = 2
if strings.Contains(OpType(int(t) + toEndOffset).String(), "End"+suffix) { if strings.Contains(OpType(int(t) + toEndOffset).String(), "End"+suffix) {
return OpType(int(t) + toEndOffset) return OpType(int(t) + toEndOffset)
} }
@ -161,15 +153,6 @@ func (t OpType) FieldToOmitEmptyField() OpType {
} }
return t return t
} }
func (t OpType) FieldToStringTagField() OpType {
const toStringTagOffset = 2
if strings.Contains(OpType(int(t) + toStringTagOffset).String(), "StringTag") {
return OpType(int(t) + toStringTagOffset)
}
return t
}
`) `)
if err != nil { if err != nil {
return err return err
@ -191,9 +174,10 @@ func (t OpType) FieldToStringTagField() OpType {
primitiveTypes := []string{ primitiveTypes := []string{
"int", "uint", "float32", "float64", "bool", "string", "bytes", "number", "int", "uint", "float32", "float64", "bool", "string", "bytes", "number",
"array", "map", "slice", "struct", "MarshalJSON", "MarshalText", "array", "map", "slice", "struct", "MarshalJSON", "MarshalText",
"intString", "uintString", "intString", "uintString", "float32String", "float64String", "boolString", "stringString", "numberString",
"intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr", "numberPtr", "intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr", "numberPtr",
"arrayPtr", "mapPtr", "slicePtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr", "arrayPtr", "mapPtr", "slicePtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr",
"intPtrString", "uintPtrString", "float32PtrString", "float64PtrString", "boolPtrString", "stringPtrString", "numberPtrString",
} }
primitiveTypesUpper := []string{} primitiveTypesUpper := []string{}
for _, typ := range primitiveTypes { for _, typ := range primitiveTypes {
@ -221,7 +205,7 @@ func (t OpType) FieldToStringTagField() OpType {
} }
for _, typ := range append(primitiveTypesUpper, "") { for _, typ := range append(primitiveTypesUpper, "") {
for _, ptrOrNot := range []string{"", "Ptr"} { for _, ptrOrNot := range []string{"", "Ptr"} {
for _, opt := range []string{"", "OmitEmpty", "StringTag"} { for _, opt := range []string{"", "OmitEmpty"} {
ptrOrNot := ptrOrNot ptrOrNot := ptrOrNot
opt := opt opt := opt
typ := typ typ := typ
@ -240,7 +224,7 @@ func (t OpType) FieldToStringTagField() OpType {
} }
} }
for _, typ := range append(primitiveTypesUpper, "") { for _, typ := range append(primitiveTypesUpper, "") {
for _, opt := range []string{"", "OmitEmpty", "StringTag"} { for _, opt := range []string{"", "OmitEmpty"} {
opt := opt opt := opt
typ := typ typ := typ
@ -254,7 +238,7 @@ func (t OpType) FieldToStringTagField() OpType {
Code: "StructField", Code: "StructField",
}) })
} }
for _, opt := range []string{"", "OmitEmpty", "StringTag"} { for _, opt := range []string{"", "OmitEmpty"} {
opt := opt opt := opt
typ := typ typ := typ

View File

@ -1019,23 +1019,17 @@ func compileMapValue(ctx *compileContext) (*Opcode, error) {
} }
func optimizeStructHeader(code *Opcode, tag *runtime.StructTag) OpType { func optimizeStructHeader(code *Opcode, tag *runtime.StructTag) OpType {
headType := code.ToHeaderType() headType := code.ToHeaderType(tag.IsString)
switch { if tag.IsOmitEmpty {
case tag.IsOmitEmpty:
headType = headType.HeadToOmitEmptyHead() headType = headType.HeadToOmitEmptyHead()
case tag.IsString:
headType = headType.HeadToStringTagHead()
} }
return headType return headType
} }
func optimizeStructField(code *Opcode, tag *runtime.StructTag) OpType { func optimizeStructField(code *Opcode, tag *runtime.StructTag) OpType {
fieldType := code.ToFieldType() fieldType := code.ToFieldType(tag.IsString)
switch { if tag.IsOmitEmpty {
case tag.IsOmitEmpty:
fieldType = fieldType.FieldToOmitEmptyField() fieldType = fieldType.FieldToOmitEmptyField()
case tag.IsString:
fieldType = fieldType.FieldToStringTagField()
} }
return fieldType return fieldType
} }

View File

@ -41,38 +41,24 @@ func (t OpType) IsMultipleOpHead() bool {
return true return true
case OpStructHeadOmitEmptySlice: case OpStructHeadOmitEmptySlice:
return true return true
case OpStructHeadStringTagSlice:
return true
case OpStructHeadOmitEmptyArray: case OpStructHeadOmitEmptyArray:
return true return true
case OpStructHeadStringTagArray:
return true
case OpStructHeadOmitEmptyMap: case OpStructHeadOmitEmptyMap:
return true return true
case OpStructHeadStringTagMap:
return true
case OpStructHeadOmitEmptyStruct: case OpStructHeadOmitEmptyStruct:
return true return true
case OpStructHeadStringTag:
return true
case OpStructHeadSlicePtr: case OpStructHeadSlicePtr:
return true return true
case OpStructHeadOmitEmptySlicePtr: case OpStructHeadOmitEmptySlicePtr:
return true return true
case OpStructHeadStringTagSlicePtr:
return true
case OpStructHeadArrayPtr: case OpStructHeadArrayPtr:
return true return true
case OpStructHeadOmitEmptyArrayPtr: case OpStructHeadOmitEmptyArrayPtr:
return true return true
case OpStructHeadStringTagArrayPtr:
return true
case OpStructHeadMapPtr: case OpStructHeadMapPtr:
return true return true
case OpStructHeadOmitEmptyMapPtr: case OpStructHeadOmitEmptyMapPtr:
return true return true
case OpStructHeadStringTagMapPtr:
return true
} }
return false return false
} }
@ -93,38 +79,24 @@ func (t OpType) IsMultipleOpField() bool {
return true return true
case OpStructFieldOmitEmptySlice: case OpStructFieldOmitEmptySlice:
return true return true
case OpStructFieldStringTagSlice:
return true
case OpStructFieldOmitEmptyArray: case OpStructFieldOmitEmptyArray:
return true return true
case OpStructFieldStringTagArray:
return true
case OpStructFieldOmitEmptyMap: case OpStructFieldOmitEmptyMap:
return true return true
case OpStructFieldStringTagMap:
return true
case OpStructFieldOmitEmptyStruct: case OpStructFieldOmitEmptyStruct:
return true return true
case OpStructFieldStringTag:
return true
case OpStructFieldSlicePtr: case OpStructFieldSlicePtr:
return true return true
case OpStructFieldOmitEmptySlicePtr: case OpStructFieldOmitEmptySlicePtr:
return true return true
case OpStructFieldStringTagSlicePtr:
return true
case OpStructFieldArrayPtr: case OpStructFieldArrayPtr:
return true return true
case OpStructFieldOmitEmptyArrayPtr: case OpStructFieldOmitEmptyArrayPtr:
return true return true
case OpStructFieldStringTagArrayPtr:
return true
case OpStructFieldMapPtr: case OpStructFieldMapPtr:
return true return true
case OpStructFieldOmitEmptyMapPtr: case OpStructFieldOmitEmptyMapPtr:
return true return true
case OpStructFieldStringTagMapPtr:
return true
} }
return false return false
} }

View File

@ -68,35 +68,77 @@ func (c *Opcode) setMaskAndRshiftNum(bitSize uint8) {
c.RshiftNum = rshitNum(bitSize) c.RshiftNum = rshitNum(bitSize)
} }
func (c *Opcode) ToHeaderType() OpType { func (c *Opcode) ToHeaderType(isString bool) OpType {
switch c.Op { switch c.Op {
case OpInt: case OpInt:
if isString {
return OpStructHeadIntString
}
return OpStructHeadInt return OpStructHeadInt
case OpIntPtr: case OpIntPtr:
if isString {
return OpStructHeadIntPtrString
}
return OpStructHeadIntPtr return OpStructHeadIntPtr
case OpUint: case OpUint:
if isString {
return OpStructHeadUintString
}
return OpStructHeadUint return OpStructHeadUint
case OpUintPtr: case OpUintPtr:
if isString {
return OpStructHeadUintPtrString
}
return OpStructHeadUintPtr return OpStructHeadUintPtr
case OpFloat32: case OpFloat32:
if isString {
return OpStructHeadFloat32String
}
return OpStructHeadFloat32 return OpStructHeadFloat32
case OpFloat32Ptr: case OpFloat32Ptr:
if isString {
return OpStructHeadFloat32PtrString
}
return OpStructHeadFloat32Ptr return OpStructHeadFloat32Ptr
case OpFloat64: case OpFloat64:
if isString {
return OpStructHeadFloat64String
}
return OpStructHeadFloat64 return OpStructHeadFloat64
case OpFloat64Ptr: case OpFloat64Ptr:
if isString {
return OpStructHeadFloat64PtrString
}
return OpStructHeadFloat64Ptr return OpStructHeadFloat64Ptr
case OpString: case OpString:
if isString {
return OpStructHeadStringString
}
return OpStructHeadString return OpStructHeadString
case OpStringPtr: case OpStringPtr:
if isString {
return OpStructHeadStringPtrString
}
return OpStructHeadStringPtr return OpStructHeadStringPtr
case OpNumber: case OpNumber:
if isString {
return OpStructHeadNumberString
}
return OpStructHeadNumber return OpStructHeadNumber
case OpNumberPtr: case OpNumberPtr:
if isString {
return OpStructHeadNumberPtrString
}
return OpStructHeadNumberPtr return OpStructHeadNumberPtr
case OpBool: case OpBool:
if isString {
return OpStructHeadBoolString
}
return OpStructHeadBool return OpStructHeadBool
case OpBoolPtr: case OpBoolPtr:
if isString {
return OpStructHeadBoolPtrString
}
return OpStructHeadBoolPtr return OpStructHeadBoolPtr
case OpBytes: case OpBytes:
return OpStructHeadBytes return OpStructHeadBytes
@ -129,35 +171,77 @@ func (c *Opcode) ToHeaderType() OpType {
return OpStructHead return OpStructHead
} }
func (c *Opcode) ToFieldType() OpType { func (c *Opcode) ToFieldType(isString bool) OpType {
switch c.Op { switch c.Op {
case OpInt: case OpInt:
if isString {
return OpStructFieldIntString
}
return OpStructFieldInt return OpStructFieldInt
case OpIntPtr: case OpIntPtr:
if isString {
return OpStructFieldIntPtrString
}
return OpStructFieldIntPtr return OpStructFieldIntPtr
case OpUint: case OpUint:
if isString {
return OpStructFieldUintString
}
return OpStructFieldUint return OpStructFieldUint
case OpUintPtr: case OpUintPtr:
if isString {
return OpStructFieldUintPtrString
}
return OpStructFieldUintPtr return OpStructFieldUintPtr
case OpFloat32: case OpFloat32:
if isString {
return OpStructFieldFloat32String
}
return OpStructFieldFloat32 return OpStructFieldFloat32
case OpFloat32Ptr: case OpFloat32Ptr:
if isString {
return OpStructFieldFloat32PtrString
}
return OpStructFieldFloat32Ptr return OpStructFieldFloat32Ptr
case OpFloat64: case OpFloat64:
if isString {
return OpStructFieldFloat64String
}
return OpStructFieldFloat64 return OpStructFieldFloat64
case OpFloat64Ptr: case OpFloat64Ptr:
if isString {
return OpStructFieldFloat64PtrString
}
return OpStructFieldFloat64Ptr return OpStructFieldFloat64Ptr
case OpString: case OpString:
if isString {
return OpStructFieldStringString
}
return OpStructFieldString return OpStructFieldString
case OpStringPtr: case OpStringPtr:
if isString {
return OpStructFieldStringPtrString
}
return OpStructFieldStringPtr return OpStructFieldStringPtr
case OpNumber: case OpNumber:
if isString {
return OpStructFieldNumberString
}
return OpStructFieldNumber return OpStructFieldNumber
case OpNumberPtr: case OpNumberPtr:
if isString {
return OpStructFieldNumberPtrString
}
return OpStructFieldNumberPtr return OpStructFieldNumberPtr
case OpBool: case OpBool:
if isString {
return OpStructFieldBoolString
}
return OpStructFieldBool return OpStructFieldBool
case OpBoolPtr: case OpBoolPtr:
if isString {
return OpStructFieldBoolPtrString
}
return OpStructFieldBoolPtr return OpStructFieldBoolPtr
case OpBytes: case OpBytes:
return OpStructFieldBytes return OpStructFieldBytes

File diff suppressed because it is too large Load Diff

View File

@ -628,35 +628,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 encoder.OpStructPtrHeadInt: case encoder.OpStructPtrHeadInt:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -725,7 +696,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagInt: case encoder.OpStructPtrHeadIntString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -739,7 +710,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagInt: case encoder.OpStructHeadIntString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -828,7 +799,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagIntPtr: case encoder.OpStructPtrHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -840,7 +811,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagIntPtr: case encoder.OpStructHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -934,7 +905,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagUint: case encoder.OpStructPtrHeadUintString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -948,7 +919,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagUint: case encoder.OpStructHeadUintString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1037,7 +1008,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagUintPtr: case encoder.OpStructPtrHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1049,7 +1020,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagUintPtr: case encoder.OpStructHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1142,7 +1113,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat32: case encoder.OpStructPtrHeadFloat32String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1156,7 +1127,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32: case encoder.OpStructHeadFloat32String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1245,7 +1216,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat32Ptr: case encoder.OpStructPtrHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1257,7 +1228,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32Ptr: case encoder.OpStructHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1357,7 +1328,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat64: case encoder.OpStructPtrHeadFloat64String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1371,7 +1342,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64: case encoder.OpStructHeadFloat64String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1472,7 +1443,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat64Ptr: case encoder.OpStructPtrHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1484,7 +1455,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64Ptr: case encoder.OpStructHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1581,7 +1552,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagString: case encoder.OpStructPtrHeadStringString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1595,7 +1566,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagString: case encoder.OpStructHeadStringString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1683,7 +1654,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagStringPtr: case encoder.OpStructPtrHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1695,7 +1666,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagStringPtr: case encoder.OpStructHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1786,7 +1757,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructPtrHeadStringTagBool: case encoder.OpStructPtrHeadBoolString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1800,7 +1771,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagBool: case encoder.OpStructHeadBoolString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1889,7 +1860,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBoolPtr: case encoder.OpStructPtrHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1901,7 +1872,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagBoolPtr: case encoder.OpStructHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1994,37 +1965,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagBytes:
if code.Indirect {
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagBytes:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadBytesPtr: case encoder.OpStructPtrHeadBytesPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2095,42 +2035,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
if code.Indirect {
p = ptrToNPtr(p+code.Offset, code.PtrNum)
}
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadNumber: case encoder.OpStructPtrHeadNumber:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -2204,7 +2108,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagNumber: case encoder.OpStructPtrHeadNumberString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2218,7 +2122,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumber: case encoder.OpStructHeadNumberString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2317,7 +2221,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagNumberPtr: case encoder.OpStructPtrHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2329,7 +2233,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumberPtr: case encoder.OpStructHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2358,8 +2262,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadStringTagArray, case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
encoder.OpStructPtrHeadSlice, encoder.OpStructPtrHeadStringTagSlice:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2373,8 +2276,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadArray, encoder.OpStructHeadStringTagArray, case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
encoder.OpStructHeadSlice, encoder.OpStructHeadStringTagSlice:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2458,8 +2360,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadStringTagArrayPtr, case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
encoder.OpStructPtrHeadSlicePtr, encoder.OpStructPtrHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2471,8 +2372,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadStringTagArrayPtr, case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
encoder.OpStructHeadSlicePtr, encoder.OpStructHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2532,7 +2432,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMap, encoder.OpStructPtrHeadStringTagMap: case encoder.OpStructPtrHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2544,7 +2444,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMap, encoder.OpStructHeadStringTagMap: case encoder.OpStructHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2598,7 +2498,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMapPtr, encoder.OpStructPtrHeadStringTagMapPtr: case encoder.OpStructPtrHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2610,7 +2510,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMapPtr, encoder.OpStructHeadStringTagMapPtr: case encoder.OpStructHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2726,50 +2626,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
if code.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalJSON {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2815,7 +2671,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalJSONPtr, encoder.OpStructPtrHeadStringTagMarshalJSONPtr: case encoder.OpStructPtrHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2827,7 +2683,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalJSONPtr, encoder.OpStructHeadStringTagMarshalJSONPtr: case encoder.OpStructHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2939,50 +2795,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
if code.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalText {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalText: case encoder.OpStructPtrHeadOmitEmptyMarshalText:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -3027,7 +2839,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalTextPtr, encoder.OpStructPtrHeadStringTagMarshalTextPtr: case encoder.OpStructPtrHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3039,7 +2851,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalTextPtr, encoder.OpStructHeadStringTagMarshalTextPtr: case encoder.OpStructHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3124,12 +2936,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldStringTag:
p := load(ctxptr, code.HeadIdx)
p += code.Offset
b = append(b, code.Key...)
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldInt: case encoder.OpStructFieldInt:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3146,7 +2952,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagInt: case encoder.OpStructFieldIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3174,7 +2980,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagIntPtr: case encoder.OpStructFieldIntPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3203,7 +3009,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUint: case encoder.OpStructFieldUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3231,7 +3037,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUintPtr: case encoder.OpStructFieldUintPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3259,7 +3065,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32: case encoder.OpStructFieldFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3287,7 +3093,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32Ptr: case encoder.OpStructFieldFloat32PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3322,7 +3128,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64: case encoder.OpStructFieldFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -3364,7 +3170,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64Ptr: case encoder.OpStructFieldFloat64PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3396,7 +3202,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagString: case encoder.OpStructFieldStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
s := ptrToString(p + code.Offset) s := ptrToString(p + code.Offset)
@ -3423,7 +3229,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagStringPtr: case encoder.OpStructFieldStringPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3449,7 +3255,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBool: case encoder.OpStructFieldBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3477,7 +3283,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBoolPtr: case encoder.OpStructFieldBoolPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3505,13 +3311,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytes:
p := load(ctxptr, code.HeadIdx)
v := ptrToBytes(p + code.Offset)
b = append(b, code.Key...)
b = appendByteSlice(b, v)
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldBytesPtr: case encoder.OpStructFieldBytesPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
@ -3532,17 +3331,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytesPtr:
b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldNumber: case encoder.OpStructFieldNumber:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3564,7 +3352,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumber: case encoder.OpStructFieldNumberString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3602,7 +3390,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumberPtr: case encoder.OpStructFieldNumberPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3618,7 +3406,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSON, encoder.OpStructFieldStringTagMarshalJSON: case encoder.OpStructFieldMarshalJSON:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p += code.Offset p += code.Offset
@ -3658,7 +3446,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSONPtr, encoder.OpStructFieldStringTagMarshalJSONPtr: case encoder.OpStructFieldMarshalJSONPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3685,7 +3473,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalText, encoder.OpStructFieldStringTagMarshalText: case encoder.OpStructFieldMarshalText:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p += code.Offset p += code.Offset
@ -3720,7 +3508,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalTextPtr, encoder.OpStructFieldStringTagMarshalTextPtr: case encoder.OpStructFieldMarshalTextPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3747,7 +3535,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldArray, encoder.OpStructFieldStringTagArray: case encoder.OpStructFieldArray:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
@ -3759,7 +3547,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = append(b, code.Key...) b = append(b, code.Key...)
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
case encoder.OpStructFieldArrayPtr, encoder.OpStructFieldStringTagArrayPtr: case encoder.OpStructFieldArrayPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3775,7 +3563,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldSlice, encoder.OpStructFieldStringTagSlice: case encoder.OpStructFieldSlice:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
@ -3792,7 +3580,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldSlicePtr, encoder.OpStructFieldStringTagSlicePtr: case encoder.OpStructFieldSlicePtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3808,7 +3596,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: case encoder.OpStructFieldMap:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToPtr(p + code.Offset) p = ptrToPtr(p + code.Offset)
@ -3824,7 +3612,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldMapPtr, encoder.OpStructFieldStringTagMapPtr: case encoder.OpStructFieldMapPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToPtr(p + code.Offset) p = ptrToPtr(p + code.Offset)
@ -3887,7 +3675,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagInt: case encoder.OpStructEndIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3923,7 +3711,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagIntPtr: case encoder.OpStructEndIntPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3960,7 +3748,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUint: case encoder.OpStructEndUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3996,7 +3784,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUintPtr: case encoder.OpStructEndUintPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4032,7 +3820,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32: case encoder.OpStructEndFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -4068,7 +3856,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32Ptr: case encoder.OpStructEndFloat32PtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4111,7 +3899,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64: case encoder.OpStructEndFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -4161,7 +3949,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64Ptr: case encoder.OpStructEndFloat64PtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4201,7 +3989,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagString: case encoder.OpStructEndStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
s := ptrToString(p + code.Offset) s := ptrToString(p + code.Offset)
@ -4236,7 +4024,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagStringPtr: case encoder.OpStructEndStringPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4271,7 +4059,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBool: case encoder.OpStructEndBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -4307,7 +4095,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBoolPtr: case encoder.OpStructEndBoolPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4343,13 +4131,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytes:
p := load(ctxptr, code.HeadIdx)
v := ptrToBytes(p + code.Offset)
b = append(b, code.Key...)
b = appendByteSlice(b, v)
b = appendStructEnd(b)
code = code.Next
case encoder.OpStructEndBytesPtr: case encoder.OpStructEndBytesPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
@ -4378,17 +4159,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytesPtr:
b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendStructEnd(b)
code = code.Next
case encoder.OpStructEndNumber: case encoder.OpStructEndNumber:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4418,7 +4188,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumber: case encoder.OpStructEndNumberString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -4464,7 +4234,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumberPtr: case encoder.OpStructEndNumberPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)

View File

@ -641,35 +641,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 encoder.OpStructPtrHeadInt: case encoder.OpStructPtrHeadInt:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -738,7 +709,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagInt: case encoder.OpStructPtrHeadIntString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -752,7 +723,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagInt: case encoder.OpStructHeadIntString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -841,7 +812,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagIntPtr: case encoder.OpStructPtrHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -853,7 +824,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagIntPtr: case encoder.OpStructHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -947,7 +918,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagUint: case encoder.OpStructPtrHeadUintString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -961,7 +932,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagUint: case encoder.OpStructHeadUintString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1050,7 +1021,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagUintPtr: case encoder.OpStructPtrHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1062,7 +1033,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagUintPtr: case encoder.OpStructHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1155,7 +1126,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat32: case encoder.OpStructPtrHeadFloat32String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1169,7 +1140,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32: case encoder.OpStructHeadFloat32String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1258,7 +1229,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat32Ptr: case encoder.OpStructPtrHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1270,7 +1241,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32Ptr: case encoder.OpStructHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1370,7 +1341,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat64: case encoder.OpStructPtrHeadFloat64String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1384,7 +1355,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64: case encoder.OpStructHeadFloat64String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1485,7 +1456,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat64Ptr: case encoder.OpStructPtrHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1497,7 +1468,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64Ptr: case encoder.OpStructHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1594,7 +1565,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagString: case encoder.OpStructPtrHeadStringString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1608,7 +1579,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagString: case encoder.OpStructHeadStringString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1696,7 +1667,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagStringPtr: case encoder.OpStructPtrHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1708,7 +1679,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagStringPtr: case encoder.OpStructHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1799,7 +1770,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructPtrHeadStringTagBool: case encoder.OpStructPtrHeadBoolString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1813,7 +1784,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagBool: case encoder.OpStructHeadBoolString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1902,7 +1873,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBoolPtr: case encoder.OpStructPtrHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1914,7 +1885,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagBoolPtr: case encoder.OpStructHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2007,37 +1978,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagBytes:
if code.Indirect {
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagBytes:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadBytesPtr: case encoder.OpStructPtrHeadBytesPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2108,42 +2048,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
if code.Indirect {
p = ptrToNPtr(p+code.Offset, code.PtrNum)
}
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadNumber: case encoder.OpStructPtrHeadNumber:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -2217,7 +2121,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagNumber: case encoder.OpStructPtrHeadNumberString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2231,7 +2135,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumber: case encoder.OpStructHeadNumberString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2330,7 +2234,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagNumberPtr: case encoder.OpStructPtrHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2342,7 +2246,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumberPtr: case encoder.OpStructHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2371,8 +2275,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadStringTagArray, case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
encoder.OpStructPtrHeadSlice, encoder.OpStructPtrHeadStringTagSlice:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2386,8 +2289,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadArray, encoder.OpStructHeadStringTagArray, case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
encoder.OpStructHeadSlice, encoder.OpStructHeadStringTagSlice:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2471,8 +2373,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadStringTagArrayPtr, case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
encoder.OpStructPtrHeadSlicePtr, encoder.OpStructPtrHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2484,8 +2385,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadStringTagArrayPtr, case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
encoder.OpStructHeadSlicePtr, encoder.OpStructHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2545,7 +2445,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMap, encoder.OpStructPtrHeadStringTagMap: case encoder.OpStructPtrHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2557,7 +2457,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMap, encoder.OpStructHeadStringTagMap: case encoder.OpStructHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2611,7 +2511,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMapPtr, encoder.OpStructPtrHeadStringTagMapPtr: case encoder.OpStructPtrHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2623,7 +2523,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMapPtr, encoder.OpStructHeadStringTagMapPtr: case encoder.OpStructHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2739,50 +2639,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
if code.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalJSON {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2828,7 +2684,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalJSONPtr, encoder.OpStructPtrHeadStringTagMarshalJSONPtr: case encoder.OpStructPtrHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2840,7 +2696,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalJSONPtr, encoder.OpStructHeadStringTagMarshalJSONPtr: case encoder.OpStructHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2952,50 +2808,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.Key...)
if code.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalText {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalText: case encoder.OpStructPtrHeadOmitEmptyMarshalText:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -3040,7 +2852,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalTextPtr, encoder.OpStructPtrHeadStringTagMarshalTextPtr: case encoder.OpStructPtrHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3052,7 +2864,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalTextPtr, encoder.OpStructHeadStringTagMarshalTextPtr: case encoder.OpStructHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3137,12 +2949,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldStringTag:
p := load(ctxptr, code.HeadIdx)
p += code.Offset
b = append(b, code.Key...)
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldInt: case encoder.OpStructFieldInt:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3159,7 +2965,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagInt: case encoder.OpStructFieldIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3187,7 +2993,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagIntPtr: case encoder.OpStructFieldIntPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3216,7 +3022,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUint: case encoder.OpStructFieldUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3244,7 +3050,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUintPtr: case encoder.OpStructFieldUintPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3272,7 +3078,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32: case encoder.OpStructFieldFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3300,7 +3106,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32Ptr: case encoder.OpStructFieldFloat32PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3335,7 +3141,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64: case encoder.OpStructFieldFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -3377,7 +3183,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64Ptr: case encoder.OpStructFieldFloat64PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3409,7 +3215,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagString: case encoder.OpStructFieldStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
s := ptrToString(p + code.Offset) s := ptrToString(p + code.Offset)
@ -3436,7 +3242,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagStringPtr: case encoder.OpStructFieldStringPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3462,7 +3268,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBool: case encoder.OpStructFieldBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3490,7 +3296,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBoolPtr: case encoder.OpStructFieldBoolPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3518,13 +3324,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytes:
p := load(ctxptr, code.HeadIdx)
v := ptrToBytes(p + code.Offset)
b = append(b, code.Key...)
b = appendByteSlice(b, v)
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldBytesPtr: case encoder.OpStructFieldBytesPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
@ -3545,17 +3344,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytesPtr:
b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldNumber: case encoder.OpStructFieldNumber:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3577,7 +3365,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumber: case encoder.OpStructFieldNumberString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3615,7 +3403,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumberPtr: case encoder.OpStructFieldNumberPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3631,7 +3419,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSON, encoder.OpStructFieldStringTagMarshalJSON: case encoder.OpStructFieldMarshalJSON:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p += code.Offset p += code.Offset
@ -3671,7 +3459,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSONPtr, encoder.OpStructFieldStringTagMarshalJSONPtr: case encoder.OpStructFieldMarshalJSONPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3698,7 +3486,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalText, encoder.OpStructFieldStringTagMarshalText: case encoder.OpStructFieldMarshalText:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p += code.Offset p += code.Offset
@ -3733,7 +3521,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalTextPtr, encoder.OpStructFieldStringTagMarshalTextPtr: case encoder.OpStructFieldMarshalTextPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3760,7 +3548,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldArray, encoder.OpStructFieldStringTagArray: case encoder.OpStructFieldArray:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
@ -3772,7 +3560,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = append(b, code.Key...) b = append(b, code.Key...)
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
case encoder.OpStructFieldArrayPtr, encoder.OpStructFieldStringTagArrayPtr: case encoder.OpStructFieldArrayPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3788,7 +3576,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldSlice, encoder.OpStructFieldStringTagSlice: case encoder.OpStructFieldSlice:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
@ -3805,7 +3593,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldSlicePtr, encoder.OpStructFieldStringTagSlicePtr: case encoder.OpStructFieldSlicePtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3821,7 +3609,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: case encoder.OpStructFieldMap:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToPtr(p + code.Offset) p = ptrToPtr(p + code.Offset)
@ -3837,7 +3625,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldMapPtr, encoder.OpStructFieldStringTagMapPtr: case encoder.OpStructFieldMapPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToPtr(p + code.Offset) p = ptrToPtr(p + code.Offset)
@ -3900,7 +3688,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagInt: case encoder.OpStructEndIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -3936,7 +3724,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagIntPtr: case encoder.OpStructEndIntPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3973,7 +3761,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUint: case encoder.OpStructEndUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -4009,7 +3797,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUintPtr: case encoder.OpStructEndUintPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4045,7 +3833,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32: case encoder.OpStructEndFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -4081,7 +3869,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32Ptr: case encoder.OpStructEndFloat32PtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4124,7 +3912,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64: case encoder.OpStructEndFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -4174,7 +3962,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64Ptr: case encoder.OpStructEndFloat64PtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4214,7 +4002,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagString: case encoder.OpStructEndStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
s := ptrToString(p + code.Offset) s := ptrToString(p + code.Offset)
@ -4249,7 +4037,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagStringPtr: case encoder.OpStructEndStringPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4284,7 +4072,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBool: case encoder.OpStructEndBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -4320,7 +4108,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBoolPtr: case encoder.OpStructEndBoolPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4356,13 +4144,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytes:
p := load(ctxptr, code.HeadIdx)
v := ptrToBytes(p + code.Offset)
b = append(b, code.Key...)
b = appendByteSlice(b, v)
b = appendStructEnd(b)
code = code.Next
case encoder.OpStructEndBytesPtr: case encoder.OpStructEndBytesPtr:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
@ -4391,17 +4172,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytesPtr:
b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendStructEnd(b)
code = code.Next
case encoder.OpStructEndNumber: case encoder.OpStructEndNumber:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4431,7 +4201,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumber: case encoder.OpStructEndNumberString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, '"') b = append(b, '"')
@ -4477,7 +4247,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumberPtr: case encoder.OpStructEndNumberPtrString:
b = append(b, code.Key...) b = append(b, code.Key...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)

View File

@ -628,35 +628,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 encoder.OpStructPtrHeadInt: case encoder.OpStructPtrHeadInt:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -725,7 +696,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagInt: case encoder.OpStructPtrHeadIntString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -739,7 +710,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagInt: case encoder.OpStructHeadIntString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -828,7 +799,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagIntPtr: case encoder.OpStructPtrHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -840,7 +811,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagIntPtr: case encoder.OpStructHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -934,7 +905,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagUint: case encoder.OpStructPtrHeadUintString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -948,7 +919,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagUint: case encoder.OpStructHeadUintString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1037,7 +1008,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagUintPtr: case encoder.OpStructPtrHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1049,7 +1020,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagUintPtr: case encoder.OpStructHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1142,7 +1113,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat32: case encoder.OpStructPtrHeadFloat32String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1156,7 +1127,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32: case encoder.OpStructHeadFloat32String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1245,7 +1216,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat32Ptr: case encoder.OpStructPtrHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1257,7 +1228,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32Ptr: case encoder.OpStructHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1357,7 +1328,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat64: case encoder.OpStructPtrHeadFloat64String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1371,7 +1342,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64: case encoder.OpStructHeadFloat64String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1472,7 +1443,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat64Ptr: case encoder.OpStructPtrHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1484,7 +1455,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64Ptr: case encoder.OpStructHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1581,7 +1552,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagString: case encoder.OpStructPtrHeadStringString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1595,7 +1566,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagString: case encoder.OpStructHeadStringString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1683,7 +1654,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagStringPtr: case encoder.OpStructPtrHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1695,7 +1666,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagStringPtr: case encoder.OpStructHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1786,7 +1757,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructPtrHeadStringTagBool: case encoder.OpStructPtrHeadBoolString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1800,7 +1771,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagBool: case encoder.OpStructHeadBoolString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1889,7 +1860,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBoolPtr: case encoder.OpStructPtrHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1901,7 +1872,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagBoolPtr: case encoder.OpStructHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1994,37 +1965,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagBytes:
if code.Indirect {
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagBytes:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.EscapedKey...)
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadBytesPtr: case encoder.OpStructPtrHeadBytesPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2095,42 +2035,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.EscapedKey...)
if code.Indirect {
p = ptrToNPtr(p+code.Offset, code.PtrNum)
}
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadNumber: case encoder.OpStructPtrHeadNumber:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -2204,7 +2108,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagNumber: case encoder.OpStructPtrHeadNumberString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2218,7 +2122,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumber: case encoder.OpStructHeadNumberString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2317,7 +2221,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagNumberPtr: case encoder.OpStructPtrHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2329,7 +2233,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumberPtr: case encoder.OpStructHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2358,8 +2262,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadStringTagArray, case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
encoder.OpStructPtrHeadSlice, encoder.OpStructPtrHeadStringTagSlice:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2373,8 +2276,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadArray, encoder.OpStructHeadStringTagArray, case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
encoder.OpStructHeadSlice, encoder.OpStructHeadStringTagSlice:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2458,8 +2360,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadStringTagArrayPtr, case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
encoder.OpStructPtrHeadSlicePtr, encoder.OpStructPtrHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2471,8 +2372,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadStringTagArrayPtr, case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
encoder.OpStructHeadSlicePtr, encoder.OpStructHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2532,7 +2432,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMap, encoder.OpStructPtrHeadStringTagMap: case encoder.OpStructPtrHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2544,7 +2444,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMap, encoder.OpStructHeadStringTagMap: case encoder.OpStructHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2598,7 +2498,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMapPtr, encoder.OpStructPtrHeadStringTagMapPtr: case encoder.OpStructPtrHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2610,7 +2510,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMapPtr, encoder.OpStructHeadStringTagMapPtr: case encoder.OpStructHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2726,50 +2626,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.EscapedKey...)
if code.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalJSON {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2815,7 +2671,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalJSONPtr, encoder.OpStructPtrHeadStringTagMarshalJSONPtr: case encoder.OpStructPtrHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2827,7 +2683,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalJSONPtr, encoder.OpStructHeadStringTagMarshalJSONPtr: case encoder.OpStructHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2939,50 +2795,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if !code.AnonymousHead {
b = append(b, '{')
}
b = append(b, code.EscapedKey...)
if code.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalText {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalText: case encoder.OpStructPtrHeadOmitEmptyMarshalText:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -3027,7 +2839,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalTextPtr, encoder.OpStructPtrHeadStringTagMarshalTextPtr: case encoder.OpStructPtrHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3039,7 +2851,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalTextPtr, encoder.OpStructHeadStringTagMarshalTextPtr: case encoder.OpStructHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3124,12 +2936,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldStringTag:
p := load(ctxptr, code.HeadIdx)
p += code.Offset
b = append(b, code.EscapedKey...)
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldInt: case encoder.OpStructFieldInt:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3146,7 +2952,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagInt: case encoder.OpStructFieldIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -3174,7 +2980,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagIntPtr: case encoder.OpStructFieldIntPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3203,7 +3009,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUint: case encoder.OpStructFieldUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -3231,7 +3037,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUintPtr: case encoder.OpStructFieldUintPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3259,7 +3065,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32: case encoder.OpStructFieldFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -3287,7 +3093,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32Ptr: case encoder.OpStructFieldFloat32PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3322,7 +3128,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64: case encoder.OpStructFieldFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -3364,7 +3170,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64Ptr: case encoder.OpStructFieldFloat64PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3396,7 +3202,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagString: case encoder.OpStructFieldStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
s := ptrToString(p + code.Offset) s := ptrToString(p + code.Offset)
@ -3423,7 +3229,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagStringPtr: case encoder.OpStructFieldStringPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3449,7 +3255,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBool: case encoder.OpStructFieldBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -3477,7 +3283,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBoolPtr: case encoder.OpStructFieldBoolPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3505,13 +3311,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytes:
p := load(ctxptr, code.HeadIdx)
v := ptrToBytes(p + code.Offset)
b = append(b, code.EscapedKey...)
b = appendByteSlice(b, v)
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldBytesPtr: case encoder.OpStructFieldBytesPtr:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
@ -3532,17 +3331,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytesPtr:
b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldNumber: case encoder.OpStructFieldNumber:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3564,7 +3352,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumber: case encoder.OpStructFieldNumberString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -3602,7 +3390,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumberPtr: case encoder.OpStructFieldNumberPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3618,7 +3406,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSON, encoder.OpStructFieldStringTagMarshalJSON: case encoder.OpStructFieldMarshalJSON:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p += code.Offset p += code.Offset
@ -3658,7 +3446,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSONPtr, encoder.OpStructFieldStringTagMarshalJSONPtr: case encoder.OpStructFieldMarshalJSONPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3685,7 +3473,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalText, encoder.OpStructFieldStringTagMarshalText: case encoder.OpStructFieldMarshalText:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p += code.Offset p += code.Offset
@ -3720,7 +3508,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalTextPtr, encoder.OpStructFieldStringTagMarshalTextPtr: case encoder.OpStructFieldMarshalTextPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3747,7 +3535,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldArray, encoder.OpStructFieldStringTagArray: case encoder.OpStructFieldArray:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
@ -3759,7 +3547,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
case encoder.OpStructFieldArrayPtr, encoder.OpStructFieldStringTagArrayPtr: case encoder.OpStructFieldArrayPtr:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3775,7 +3563,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldSlice, encoder.OpStructFieldStringTagSlice: case encoder.OpStructFieldSlice:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
@ -3792,7 +3580,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldSlicePtr, encoder.OpStructFieldStringTagSlicePtr: case encoder.OpStructFieldSlicePtr:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3808,7 +3596,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: case encoder.OpStructFieldMap:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToPtr(p + code.Offset) p = ptrToPtr(p + code.Offset)
@ -3824,7 +3612,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldMapPtr, encoder.OpStructFieldStringTagMapPtr: case encoder.OpStructFieldMapPtr:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToPtr(p + code.Offset) p = ptrToPtr(p + code.Offset)
@ -3887,7 +3675,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagInt: case encoder.OpStructEndIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -3923,7 +3711,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagIntPtr: case encoder.OpStructEndIntPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -3960,7 +3748,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUint: case encoder.OpStructEndUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -3996,7 +3784,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUintPtr: case encoder.OpStructEndUintPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4032,7 +3820,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32: case encoder.OpStructEndFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -4068,7 +3856,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32Ptr: case encoder.OpStructEndFloat32PtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4111,7 +3899,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64: case encoder.OpStructEndFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -4161,7 +3949,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64Ptr: case encoder.OpStructEndFloat64PtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4201,7 +3989,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagString: case encoder.OpStructEndStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
s := ptrToString(p + code.Offset) s := ptrToString(p + code.Offset)
@ -4236,7 +4024,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagStringPtr: case encoder.OpStructEndStringPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4271,7 +4059,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBool: case encoder.OpStructEndBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -4307,7 +4095,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBoolPtr: case encoder.OpStructEndBoolPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
@ -4343,13 +4131,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytes:
p := load(ctxptr, code.HeadIdx)
v := ptrToBytes(p + code.Offset)
b = append(b, code.EscapedKey...)
b = appendByteSlice(b, v)
b = appendStructEnd(b)
code = code.Next
case encoder.OpStructEndBytesPtr: case encoder.OpStructEndBytesPtr:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
@ -4378,17 +4159,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytesPtr:
b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendStructEnd(b)
code = code.Next
case encoder.OpStructEndNumber: case encoder.OpStructEndNumber:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4418,7 +4188,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumber: case encoder.OpStructEndNumberString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, '"') b = append(b, '"')
@ -4464,7 +4234,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumberPtr: case encoder.OpStructEndNumberPtrString:
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)

View File

@ -655,37 +655,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 encoder.OpStructPtrHeadInt: case encoder.OpStructPtrHeadInt:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -758,7 +727,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagInt: case encoder.OpStructPtrHeadIntString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -772,7 +741,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagInt: case encoder.OpStructHeadIntString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -866,7 +835,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagIntPtr: case encoder.OpStructPtrHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -878,7 +847,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagIntPtr: case encoder.OpStructHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -978,7 +947,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagUint: case encoder.OpStructPtrHeadUintString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -992,7 +961,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagUint: case encoder.OpStructHeadUintString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1086,7 +1055,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagUintPtr: case encoder.OpStructPtrHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1098,7 +1067,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagUintPtr: case encoder.OpStructHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1197,7 +1166,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat32: case encoder.OpStructPtrHeadFloat32String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1211,7 +1180,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32: case encoder.OpStructHeadFloat32String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1305,7 +1274,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat32Ptr: case encoder.OpStructPtrHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1317,7 +1286,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32Ptr: case encoder.OpStructHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1423,7 +1392,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat64: case encoder.OpStructPtrHeadFloat64String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1437,7 +1406,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64: case encoder.OpStructHeadFloat64String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1543,7 +1512,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat64Ptr: case encoder.OpStructPtrHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1555,7 +1524,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64Ptr: case encoder.OpStructHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1658,7 +1627,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagString: case encoder.OpStructPtrHeadStringString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1672,7 +1641,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagString: case encoder.OpStructHeadStringString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1766,7 +1735,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagStringPtr: case encoder.OpStructPtrHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1778,7 +1747,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagStringPtr: case encoder.OpStructHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1875,7 +1844,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructPtrHeadStringTagBool: case encoder.OpStructPtrHeadBoolString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1889,7 +1858,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagBool: case encoder.OpStructHeadBoolString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1983,7 +1952,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBoolPtr: case encoder.OpStructPtrHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1995,7 +1964,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagBoolPtr: case encoder.OpStructHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2094,39 +2063,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagBytes:
if code.Indirect {
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagBytes:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadBytesPtr: case encoder.OpStructPtrHeadBytesPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2201,44 +2137,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadNumber: case encoder.OpStructPtrHeadNumber:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -2316,7 +2214,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagNumber: case encoder.OpStructPtrHeadNumberString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2330,7 +2228,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumber: case encoder.OpStructHeadNumberString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2435,7 +2333,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagNumberPtr: case encoder.OpStructPtrHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2447,7 +2345,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumberPtr: case encoder.OpStructHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2478,8 +2376,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadStringTagArray, case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
encoder.OpStructPtrHeadSlice, encoder.OpStructPtrHeadStringTagSlice:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2493,8 +2390,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadArray, encoder.OpStructHeadStringTagArray, case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
encoder.OpStructHeadSlice, encoder.OpStructHeadStringTagSlice:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2584,8 +2480,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadStringTagArrayPtr, case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
encoder.OpStructPtrHeadSlicePtr, encoder.OpStructPtrHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2597,8 +2492,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadStringTagArrayPtr, case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
encoder.OpStructHeadSlicePtr, encoder.OpStructHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2662,7 +2556,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMap, encoder.OpStructPtrHeadStringTagMap: case encoder.OpStructPtrHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2674,7 +2568,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMap, encoder.OpStructHeadStringTagMap: case encoder.OpStructHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2732,7 +2626,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMapPtr, encoder.OpStructPtrHeadStringTagMapPtr: case encoder.OpStructPtrHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2744,7 +2638,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMapPtr, encoder.OpStructHeadStringTagMapPtr: case encoder.OpStructHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2866,52 +2760,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalJSON {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, true)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2959,7 +2807,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalJSONPtr, encoder.OpStructPtrHeadStringTagMarshalJSONPtr: case encoder.OpStructPtrHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2971,7 +2819,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalJSONPtr, encoder.OpStructHeadStringTagMarshalJSONPtr: case encoder.OpStructHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3089,52 +2937,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalText {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalText: case encoder.OpStructPtrHeadOmitEmptyMarshalText:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -3181,7 +2983,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalTextPtr, encoder.OpStructPtrHeadStringTagMarshalTextPtr: case encoder.OpStructPtrHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3193,7 +2995,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalTextPtr, encoder.OpStructHeadStringTagMarshalTextPtr: case encoder.OpStructHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3286,14 +3088,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldStringTag:
p := load(ctxptr, code.HeadIdx)
p += code.Offset
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...)
b = append(b, ' ')
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldInt: case encoder.OpStructFieldInt:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3314,7 +3108,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagInt: case encoder.OpStructFieldIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3347,7 +3141,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagIntPtr: case encoder.OpStructFieldIntPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3382,7 +3176,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUint: case encoder.OpStructFieldUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3415,7 +3209,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUintPtr: case encoder.OpStructFieldUintPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3449,7 +3243,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32: case encoder.OpStructFieldFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3482,7 +3276,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32Ptr: case encoder.OpStructFieldFloat32PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3523,7 +3317,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64: case encoder.OpStructFieldFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -3568,7 +3362,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64Ptr: case encoder.OpStructFieldFloat64PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3606,7 +3400,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagString: case encoder.OpStructFieldStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3639,7 +3433,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagStringPtr: case encoder.OpStructFieldStringPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -3671,7 +3465,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBool: case encoder.OpStructFieldBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3704,7 +3498,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBoolPtr: case encoder.OpStructFieldBoolPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -3738,14 +3532,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytes:
p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...)
b = append(b, ' ')
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldBytesPtr: case encoder.OpStructFieldBytesPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3770,19 +3556,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytesPtr:
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldNumber: case encoder.OpStructFieldNumber:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3808,7 +3581,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumber: case encoder.OpStructFieldNumberString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -3852,7 +3625,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumberPtr: case encoder.OpStructFieldNumberPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -3870,7 +3643,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSON, encoder.OpStructFieldStringTagMarshalJSON: case encoder.OpStructFieldMarshalJSON:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -3914,7 +3687,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSONPtr, encoder.OpStructFieldStringTagMarshalJSONPtr: case encoder.OpStructFieldMarshalJSONPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3945,7 +3718,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalText, encoder.OpStructFieldStringTagMarshalText: case encoder.OpStructFieldMarshalText:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -3984,7 +3757,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalTextPtr, encoder.OpStructFieldStringTagMarshalTextPtr: case encoder.OpStructFieldMarshalTextPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4015,7 +3788,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldArray, encoder.OpStructFieldStringTagArray: case encoder.OpStructFieldArray:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4031,7 +3804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
p += code.Offset p += code.Offset
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
case encoder.OpStructFieldArrayPtr, encoder.OpStructFieldStringTagArrayPtr: case encoder.OpStructFieldArrayPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4051,7 +3824,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldSlice, encoder.OpStructFieldStringTagSlice: case encoder.OpStructFieldSlice:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4072,7 +3845,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldSlicePtr, encoder.OpStructFieldStringTagSlicePtr: case encoder.OpStructFieldSlicePtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4092,7 +3865,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: case encoder.OpStructFieldMap:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4112,7 +3885,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldMapPtr, encoder.OpStructFieldStringTagMapPtr: case encoder.OpStructFieldMapPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4138,7 +3911,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldStruct, encoder.OpStructFieldStringTagStruct: case encoder.OpStructFieldStruct:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -4211,7 +3984,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagInt: case encoder.OpStructEndIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4258,7 +4031,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagIntPtr: case encoder.OpStructEndIntPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4307,7 +4080,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUint: case encoder.OpStructEndUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4354,7 +4127,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUintPtr: case encoder.OpStructEndUintPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4402,7 +4175,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32: case encoder.OpStructEndFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4449,7 +4222,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32Ptr: case encoder.OpStructEndFloat32PtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4504,7 +4277,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64: case encoder.OpStructEndFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -4563,7 +4336,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64Ptr: case encoder.OpStructEndFloat64PtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4615,7 +4388,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagString: case encoder.OpStructEndStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4662,7 +4435,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagStringPtr: case encoder.OpStructEndStringPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4708,7 +4481,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBool: case encoder.OpStructEndBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4755,7 +4528,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBoolPtr: case encoder.OpStructEndBoolPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4803,14 +4576,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytes:
p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...)
b = append(b, ' ')
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendStructEnd(ctx, b, code.Indent-1)
code = code.Next
case encoder.OpStructEndBytesPtr: case encoder.OpStructEndBytesPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4849,19 +4614,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytesPtr:
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...)
b = append(b, ' ')
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendStructEnd(ctx, b, code.Indent-1)
code = code.Next
case encoder.OpStructEndNumber: case encoder.OpStructEndNumber:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
@ -4901,7 +4653,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumber: case encoder.OpStructEndNumberString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')
@ -4959,7 +4711,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumberPtr: case encoder.OpStructEndNumberPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.EscapedKey...) b = append(b, code.EscapedKey...)
b = append(b, ' ') b = append(b, ' ')

View File

@ -655,37 +655,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTag:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 encoder.OpStructPtrHeadInt: case encoder.OpStructPtrHeadInt:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -758,7 +727,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagInt: case encoder.OpStructPtrHeadIntString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -772,7 +741,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagInt: case encoder.OpStructHeadIntString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -866,7 +835,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagIntPtr: case encoder.OpStructPtrHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -878,7 +847,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagIntPtr: case encoder.OpStructHeadIntPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -978,7 +947,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagUint: case encoder.OpStructPtrHeadUintString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -992,7 +961,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagUint: case encoder.OpStructHeadUintString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1086,7 +1055,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagUintPtr: case encoder.OpStructPtrHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1098,7 +1067,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagUintPtr: case encoder.OpStructHeadUintPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1197,7 +1166,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat32: case encoder.OpStructPtrHeadFloat32String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1211,7 +1180,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32: case encoder.OpStructHeadFloat32String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1305,7 +1274,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat32Ptr: case encoder.OpStructPtrHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1317,7 +1286,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat32Ptr: case encoder.OpStructHeadFloat32PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1423,7 +1392,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagFloat64: case encoder.OpStructPtrHeadFloat64String:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1437,7 +1406,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64: case encoder.OpStructHeadFloat64String:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1543,7 +1512,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagFloat64Ptr: case encoder.OpStructPtrHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1555,7 +1524,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagFloat64Ptr: case encoder.OpStructHeadFloat64PtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1658,7 +1627,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagString: case encoder.OpStructPtrHeadStringString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1672,7 +1641,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagString: case encoder.OpStructHeadStringString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1766,7 +1735,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagStringPtr: case encoder.OpStructPtrHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1778,7 +1747,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagStringPtr: case encoder.OpStructHeadStringPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1875,7 +1844,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructPtrHeadStringTagBool: case encoder.OpStructPtrHeadBoolString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -1889,7 +1858,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagBool: case encoder.OpStructHeadBoolString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1983,7 +1952,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBoolPtr: case encoder.OpStructPtrHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -1995,7 +1964,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagBoolPtr: case encoder.OpStructHeadBoolPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2094,39 +2063,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagBytes:
if code.Indirect {
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagBytes:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadBytesPtr: case encoder.OpStructPtrHeadBytesPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2201,44 +2137,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadStringTagBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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 = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadNumber: case encoder.OpStructPtrHeadNumber:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
@ -2316,7 +2214,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadStringTagNumber: case encoder.OpStructPtrHeadNumberString:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2330,7 +2228,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumber: case encoder.OpStructHeadNumberString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2435,7 +2333,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagNumberPtr: case encoder.OpStructPtrHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2447,7 +2345,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadStringTagNumberPtr: case encoder.OpStructHeadNumberPtrString:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2478,8 +2376,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadStringTagArray, case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
encoder.OpStructPtrHeadSlice, encoder.OpStructPtrHeadStringTagSlice:
if code.Indirect { if code.Indirect {
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2493,8 +2390,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
} }
fallthrough fallthrough
case encoder.OpStructHeadArray, encoder.OpStructHeadStringTagArray, case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
encoder.OpStructHeadSlice, encoder.OpStructHeadStringTagSlice:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2584,8 +2480,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadStringTagArrayPtr, case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
encoder.OpStructPtrHeadSlicePtr, encoder.OpStructPtrHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2597,8 +2492,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadStringTagArrayPtr, case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
encoder.OpStructHeadSlicePtr, encoder.OpStructHeadStringTagSlicePtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2662,7 +2556,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMap, encoder.OpStructPtrHeadStringTagMap: case encoder.OpStructPtrHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2674,7 +2568,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMap, encoder.OpStructHeadStringTagMap: case encoder.OpStructHeadMap:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2732,7 +2626,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructPtrHeadMapPtr, encoder.OpStructPtrHeadStringTagMapPtr: case encoder.OpStructPtrHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2744,7 +2638,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMapPtr, encoder.OpStructHeadStringTagMapPtr: case encoder.OpStructHeadMapPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2866,52 +2760,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalJSON {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, false)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -2959,7 +2807,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalJSONPtr, encoder.OpStructPtrHeadStringTagMarshalJSONPtr: case encoder.OpStructPtrHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -2971,7 +2819,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalJSONPtr, encoder.OpStructHeadStringTagMarshalJSONPtr: case encoder.OpStructHeadMarshalJSONPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3089,52 +2937,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructPtrHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(b)
}
code = code.End.Next
break
}
if code.Indirect {
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
fallthrough
case encoder.OpStructHeadStringTagMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect {
if !code.AnonymousHead {
b = appendNull(b)
b = appendComma(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.IsNilableType {
if code.Indirect || code.Op == encoder.OpStructPtrHeadStringTagMarshalText {
p = ptrToPtr(p + code.Offset)
}
}
if p == 0 && code.Nilcheck {
b = appendNull(b)
} else {
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalText: case encoder.OpStructPtrHeadOmitEmptyMarshalText:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
@ -3181,7 +2983,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
} }
case encoder.OpStructPtrHeadMarshalTextPtr, encoder.OpStructPtrHeadStringTagMarshalTextPtr: case encoder.OpStructPtrHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 { if p == 0 {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3193,7 +2995,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough fallthrough
case encoder.OpStructHeadMarshalTextPtr, encoder.OpStructHeadStringTagMarshalTextPtr: case encoder.OpStructHeadMarshalTextPtr:
p := load(ctxptr, code.Idx) p := load(ctxptr, code.Idx)
if p == 0 && code.Indirect { if p == 0 && code.Indirect {
if !code.AnonymousHead { if !code.AnonymousHead {
@ -3286,14 +3088,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldStringTag:
p := load(ctxptr, code.HeadIdx)
p += code.Offset
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...)
b = append(b, ' ')
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldInt: case encoder.OpStructFieldInt:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3314,7 +3108,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagInt: case encoder.OpStructFieldIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3347,7 +3141,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagIntPtr: case encoder.OpStructFieldIntPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3382,7 +3176,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUint: case encoder.OpStructFieldUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3415,7 +3209,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagUintPtr: case encoder.OpStructFieldUintPtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3449,7 +3243,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32: case encoder.OpStructFieldFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3482,7 +3276,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat32Ptr: case encoder.OpStructFieldFloat32PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3523,7 +3317,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64: case encoder.OpStructFieldFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -3568,7 +3362,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagFloat64Ptr: case encoder.OpStructFieldFloat64PtrString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum) p = ptrToNPtr(p+code.Offset, code.PtrNum)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -3606,7 +3400,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagString: case encoder.OpStructFieldStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3639,7 +3433,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagStringPtr: case encoder.OpStructFieldStringPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -3671,7 +3465,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBool: case encoder.OpStructFieldBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3704,7 +3498,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBoolPtr: case encoder.OpStructFieldBoolPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -3738,14 +3532,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytes:
p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...)
b = append(b, ' ')
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldBytesPtr: case encoder.OpStructFieldBytesPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3770,19 +3556,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagBytesPtr:
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...)
b = append(b, ' ')
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendComma(b)
code = code.Next
case encoder.OpStructFieldNumber: case encoder.OpStructFieldNumber:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3808,7 +3581,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumber: case encoder.OpStructFieldNumberString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -3852,7 +3625,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldStringTagNumberPtr: case encoder.OpStructFieldNumberPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -3870,7 +3643,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(b) b = appendComma(b)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSON, encoder.OpStructFieldStringTagMarshalJSON: case encoder.OpStructFieldMarshalJSON:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -3914,7 +3687,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalJSONPtr, encoder.OpStructFieldStringTagMarshalJSONPtr: case encoder.OpStructFieldMarshalJSONPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3945,7 +3718,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalText, encoder.OpStructFieldStringTagMarshalText: case encoder.OpStructFieldMarshalText:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -3984,7 +3757,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} }
b = appendComma(bb) b = appendComma(bb)
code = code.Next code = code.Next
case encoder.OpStructFieldMarshalTextPtr, encoder.OpStructFieldStringTagMarshalTextPtr: case encoder.OpStructFieldMarshalTextPtr:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4015,7 +3788,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(bb) b = appendComma(bb)
} }
code = code.Next code = code.Next
case encoder.OpStructFieldArray, encoder.OpStructFieldStringTagArray: case encoder.OpStructFieldArray:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4031,7 +3804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
p += code.Offset p += code.Offset
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
case encoder.OpStructFieldArrayPtr, encoder.OpStructFieldStringTagArrayPtr: case encoder.OpStructFieldArrayPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4051,7 +3824,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldSlice, encoder.OpStructFieldStringTagSlice: case encoder.OpStructFieldSlice:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4072,7 +3845,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldSlicePtr, encoder.OpStructFieldStringTagSlicePtr: case encoder.OpStructFieldSlicePtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4092,7 +3865,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldMap, encoder.OpStructFieldStringTagMap: case encoder.OpStructFieldMap:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4112,7 +3885,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
code = code.Next code = code.Next
store(ctxptr, code.Idx, p) store(ctxptr, code.Idx, p)
} }
case encoder.OpStructFieldMapPtr, encoder.OpStructFieldStringTagMapPtr: case encoder.OpStructFieldMapPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4138,7 +3911,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
} else { } else {
code = code.NextField code = code.NextField
} }
case encoder.OpStructFieldStruct, encoder.OpStructFieldStringTagStruct: case encoder.OpStructFieldStruct:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
p += code.Offset p += code.Offset
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
@ -4211,7 +3984,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagInt: case encoder.OpStructEndIntString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4258,7 +4031,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagIntPtr: case encoder.OpStructEndIntPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4307,7 +4080,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUint: case encoder.OpStructEndUintString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4354,7 +4127,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagUintPtr: case encoder.OpStructEndUintPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4402,7 +4175,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32: case encoder.OpStructEndFloat32String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4449,7 +4222,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat32Ptr: case encoder.OpStructEndFloat32PtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4504,7 +4277,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64: case encoder.OpStructEndFloat64String:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
v := ptrToFloat64(p + code.Offset) v := ptrToFloat64(p + code.Offset)
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -4563,7 +4336,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagFloat64Ptr: case encoder.OpStructEndFloat64PtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4615,7 +4388,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagString: case encoder.OpStructEndStringString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4662,7 +4435,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagStringPtr: case encoder.OpStructEndStringPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4708,7 +4481,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBool: case encoder.OpStructEndBoolString:
p := load(ctxptr, code.HeadIdx) p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4755,7 +4528,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBoolPtr: case encoder.OpStructEndBoolPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4803,14 +4576,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytes:
p := load(ctxptr, code.HeadIdx)
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...)
b = append(b, ' ')
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
b = appendStructEnd(ctx, b, code.Indent-1)
code = code.Next
case encoder.OpStructEndBytesPtr: case encoder.OpStructEndBytesPtr:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4849,19 +4614,6 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagBytesPtr:
b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...)
b = append(b, ' ')
p := load(ctxptr, code.HeadIdx)
p = ptrToNPtr(p+code.Offset, code.PtrNum)
if p == 0 {
b = appendNull(b)
} else {
b = appendByteSlice(b, ptrToBytes(p))
}
b = appendStructEnd(ctx, b, code.Indent-1)
code = code.Next
case encoder.OpStructEndNumber: case encoder.OpStructEndNumber:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
@ -4901,7 +4653,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumber: case encoder.OpStructEndNumberString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')
@ -4959,7 +4711,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
b = appendComma(b) b = appendComma(b)
} }
code = code.Next code = code.Next
case encoder.OpStructEndStringTagNumberPtr: case encoder.OpStructEndNumberPtrString:
b = appendIndent(ctx, b, code.Indent) b = appendIndent(ctx, b, code.Indent)
b = append(b, code.Key...) b = append(b, code.Key...)
b = append(b, ' ') b = append(b, ' ')

View File

@ -74,8 +74,14 @@ func StructTagFromField(field reflect.StructField) *StructTag {
} }
st.Key = keyName st.Key = keyName
if len(opts) > 1 { if len(opts) > 1 {
st.IsOmitEmpty = opts[1] == "omitempty" for _, opt := range opts[1:] {
st.IsString = opts[1] == "string" switch opt {
case "omitempty":
st.IsOmitEmpty = true
case "string":
st.IsString = true
}
}
} }
return st return st
} }