Fix pointer op

This commit is contained in:
Masaaki Goshima 2021-03-10 01:11:48 +09:00
parent d42d09f9f9
commit 37fb74bbb8
8 changed files with 628 additions and 2678 deletions

View File

@ -15,8 +15,6 @@ type opType struct {
Op string Op string
Code string Code string
HeadToPtrHead func() string HeadToPtrHead func() string
HeadToNPtrHead func() string
HeadToAnonymousHead func() string
HeadToOmitEmptyHead func() string HeadToOmitEmptyHead func() string
HeadToStringTagHead func() string HeadToStringTagHead func() string
PtrHeadToHead func() string PtrHeadToHead func() string
@ -29,14 +27,6 @@ func (t opType) IsHeadToPtrHead() bool {
return t.Op != t.HeadToPtrHead() return t.Op != t.HeadToPtrHead()
} }
func (t opType) IsHeadToNPtrHead() bool {
return t.Op != t.HeadToNPtrHead()
}
func (t opType) IsHeadToAnonymousHead() bool {
return t.Op != t.HeadToAnonymousHead()
}
func (t opType) IsHeadToOmitEmptyHead() bool { func (t opType) IsHeadToOmitEmptyHead() bool {
return t.Op != t.HeadToOmitEmptyHead() return t.Op != t.HeadToOmitEmptyHead()
} }
@ -66,8 +56,6 @@ func createOpType(op, code string) opType {
Op: op, Op: op,
Code: code, Code: code,
HeadToPtrHead: func() string { return op }, HeadToPtrHead: func() string { return op },
HeadToNPtrHead: func() string { return op },
HeadToAnonymousHead: func() string { return op },
HeadToOmitEmptyHead: func() string { return op }, HeadToOmitEmptyHead: func() string { return op },
HeadToStringTagHead: func() string { return op }, HeadToStringTagHead: func() string { return op },
PtrHeadToHead: func() string { return op }, PtrHeadToHead: func() string { return op },
@ -121,19 +109,19 @@ func (t opType) codeType() codeType {
} }
return codeStructField return codeStructField
} }
if strings.Contains(t.String(), "ArrayHead") { if t.String() == "Array" || t.String() == "ArrayPtr" {
return codeArrayHead return codeArrayHead
} }
if strings.Contains(t.String(), "ArrayElem") { if strings.Contains(t.String(), "ArrayElem") {
return codeArrayElem return codeArrayElem
} }
if strings.Contains(t.String(), "SliceHead") { if t.String() == "Slice" || t.String() == "SlicePtr" {
return codeSliceHead return codeSliceHead
} }
if strings.Contains(t.String(), "SliceElem") { if strings.Contains(t.String(), "SliceElem") {
return codeSliceElem return codeSliceElem
} }
if strings.Contains(t.String(), "MapHead") { if t.String() == "Map" || t.String() == "MapPtr" {
return codeMapHead return codeMapHead
} }
if strings.Contains(t.String(), "MapKey") { if strings.Contains(t.String(), "MapKey") {
@ -153,9 +141,6 @@ func (t opType) headToPtrHead() opType {
if strings.Index(t.String(), "PtrHead") > 0 { if strings.Index(t.String(), "PtrHead") > 0 {
return t return t
} }
if strings.Index(t.String(), "PtrAnonymousHead") > 0 {
return t
}
idx := strings.Index(t.String(), "Field") idx := strings.Index(t.String(), "Field")
if idx == -1 { if idx == -1 {
@ -163,42 +148,13 @@ func (t opType) headToPtrHead() opType {
} }
suffix := "Ptr"+t.String()[idx+len("Field"):] suffix := "Ptr"+t.String()[idx+len("Field"):]
const toPtrOffset = 6 const toPtrOffset = 3
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)
} }
return t return t
} }
func (t opType) headToNPtrHead() opType {
if strings.Index(t.String(), "PtrHead") > 0 {
return t
}
if strings.Index(t.String(), "PtrAnonymousHead") > 0 {
return t
}
idx := strings.Index(t.String(), "Field")
if idx == -1 {
return t
}
suffix := "NPtr"+t.String()[idx+len("Field"):]
const toPtrOffset = 12
if strings.Contains(opType(int(t) + toPtrOffset).String(), suffix) {
return opType(int(t) + toPtrOffset)
}
return t
}
func (t opType) headToAnonymousHead() opType {
const toAnonymousOffset = 3
if strings.Contains(opType(int(t) + toAnonymousOffset).String(), "Anonymous") {
return opType(int(t) + toAnonymousOffset)
}
return t
}
func (t opType) headToOmitEmptyHead() opType { func (t opType) headToOmitEmptyHead() opType {
const toOmitEmptyOffset = 1 const toOmitEmptyOffset = 1
if strings.Contains(opType(int(t) + toOmitEmptyOffset).String(), "OmitEmpty") { if strings.Contains(opType(int(t) + toOmitEmptyOffset).String(), "OmitEmpty") {
@ -223,7 +179,7 @@ func (t opType) ptrHeadToHead() opType {
} }
suffix := t.String()[idx+len("Ptr"):] suffix := t.String()[idx+len("Ptr"):]
const toPtrOffset = 6 const toPtrOffset = 3
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)
} }
@ -281,8 +237,7 @@ func (t opType) fieldToStringTagField() opType {
"array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive", "array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive",
"intString", "uintString", "intString", "uintString",
"intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr", "intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr",
"arrayPtr", "slicePtr", "mapPtr", "marshalJSONPtr", "marshalTextPtr", "arrayPtr", "slicePtr", "mapPtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr",
"intNPtr", "uintNPtr", "float32NPtr", "float64NPtr", "boolNPtr", "stringNPtr", "bytesNPtr",
} }
primitiveTypesUpper := []string{} primitiveTypesUpper := []string{}
for _, typ := range primitiveTypes { for _, typ := range primitiveTypes {
@ -292,16 +247,12 @@ func (t opType) fieldToStringTagField() opType {
createOpType("End", "Op"), createOpType("End", "Op"),
createOpType("Interface", "Op"), createOpType("Interface", "Op"),
createOpType("Ptr", "Op"), createOpType("Ptr", "Op"),
createOpType("NPtr", "Op"),
createOpType("SliceHead", "SliceHead"),
createOpType("RootSliceHead", "SliceHead"), createOpType("RootSliceHead", "SliceHead"),
createOpType("SliceElem", "SliceElem"), createOpType("SliceElem", "SliceElem"),
createOpType("RootSliceElem", "SliceElem"), createOpType("RootSliceElem", "SliceElem"),
createOpType("SliceEnd", "Op"), createOpType("SliceEnd", "Op"),
createOpType("ArrayHead", "ArrayHead"),
createOpType("ArrayElem", "ArrayElem"), createOpType("ArrayElem", "ArrayElem"),
createOpType("ArrayEnd", "Op"), createOpType("ArrayEnd", "Op"),
createOpType("MapHead", "MapHead"),
createOpType("MapHeadLoad", "MapHead"), createOpType("MapHeadLoad", "MapHead"),
createOpType("MapKey", "MapKey"), createOpType("MapKey", "MapKey"),
createOpType("MapValue", "MapValue"), createOpType("MapValue", "MapValue"),
@ -314,18 +265,15 @@ func (t opType) fieldToStringTagField() opType {
opTypes = append(opTypes, createOpType(typ, "Op")) opTypes = append(opTypes, createOpType(typ, "Op"))
} }
for _, typ := range append(primitiveTypesUpper, "") { for _, typ := range append(primitiveTypesUpper, "") {
for _, ptrOrNot := range []string{"", "Ptr", "NPtr"} { for _, ptrOrNot := range []string{"", "Ptr"} {
for _, headType := range []string{"", "Anonymous"} {
for _, opt := range []string{"", "OmitEmpty", "StringTag"} { for _, opt := range []string{"", "OmitEmpty", "StringTag"} {
ptrOrNot := ptrOrNot ptrOrNot := ptrOrNot
headType := headType
opt := opt opt := opt
typ := typ typ := typ
op := fmt.Sprintf( op := fmt.Sprintf(
"StructField%s%sHead%s%s", "StructField%sHead%s%s",
ptrOrNot, ptrOrNot,
headType,
opt, opt,
typ, typ,
) )
@ -334,48 +282,28 @@ func (t opType) fieldToStringTagField() opType {
Code: "StructField", Code: "StructField",
HeadToPtrHead: func() string { HeadToPtrHead: func() string {
return fmt.Sprintf( return fmt.Sprintf(
"StructFieldPtr%sHead%s%s", "StructFieldPtrHead%s%s",
headType,
opt,
typ,
)
},
HeadToNPtrHead: func() string {
return fmt.Sprintf(
"StructFieldNPtr%sHead%s%s",
headType,
opt,
typ,
)
},
HeadToAnonymousHead: func() string {
return fmt.Sprintf(
"StructField%sAnonymousHead%s%s",
ptrOrNot,
opt, opt,
typ, typ,
) )
}, },
HeadToOmitEmptyHead: func() string { HeadToOmitEmptyHead: func() string {
return fmt.Sprintf( return fmt.Sprintf(
"StructField%s%sHeadOmitEmpty%s", "StructField%sHeadOmitEmpty%s",
ptrOrNot, ptrOrNot,
headType,
typ, typ,
) )
}, },
HeadToStringTagHead: func() string { HeadToStringTagHead: func() string {
return fmt.Sprintf( return fmt.Sprintf(
"StructField%s%sHeadStringTag%s", "StructField%sHeadStringTag%s",
ptrOrNot, ptrOrNot,
headType,
typ, typ,
) )
}, },
PtrHeadToHead: func() string { PtrHeadToHead: func() string {
return fmt.Sprintf( return fmt.Sprintf(
"StructField%sHead%s%s", "StructFieldHead%s%s",
headType,
opt, opt,
typ, typ,
) )
@ -387,7 +315,6 @@ 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", "StringTag"} {
opt := opt opt := opt
@ -402,8 +329,6 @@ func (t opType) fieldToStringTagField() opType {
Op: op, Op: op,
Code: "StructField", Code: "StructField",
HeadToPtrHead: func() string { return op }, HeadToPtrHead: func() string { return op },
HeadToNPtrHead: func() string { return op },
HeadToAnonymousHead: func() string { return op },
HeadToOmitEmptyHead: func() string { return op }, HeadToOmitEmptyHead: func() string { return op },
HeadToStringTagHead: func() string { return op }, HeadToStringTagHead: func() string { return op },
PtrHeadToHead: func() string { return op }, PtrHeadToHead: func() string { return op },
@ -447,8 +372,6 @@ func (t opType) fieldToStringTagField() opType {
Op: op, Op: op,
Code: "StructEnd", Code: "StructEnd",
HeadToPtrHead: func() string { return op }, HeadToPtrHead: func() string { return op },
HeadToNPtrHead: func() string { return op },
HeadToAnonymousHead: func() string { return op },
HeadToOmitEmptyHead: func() string { return op }, HeadToOmitEmptyHead: func() string { return op },
HeadToStringTagHead: func() string { return op }, HeadToStringTagHead: func() string { return op },
PtrHeadToHead: func() string { return op }, PtrHeadToHead: func() string { return op },

View File

@ -96,9 +96,7 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) {
func encodeLinkRecursiveCode(c *opcode) { func encodeLinkRecursiveCode(c *opcode) {
for code := c; code.op != opEnd && code.op != opStructFieldRecursiveEnd; { for code := c; code.op != opEnd && code.op != opStructFieldRecursiveEnd; {
switch code.op { switch code.op {
case opStructFieldRecursive, case opStructFieldRecursive, opStructFieldPtrHeadRecursive:
opStructFieldPtrAnonymousHeadRecursive,
opStructFieldAnonymousHeadRecursive:
if code.jmp.linked { if code.jmp.linked {
code = code.next code = code.next
continue continue
@ -253,11 +251,46 @@ func encodeCompile(ctx *encodeCompileContext, isPtr bool) (*opcode, error) {
return nil, &UnsupportedTypeError{Type: rtype2type(typ)} return nil, &UnsupportedTypeError{Type: rtype2type(typ)}
} }
func encodeConvertPtrOp(code *opcode) opType {
ptrHeadOp := code.op.headToPtrHead()
if code.op != ptrHeadOp {
return ptrHeadOp
}
switch code.op {
case opInt:
return opIntPtr
case opUint:
return opUintPtr
case opFloat32:
return opFloat32Ptr
case opFloat64:
return opFloat64Ptr
case opString:
return opStringPtr
case opBool:
return opBoolPtr
case opBytes:
return opBytesPtr
case opArray:
return opArrayPtr
case opSlice:
return opSlicePtr
case opMap:
return opMapPtr
case opMarshalJSON:
return opMarshalJSONPtr
case opMarshalText:
return opMarshalTextPtr
case opInterface:
return opInterfacePtr
}
return code.op
}
func encodeCompileKey(ctx *encodeCompileContext) (*opcode, error) { func encodeCompileKey(ctx *encodeCompileContext) (*opcode, error) {
typ := ctx.typ typ := ctx.typ
switch { switch {
case rtype_ptrTo(typ).Implements(marshalJSONType): case rtype_ptrTo(typ).Implements(marshalJSONType):
fmt.Println("key MarshalJSON", typ)
return encodeCompileMarshalJSONPtr(ctx) return encodeCompileMarshalJSONPtr(ctx)
case rtype_ptrTo(typ).Implements(marshalTextType): case rtype_ptrTo(typ).Implements(marshalTextType):
return encodeCompileMarshalTextPtr(ctx) return encodeCompileMarshalTextPtr(ctx)
@ -296,25 +329,14 @@ func encodeCompileKey(ctx *encodeCompileContext) (*opcode, error) {
} }
func encodeCompilePtr(ctx *encodeCompileContext) (*opcode, error) { func encodeCompilePtr(ctx *encodeCompileContext) (*opcode, error) {
ptrOpcodeIndex := ctx.opcodeIndex
ptrIndex := ctx.ptrIndex
ctx.incIndex()
code, err := encodeCompile(ctx.withType(ctx.typ.Elem()), true) code, err := encodeCompile(ctx.withType(ctx.typ.Elem()), true)
if err != nil { if err != nil {
return nil, err return nil, err
} }
ptrHeadOp := code.op.headToPtrHead() code.op = encodeConvertPtrOp(code)
if code.op != ptrHeadOp { code.ptrNum++
code.op = ptrHeadOp
code.decOpcodeIndex()
ctx.decIndex()
return code, nil return code, nil
} }
c := ctx.context()
c.opcodeIndex = ptrOpcodeIndex
c.ptrIndex = ptrIndex
return newOpCodeWithNext(c, opPtr, code), nil
}
func encodeCompileMarshalJSON(ctx *encodeCompileContext) (*opcode, error) { func encodeCompileMarshalJSON(ctx *encodeCompileContext) (*opcode, error) {
code := newOpCode(ctx, opMarshalJSON) code := newOpCode(ctx, opMarshalJSON)
@ -693,181 +715,102 @@ func encodeCompileMap(ctx *encodeCompileContext, withLoad bool) (*opcode, error)
func encodeTypeToHeaderType(ctx *encodeCompileContext, code *opcode) opType { func encodeTypeToHeaderType(ctx *encodeCompileContext, code *opcode) opType {
switch code.op { switch code.op {
case opPtr:
ptrNum := 1
c := code
ctx.decIndex()
for {
if code.next.op == opPtr {
ptrNum++
code = code.next
ctx.decIndex()
continue
}
break
}
c.ptrNum = ptrNum
if ptrNum > 1 {
switch code.next.op {
case opInt:
c.mask = code.next.mask
c.rshiftNum = code.next.rshiftNum
return opStructFieldHeadIntNPtr
case opUint:
c.mask = code.next.mask
return opStructFieldHeadUintNPtr
case opFloat32:
return opStructFieldHeadFloat32NPtr
case opFloat64:
return opStructFieldHeadFloat64NPtr
case opString:
return opStructFieldHeadStringNPtr
case opBool:
return opStructFieldHeadBoolNPtr
}
} else {
switch code.next.op {
case opInt:
c.mask = code.next.mask
c.rshiftNum = code.next.rshiftNum
return opStructFieldHeadIntPtr
case opUint:
c.mask = code.next.mask
return opStructFieldHeadUintPtr
case opFloat32:
return opStructFieldHeadFloat32Ptr
case opFloat64:
return opStructFieldHeadFloat64Ptr
case opString:
return opStructFieldHeadStringPtr
case opBool:
return opStructFieldHeadBoolPtr
case opSliceHead:
return opStructFieldHeadSlicePtr
case opArrayHead:
return opStructFieldHeadArrayPtr
case opMapHead:
return opStructFieldHeadMapPtr
case opMarshalJSON:
return opStructFieldHeadMarshalJSONPtr
case opMarshalText:
return opStructFieldHeadMarshalTextPtr
}
}
case opInt: case opInt:
return opStructFieldHeadInt return opStructFieldHeadInt
case opIntPtr:
return opStructFieldHeadIntPtr
case opUint: case opUint:
return opStructFieldHeadUint return opStructFieldHeadUint
case opUintPtr:
return opStructFieldHeadUintPtr
case opFloat32: case opFloat32:
return opStructFieldHeadFloat32 return opStructFieldHeadFloat32
case opFloat32Ptr:
return opStructFieldHeadFloat32Ptr
case opFloat64: case opFloat64:
return opStructFieldHeadFloat64 return opStructFieldHeadFloat64
case opFloat64Ptr:
return opStructFieldHeadFloat64Ptr
case opString: case opString:
return opStructFieldHeadString return opStructFieldHeadString
case opStringPtr:
return opStructFieldHeadStringPtr
case opBool: case opBool:
return opStructFieldHeadBool return opStructFieldHeadBool
case opMapHead: case opBoolPtr:
return opStructFieldHeadBoolPtr
case opMap:
return opStructFieldHeadMap return opStructFieldHeadMap
case opMapPtr:
code.op = opMap
return opStructFieldHeadMapPtr
case opMapHeadLoad: case opMapHeadLoad:
return opStructFieldHeadMapLoad return opStructFieldHeadMapLoad
case opArrayHead: case opArray:
return opStructFieldHeadArray return opStructFieldHeadArray
case opSliceHead: case opArrayPtr:
code.op = opArray
return opStructFieldHeadArrayPtr
case opSlice:
return opStructFieldHeadSlice return opStructFieldHeadSlice
case opSlicePtr:
code.op = opSlice
return opStructFieldHeadSlicePtr
case opMarshalJSON: case opMarshalJSON:
return opStructFieldHeadMarshalJSON return opStructFieldHeadMarshalJSON
case opMarshalJSONPtr: case opMarshalJSONPtr:
return opStructFieldHeadMarshalJSONPtr return opStructFieldHeadMarshalJSONPtr
case opMarshalText: case opMarshalText:
return opStructFieldHeadMarshalText return opStructFieldHeadMarshalText
case opMarshalTextPtr:
return opStructFieldHeadMarshalTextPtr
} }
return opStructFieldHead return opStructFieldHead
} }
func encodeTypeToFieldType(ctx *encodeCompileContext, code *opcode) opType { func encodeTypeToFieldType(ctx *encodeCompileContext, code *opcode) opType {
switch code.op { switch code.op {
case opPtr:
ptrNum := 1
ctx.decIndex()
c := code
for {
if code.next.op == opPtr {
ptrNum++
code = code.next
ctx.decIndex()
continue
}
break
}
c.ptrNum = ptrNum
if ptrNum > 1 {
switch code.next.op {
case opInt:
c.mask = code.next.mask
c.rshiftNum = code.next.rshiftNum
return opStructFieldIntNPtr
case opUint:
c.mask = code.next.mask
return opStructFieldUintNPtr
case opFloat32:
return opStructFieldFloat32NPtr
case opFloat64:
return opStructFieldFloat64NPtr
case opString:
return opStructFieldStringNPtr
case opBool:
return opStructFieldBoolNPtr
}
} else {
switch code.next.op {
case opInt:
c.mask = code.next.mask
c.rshiftNum = code.next.rshiftNum
return opStructFieldIntPtr
case opUint:
c.mask = code.next.mask
return opStructFieldUintPtr
case opFloat32:
return opStructFieldFloat32Ptr
case opFloat64:
return opStructFieldFloat64Ptr
case opString:
return opStructFieldStringPtr
case opBool:
return opStructFieldBoolPtr
case opSliceHead:
return opStructFieldSlicePtr
case opArrayHead:
return opStructFieldArrayPtr
case opMapHead:
return opStructFieldMapPtr
case opMarshalJSON:
return opStructFieldMarshalJSONPtr
case opMarshalText:
return opStructFieldMarshalTextPtr
}
}
case opInt: case opInt:
return opStructFieldInt return opStructFieldInt
case opIntPtr:
return opStructFieldIntPtr
case opUint: case opUint:
return opStructFieldUint return opStructFieldUint
case opUintPtr:
return opStructFieldUintPtr
case opFloat32: case opFloat32:
return opStructFieldFloat32 return opStructFieldFloat32
case opFloat32Ptr:
return opStructFieldFloat32Ptr
case opFloat64: case opFloat64:
return opStructFieldFloat64 return opStructFieldFloat64
case opFloat64Ptr:
return opStructFieldFloat64Ptr
case opString: case opString:
return opStructFieldString return opStructFieldString
case opStringPtr:
return opStructFieldStringPtr
case opBool: case opBool:
return opStructFieldBool return opStructFieldBool
case opMapHead: case opBoolPtr:
return opStructFieldBoolPtr
case opMap:
return opStructFieldMap return opStructFieldMap
case opMapPtr:
code.op = opMap
return opStructFieldMapPtr
case opMapHeadLoad: case opMapHeadLoad:
return opStructFieldMapLoad return opStructFieldMapLoad
case opArrayHead: case opArray:
return opStructFieldArray return opStructFieldArray
case opSliceHead: case opArrayPtr:
code.op = opArray
return opStructFieldArrayPtr
case opSlice:
return opStructFieldSlice return opStructFieldSlice
case opSlicePtr:
code.op = opSlice
return opStructFieldSlicePtr
case opStructFieldHead: case opStructFieldHead:
return opStructFieldStruct return opStructFieldStruct
case opMarshalJSON: case opMarshalJSON:
@ -876,6 +819,8 @@ func encodeTypeToFieldType(ctx *encodeCompileContext, code *opcode) opType {
return opStructFieldMarshalJSONPtr return opStructFieldMarshalJSONPtr
case opMarshalText: case opMarshalText:
return opStructFieldMarshalText return opStructFieldMarshalText
case opMarshalTextPtr:
return opStructFieldMarshalTextPtr
} }
return opStructField return opStructField
} }
@ -952,7 +897,6 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode
opStructFieldHeadMapPtr, opStructFieldHeadMapPtr,
opStructFieldHeadOmitEmptyMapPtr, opStructFieldHeadOmitEmptyMapPtr,
opStructFieldHeadStringTagMapPtr: opStructFieldHeadStringTagMapPtr:
*valueCode = *valueCode.next
return valueCode.beforeLastCode() return valueCode.beforeLastCode()
case opStructFieldHeadMarshalJSONPtr, case opStructFieldHeadMarshalJSONPtr,
opStructFieldHeadOmitEmptyMarshalJSONPtr, opStructFieldHeadOmitEmptyMarshalJSONPtr,
@ -961,7 +905,6 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode
opStructFieldHeadOmitEmptyMarshalTextPtr, opStructFieldHeadOmitEmptyMarshalTextPtr,
opStructFieldHeadStringTagMarshalTextPtr: opStructFieldHeadStringTagMarshalTextPtr:
ctx.decOpcodeIndex() ctx.decOpcodeIndex()
fieldCode.typ = fieldCode.typ.Elem()
return (*opcode)(unsafe.Pointer(fieldCode)) return (*opcode)(unsafe.Pointer(fieldCode))
} }
ctx.decOpcodeIndex() ctx.decOpcodeIndex()
@ -1003,7 +946,6 @@ func encodeStructField(ctx *encodeCompileContext, fieldCode *opcode, valueCode *
opStructFieldMapPtr, opStructFieldMapPtr,
opStructFieldOmitEmptyMapPtr, opStructFieldOmitEmptyMapPtr,
opStructFieldStringTagMapPtr: opStructFieldStringTagMapPtr:
*valueCode = *valueCode.next
return valueCode.beforeLastCode() return valueCode.beforeLastCode()
} }
ctx.decIndex() ctx.decIndex()
@ -1014,9 +956,6 @@ func encodeIsNotExistsField(head *opcode) bool {
if head == nil { if head == nil {
return false return false
} }
if head.op != opStructFieldAnonymousHead {
return false
}
if head.next == nil { if head.next == nil {
return false return false
} }
@ -1076,15 +1015,8 @@ func encodeAnonymousStructFieldPairMap(tags structTags, named string, valueCode
removedFields := map[*opcode]struct{}{} removedFields := map[*opcode]struct{}{}
for { for {
existsKey := tags.existsKey(f.displayKey) existsKey := tags.existsKey(f.displayKey)
op := f.op.headToAnonymousHead() if existsKey && (f.next.op == opStructFieldPtrHeadRecursive || f.next.op == opStructFieldHeadRecursive) {
if existsKey && (f.next.op == opStructFieldPtrAnonymousHeadRecursive || f.next.op == opStructFieldAnonymousHeadRecursive) {
// through // through
} else if op != f.op {
if existsKey {
f.op = opStructFieldAnonymousHead
} else if named == "" {
//f.op = op
}
} else if named == "" && f.op == opStructEnd { } else if named == "" && f.op == opStructEnd {
f.op = opStructAnonymousEnd f.op = opStructAnonymousEnd
} else if existsKey { } else if existsKey {
@ -1166,7 +1098,7 @@ func encodeOptimizeConflictAnonymousFields(anonymousFields map[string][]structFi
if !fieldPair.linked { if !fieldPair.linked {
if fieldPair.prevField == nil { if fieldPair.prevField == nil {
// head operation // head operation
fieldPair.curField.op = opStructFieldAnonymousHead fieldPair.curField.op = opStructFieldHead
} else { } else {
diff := fieldPair.curField.nextField.displayIdx - fieldPair.curField.displayIdx diff := fieldPair.curField.nextField.displayIdx - fieldPair.curField.displayIdx
for i := 0; i < diff; i++ { for i := 0; i < diff; i++ {
@ -1184,7 +1116,7 @@ func encodeOptimizeConflictAnonymousFields(anonymousFields map[string][]structFi
if !fieldPair.linked { if !fieldPair.linked {
if fieldPair.prevField == nil { if fieldPair.prevField == nil {
// head operation // head operation
fieldPair.curField.op = opStructFieldAnonymousHead fieldPair.curField.op = opStructFieldHead
} else { } else {
diff := fieldPair.curField.nextField.displayIdx - fieldPair.curField.displayIdx diff := fieldPair.curField.nextField.displayIdx - fieldPair.curField.displayIdx
removedFields[fieldPair.curField] = struct{}{} removedFields[fieldPair.curField] = struct{}{}

View File

@ -378,7 +378,7 @@ func newSliceHeaderCode(ctx *encodeCompileContext) *opcode {
ctx.incPtrIndex() ctx.incPtrIndex()
length := opcodeOffset(ctx.ptrIndex) length := opcodeOffset(ctx.ptrIndex)
return &opcode{ return &opcode{
op: opSliceHead, op: opSlice,
displayIdx: ctx.opcodeIndex, displayIdx: ctx.opcodeIndex,
idx: idx, idx: idx,
headIdx: idx, headIdx: idx,
@ -406,7 +406,7 @@ func newArrayHeaderCode(ctx *encodeCompileContext, alen int) *opcode {
ctx.incPtrIndex() ctx.incPtrIndex()
elemIdx := opcodeOffset(ctx.ptrIndex) elemIdx := opcodeOffset(ctx.ptrIndex)
return &opcode{ return &opcode{
op: opArrayHead, op: opArray,
displayIdx: ctx.opcodeIndex, displayIdx: ctx.opcodeIndex,
idx: idx, idx: idx,
headIdx: idx, headIdx: idx,
@ -434,7 +434,7 @@ func newMapHeaderCode(ctx *encodeCompileContext, withLoad bool) *opcode {
if withLoad { if withLoad {
op = opMapHeadLoad op = opMapHeadLoad
} else { } else {
op = opMapHead op = opMap
} }
idx := opcodeOffset(ctx.ptrIndex) idx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex() ctx.incPtrIndex()

File diff suppressed because it is too large Load Diff

View File

@ -237,7 +237,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
b = encodeComma(b) b = encodeComma(b)
} }
code = code.next code = code.next
case opSliceHead: case opSlice:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
slice := ptrToSlice(p) slice := ptrToSlice(p)
if p == 0 || slice.data == nil { if p == 0 || slice.data == nil {
@ -273,7 +273,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
b = encodeComma(b) b = encodeComma(b)
code = code.end.next code = code.end.next
} }
case opArrayHead: case opArray:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -305,7 +305,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
b = encodeComma(b) b = encodeComma(b)
code = code.end.next code = code.end.next
} }
case opMapHead: case opMap:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -772,29 +772,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadIntNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.key...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadUint: case opStructFieldPtrHeadUint:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -977,29 +954,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadUintNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.key...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat32: case opStructFieldPtrHeadFloat32:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1181,29 +1135,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat32NPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.key...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat64: case opStructFieldPtrHeadFloat64:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1408,33 +1339,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat64NPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.key...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadString: case opStructFieldPtrHeadString:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1613,29 +1517,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadStringNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.key...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBool: case opStructFieldPtrHeadBool:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1817,29 +1698,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadBoolNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.key...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBytes: case opStructFieldPtrHeadBytes:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -2822,23 +2680,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldIntNPtr:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opStructFieldUint: case opStructFieldUint:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...) b = append(b, code.key...)
@ -3529,23 +3370,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndIntNPtr:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = appendStructEnd(b)
code = code.next
case opStructEndUint: case opStructEndUint:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...) b = append(b, code.key...)
@ -3619,23 +3443,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndUintNPtr:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = appendStructEnd(b)
code = code.next
case opStructEndFloat32: case opStructEndFloat32:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...) b = append(b, code.key...)
@ -3708,23 +3515,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndFloat32NPtr:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = appendStructEnd(b)
code = code.next
case opStructEndFloat64: case opStructEndFloat64:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...) b = append(b, code.key...)
@ -3822,27 +3612,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndFloat64NPtr:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = appendStructEnd(b)
code = code.next
case opStructEndString: case opStructEndString:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...) b = append(b, code.key...)
@ -3913,23 +3682,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndStringNPtr:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeNoEscapedString(b, ptrToString(p))
}
b = appendStructEnd(b)
code = code.next
case opStructEndBool: case opStructEndBool:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...) b = append(b, code.key...)

View File

@ -77,6 +77,16 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opInterfacePtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opInterface: case opInterface:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
@ -179,7 +189,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = encodeComma(b) b = encodeComma(b)
} }
code = code.next code = code.next
case opSliceHead: case opSlice:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
slice := ptrToSlice(p) slice := ptrToSlice(p)
if p == 0 || uintptr(slice.data) == 0 { if p == 0 || uintptr(slice.data) == 0 {
@ -215,7 +225,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = encodeComma(b) b = encodeComma(b)
code = code.end.next code = code.end.next
} }
case opArrayHead: case opArray:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -247,7 +257,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = encodeComma(b) b = encodeComma(b)
code = code.end.next code = code.end.next
} }
case opMapHead: case opMap:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -534,7 +544,14 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
case opStructFieldPtrHeadInt: case opStructFieldPtrHeadInt:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
store(ctxptr, code.idx, p)
} }
fallthrough fallthrough
case opStructFieldHeadInt: case opStructFieldHeadInt:
@ -714,29 +731,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadIntNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadUint: case opStructFieldPtrHeadUint:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -919,29 +913,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadUintNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat32: case opStructFieldPtrHeadFloat32:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1123,29 +1094,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat32NPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadFloat64: case opStructFieldPtrHeadFloat64:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1350,36 +1298,16 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat64NPtr: case opStructFieldPtrHeadString:
if code.indirect {
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; i++ { for i := 0; i < code.ptrNum; i++ {
if p == 0 { if p == 0 {
break break
} }
p = ptrToPtr(p) p = ptrToPtr(p)
} }
if p == 0 { store(ctxptr, code.idx, p)
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadString:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
} }
fallthrough fallthrough
case opStructFieldHeadString: case opStructFieldHeadString:
@ -1555,29 +1483,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadStringNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBool: case opStructFieldPtrHeadBool:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1759,29 +1664,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldHeadBoolNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p+code.offset))
}
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadBytes: case opStructFieldPtrHeadBytes:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -2764,23 +2646,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldIntNPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opStructFieldUint: case opStructFieldUint:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
@ -3471,23 +3336,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndIntNPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = appendStructEnd(b)
code = code.next
case opStructEndUint: case opStructEndUint:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
@ -3561,23 +3409,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndUintNPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = appendStructEnd(b)
code = code.next
case opStructEndFloat32: case opStructEndFloat32:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
@ -3650,23 +3481,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndFloat32NPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = appendStructEnd(b)
code = code.next
case opStructEndFloat64: case opStructEndFloat64:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
@ -3764,27 +3578,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndFloat64NPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = appendStructEnd(b)
code = code.next
case opStructEndString: case opStructEndString:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
@ -3855,23 +3648,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} }
b = appendStructEnd(b) b = appendStructEnd(b)
code = code.next code = code.next
case opStructEndStringNPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
for i := 0; i < code.ptrNum-1; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = appendStructEnd(b)
code = code.next
case opStructEndBool: case opStructEndBool:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)

View File

@ -195,7 +195,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
b = encodeIndentComma(b) b = encodeIndentComma(b)
} }
code = code.next code = code.next
case opSliceHead: case opSlice:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
slice := ptrToSlice(p) slice := ptrToSlice(p)
if p == 0 || slice.data == nil { if p == 0 || slice.data == nil {
@ -273,7 +273,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
b = append(b, ']') b = append(b, ']')
code = code.end.next code = code.end.next
} }
case opArrayHead: case opArray:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -309,7 +309,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
b = append(b, ']', ',', '\n') b = append(b, ']', ',', '\n')
code = code.end.next code = code.end.next
} }
case opMapHead: case opMap:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -812,31 +812,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadIntNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadUint: case opStructFieldPtrHeadUint:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1030,31 +1005,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadUintNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat32: case opStructFieldPtrHeadFloat32:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1247,31 +1197,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat32NPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat64: case opStructFieldPtrHeadFloat64:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1487,35 +1412,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat64NPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadString: case opStructFieldPtrHeadString:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1706,31 +1602,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadStringNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p+code.offset))
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBool: case opStructFieldPtrHeadBool:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1923,31 +1794,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadBoolNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p+code.offset))
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBytes: case opStructFieldPtrHeadBytes:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))

View File

@ -195,7 +195,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
b = encodeIndentComma(b) b = encodeIndentComma(b)
} }
code = code.next code = code.next
case opSliceHead: case opSlice:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
slice := ptrToSlice(p) slice := ptrToSlice(p)
if p == 0 || slice.data == nil { if p == 0 || slice.data == nil {
@ -273,7 +273,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
b = append(b, ']') b = append(b, ']')
code = code.end.next code = code.end.next
} }
case opArrayHead: case opArray:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -309,7 +309,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
b = append(b, ']', ',', '\n') b = append(b, ']', ',', '\n')
code = code.end.next code = code.end.next
} }
case opMapHead: case opMap:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
b = encodeNull(b) b = encodeNull(b)
@ -812,33 +812,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadIntNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadUint: case opStructFieldPtrHeadUint:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1032,33 +1006,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadUintNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat32: case opStructFieldPtrHeadFloat32:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1251,33 +1198,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat32NPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.next
break
}
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadFloat64: case opStructFieldPtrHeadFloat64:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1493,35 +1413,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadFloat64NPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadString: case opStructFieldPtrHeadString:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1712,31 +1603,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadStringNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBool: case opStructFieldPtrHeadBool:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
@ -1929,31 +1795,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldHeadBoolNPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
} else {
if !code.anonymousHead {
b = append(b, '{', '\n')
}
b = appendIndent(ctx, b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p+code.offset))
}
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadBytes: case opStructFieldPtrHeadBytes:
if code.indirect { if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))