Fix opcode

This commit is contained in:
Masaaki Goshima 2021-03-10 02:12:53 +09:00
parent 37fb74bbb8
commit d0fb2a9a4e
9 changed files with 484 additions and 774 deletions

View File

@ -234,7 +234,7 @@ func (t opType) fieldToStringTagField() opType {
} }
primitiveTypes := []string{ primitiveTypes := []string{
"int", "uint", "float32", "float64", "bool", "string", "bytes", "int", "uint", "float32", "float64", "bool", "string", "bytes",
"array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive", "array", "map", "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", "interfacePtr", "arrayPtr", "slicePtr", "mapPtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr",
@ -253,7 +253,6 @@ func (t opType) fieldToStringTagField() opType {
createOpType("SliceEnd", "Op"), createOpType("SliceEnd", "Op"),
createOpType("ArrayElem", "ArrayElem"), createOpType("ArrayElem", "ArrayElem"),
createOpType("ArrayEnd", "Op"), createOpType("ArrayEnd", "Op"),
createOpType("MapHeadLoad", "MapHead"),
createOpType("MapKey", "MapKey"), createOpType("MapKey", "MapKey"),
createOpType("MapValue", "MapValue"), createOpType("MapValue", "MapValue"),
createOpType("MapEnd", "Op"), createOpType("MapEnd", "Op"),
@ -334,7 +333,7 @@ func (t opType) fieldToStringTagField() opType {
PtrHeadToHead: func() string { return op }, PtrHeadToHead: func() string { return op },
FieldToEnd: func() string { FieldToEnd: func() string {
switch typ { switch typ {
case "", "Array", "Map", "MapLoad", "Slice", "Struct", "Recursive": case "", "Array", "Map", "Slice", "Struct", "Recursive":
return op return op
} }
return fmt.Sprintf( return fmt.Sprintf(

View File

@ -368,7 +368,12 @@ func appendIndent(ctx *encodeRuntimeContext, b []byte, indent int) []byte {
} }
func encodeMarshalJSON(b []byte, v interface{}) ([]byte, error) { func encodeMarshalJSON(b []byte, v interface{}) ([]byte, error) {
bb, err := v.(Marshaler).MarshalJSON() v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(Marshaler)
if !ok {
return encodeNull(b), nil
}
bb, err := marshaler.MarshalJSON()
if err != nil { if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
} }
@ -387,7 +392,12 @@ func encodeMarshalJSON(b []byte, v interface{}) ([]byte, error) {
} }
func encodeMarshalJSONIndent(ctx *encodeRuntimeContext, b []byte, v interface{}, indent int) ([]byte, error) { func encodeMarshalJSONIndent(ctx *encodeRuntimeContext, b []byte, v interface{}, indent int) ([]byte, error) {
bb, err := v.(Marshaler).MarshalJSON() v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(Marshaler)
if !ok {
return encodeNull(b), nil
}
bb, err := marshaler.MarshalJSON()
if err != nil { if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
} }
@ -414,7 +424,12 @@ func encodeMarshalJSONIndent(ctx *encodeRuntimeContext, b []byte, v interface{},
} }
func encodeMarshalText(b []byte, v interface{}) ([]byte, error) { func encodeMarshalText(b []byte, v interface{}) ([]byte, error) {
bytes, err := v.(encoding.TextMarshaler).MarshalText() v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(encoding.TextMarshaler)
if !ok {
return encodeNull(b), nil
}
bytes, err := marshaler.MarshalText()
if err != nil { if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
} }
@ -422,7 +437,12 @@ func encodeMarshalText(b []byte, v interface{}) ([]byte, error) {
} }
func encodeMarshalTextIndent(b []byte, v interface{}) ([]byte, error) { func encodeMarshalTextIndent(b []byte, v interface{}) ([]byte, error) {
bytes, err := v.(encoding.TextMarshaler).MarshalText() v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(encoding.TextMarshaler)
if !ok {
return encodeNull(b), nil
}
bytes, err := marshaler.MarshalText()
if err != nil { if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err} return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
} }

View File

@ -72,7 +72,10 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) {
isPtr = true isPtr = true
} }
if typ.Kind() == reflect.Map { if typ.Kind() == reflect.Map {
return encodeCompileMap(ctx.withType(typ), isPtr) if isPtr {
return encodeCompilePtr(ctx.withType(rtype_ptrTo(typ)))
}
return encodeCompileMap(ctx.withType(typ))
} else if typ.Kind() == reflect.Struct { } else if typ.Kind() == reflect.Struct {
code, err := encodeCompileStruct(ctx.withType(typ), isPtr) code, err := encodeCompileStruct(ctx.withType(typ), isPtr)
if err != nil { if err != nil {
@ -212,7 +215,7 @@ func encodeCompile(ctx *encodeCompileContext, isPtr bool) (*opcode, error) {
case reflect.Array: case reflect.Array:
return encodeCompileArray(ctx) return encodeCompileArray(ctx)
case reflect.Map: case reflect.Map:
return encodeCompileMap(ctx, isPtr) return encodeCompileMap(ctx)
case reflect.Struct: case reflect.Struct:
return encodeCompileStruct(ctx, isPtr) return encodeCompileStruct(ctx, isPtr)
case reflect.Interface: case reflect.Interface:
@ -665,12 +668,12 @@ func mapiternext(it unsafe.Pointer)
//go:noescape //go:noescape
func maplen(m unsafe.Pointer) int func maplen(m unsafe.Pointer) int
func encodeCompileMap(ctx *encodeCompileContext, withLoad bool) (*opcode, error) { func encodeCompileMap(ctx *encodeCompileContext) (*opcode, error) {
// header => code => value => code => key => code => value => code => end // header => code => value => code => key => code => value => code => end
// ^ | // ^ |
// |_______________________| // |_______________________|
ctx = ctx.incIndent() ctx = ctx.incIndent()
header := newMapHeaderCode(ctx, false) //withLoad) header := newMapHeaderCode(ctx)
ctx.incIndex() ctx.incIndex()
typ := ctx.typ typ := ctx.typ
@ -744,8 +747,6 @@ func encodeTypeToHeaderType(ctx *encodeCompileContext, code *opcode) opType {
case opMapPtr: case opMapPtr:
code.op = opMap code.op = opMap
return opStructFieldHeadMapPtr return opStructFieldHeadMapPtr
case opMapHeadLoad:
return opStructFieldHeadMapLoad
case opArray: case opArray:
return opStructFieldHeadArray return opStructFieldHeadArray
case opArrayPtr: case opArrayPtr:
@ -799,8 +800,6 @@ func encodeTypeToFieldType(ctx *encodeCompileContext, code *opcode) opType {
case opMapPtr: case opMapPtr:
code.op = opMap code.op = opMap
return opStructFieldMapPtr return opStructFieldMapPtr
case opMapHeadLoad:
return opStructFieldMapLoad
case opArray: case opArray:
return opStructFieldArray return opStructFieldArray
case opArrayPtr: case opArrayPtr:
@ -874,7 +873,6 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode
opStructFieldHeadSlice, opStructFieldHeadSlice,
opStructFieldHeadArray, opStructFieldHeadArray,
opStructFieldHeadMap, opStructFieldHeadMap,
opStructFieldHeadMapLoad,
opStructFieldHeadStruct, opStructFieldHeadStruct,
opStructFieldHeadOmitEmpty, opStructFieldHeadOmitEmpty,
opStructFieldHeadOmitEmptySlice, opStructFieldHeadOmitEmptySlice,
@ -882,9 +880,7 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode
opStructFieldHeadOmitEmptyArray, opStructFieldHeadOmitEmptyArray,
opStructFieldHeadStringTagArray, opStructFieldHeadStringTagArray,
opStructFieldHeadOmitEmptyMap, opStructFieldHeadOmitEmptyMap,
opStructFieldHeadOmitEmptyMapLoad,
opStructFieldHeadStringTagMap, opStructFieldHeadStringTagMap,
opStructFieldHeadStringTagMapLoad,
opStructFieldHeadOmitEmptyStruct, opStructFieldHeadOmitEmptyStruct,
opStructFieldHeadStringTag: opStructFieldHeadStringTag:
return valueCode.beforeLastCode() return valueCode.beforeLastCode()
@ -923,7 +919,6 @@ func encodeStructField(ctx *encodeCompileContext, fieldCode *opcode, valueCode *
opStructFieldSlice, opStructFieldSlice,
opStructFieldArray, opStructFieldArray,
opStructFieldMap, opStructFieldMap,
opStructFieldMapLoad,
opStructFieldStruct, opStructFieldStruct,
opStructFieldOmitEmpty, opStructFieldOmitEmpty,
opStructFieldOmitEmptySlice, opStructFieldOmitEmptySlice,
@ -931,9 +926,7 @@ func encodeStructField(ctx *encodeCompileContext, fieldCode *opcode, valueCode *
opStructFieldOmitEmptyArray, opStructFieldOmitEmptyArray,
opStructFieldStringTagArray, opStructFieldStringTagArray,
opStructFieldOmitEmptyMap, opStructFieldOmitEmptyMap,
opStructFieldOmitEmptyMapLoad,
opStructFieldStringTagMap, opStructFieldStringTagMap,
opStructFieldStringTagMapLoad,
opStructFieldOmitEmptyStruct, opStructFieldOmitEmptyStruct,
opStructFieldStringTag: opStructFieldStringTag:
return valueCode.beforeLastCode() return valueCode.beforeLastCode()
@ -1176,8 +1169,11 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error)
ctx.incIndex() ctx.incIndex()
nilcheck := true nilcheck := true
var valueCode *opcode var valueCode *opcode
if i == 0 && fieldNum == 1 && isPtr && fieldType.Kind() != reflect.Ptr && rtype_ptrTo(fieldType).Implements(marshalJSONType) && !fieldType.Implements(marshalJSONType) { fmt.Println("fieldType.Kind() = ", fieldType.Kind())
// *struct{ field implementedMarshalJSONType } => struct { field *implementedMarshalJSONType } isNilValue := fieldType.Kind() == reflect.Ptr || fieldType.Kind() == reflect.Interface
if i == 0 && fieldNum == 1 && isPtr && !isNilValue && rtype_ptrTo(fieldType).Implements(marshalJSONType) && !fieldType.Implements(marshalJSONType) {
// *struct{ field T } => struct { field *T }
// func (*T) MarshalJSON() ([]byte, error)
// move pointer position from head to first field // move pointer position from head to first field
code, err := encodeCompileMarshalJSON(ctx.withType(rtype_ptrTo(fieldType))) code, err := encodeCompileMarshalJSON(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil { if err != nil {
@ -1187,7 +1183,10 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error)
nilcheck = false nilcheck = false
indirect = false indirect = false
disableIndirectConversion = true disableIndirectConversion = true
} else if i == 0 && fieldNum == 1 && isPtr && fieldType.Kind() != reflect.Ptr && rtype_ptrTo(fieldType).Implements(marshalTextType) && !fieldType.Implements(marshalTextType) { } else if i == 0 && fieldNum == 1 && isPtr && !isNilValue && rtype_ptrTo(fieldType).Implements(marshalTextType) && !fieldType.Implements(marshalTextType) {
// *struct{ field T } => struct { field *T }
// func (*T) MarshalText() ([]byte, error)
// move pointer position from head to first field
code, err := encodeCompileMarshalText(ctx.withType(rtype_ptrTo(fieldType))) code, err := encodeCompileMarshalText(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil { if err != nil {
return nil, err return nil, err
@ -1196,14 +1195,18 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error)
nilcheck = false nilcheck = false
indirect = false indirect = false
disableIndirectConversion = true disableIndirectConversion = true
} else if isPtr && fieldType.Kind() != reflect.Ptr && !fieldType.Implements(marshalJSONType) && rtype_ptrTo(fieldType).Implements(marshalJSONType) { } else if isPtr && !isNilValue && !fieldType.Implements(marshalJSONType) && rtype_ptrTo(fieldType).Implements(marshalJSONType) {
// *struct{ field T }
// func (*T) MarshalJSON() ([]byte, error)
code, err := encodeCompileMarshalJSON(ctx.withType(rtype_ptrTo(fieldType))) code, err := encodeCompileMarshalJSON(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil { if err != nil {
return nil, err return nil, err
} }
nilcheck = false nilcheck = false
valueCode = code valueCode = code
} else if isPtr && fieldType.Kind() != reflect.Ptr && !fieldType.Implements(marshalTextType) && rtype_ptrTo(fieldType).Implements(marshalTextType) { } else if isPtr && !isNilValue && !fieldType.Implements(marshalTextType) && rtype_ptrTo(fieldType).Implements(marshalTextType) {
// *struct{ field T }
// func (*T) MarshalText() ([]byte, error)
code, err := encodeCompileMarshalText(ctx.withType(rtype_ptrTo(fieldType))) code, err := encodeCompileMarshalText(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -429,13 +429,7 @@ func newArrayElemCode(ctx *encodeCompileContext, head *opcode, length int, size
} }
} }
func newMapHeaderCode(ctx *encodeCompileContext, withLoad bool) *opcode { func newMapHeaderCode(ctx *encodeCompileContext) *opcode {
var op opType
if withLoad {
op = opMapHeadLoad
} else {
op = opMap
}
idx := opcodeOffset(ctx.ptrIndex) idx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex() ctx.incPtrIndex()
elemIdx := opcodeOffset(ctx.ptrIndex) elemIdx := opcodeOffset(ctx.ptrIndex)
@ -444,7 +438,7 @@ func newMapHeaderCode(ctx *encodeCompileContext, withLoad bool) *opcode {
ctx.incPtrIndex() ctx.incPtrIndex()
mapIter := opcodeOffset(ctx.ptrIndex) mapIter := opcodeOffset(ctx.ptrIndex)
return &opcode{ return &opcode{
op: op, op: opMap,
typ: ctx.typ, typ: ctx.typ,
displayIdx: ctx.opcodeIndex, displayIdx: ctx.opcodeIndex,
idx: idx, idx: idx,

View File

@ -22,7 +22,7 @@ const (
codeStructEnd codeType = 11 codeStructEnd codeType = 11
) )
var opTypeStrings = [417]string{ var opTypeStrings = [403]string{
"End", "End",
"Interface", "Interface",
"Ptr", "Ptr",
@ -32,7 +32,6 @@ var opTypeStrings = [417]string{
"SliceEnd", "SliceEnd",
"ArrayElem", "ArrayElem",
"ArrayEnd", "ArrayEnd",
"MapHeadLoad",
"MapKey", "MapKey",
"MapValue", "MapValue",
"MapEnd", "MapEnd",
@ -47,7 +46,6 @@ var opTypeStrings = [417]string{
"Bytes", "Bytes",
"Array", "Array",
"Map", "Map",
"MapLoad",
"Slice", "Slice",
"Struct", "Struct",
"MarshalJSON", "MarshalJSON",
@ -122,12 +120,6 @@ var opTypeStrings = [417]string{
"StructFieldPtrHeadMap", "StructFieldPtrHeadMap",
"StructFieldPtrHeadOmitEmptyMap", "StructFieldPtrHeadOmitEmptyMap",
"StructFieldPtrHeadStringTagMap", "StructFieldPtrHeadStringTagMap",
"StructFieldHeadMapLoad",
"StructFieldHeadOmitEmptyMapLoad",
"StructFieldHeadStringTagMapLoad",
"StructFieldPtrHeadMapLoad",
"StructFieldPtrHeadOmitEmptyMapLoad",
"StructFieldPtrHeadStringTagMapLoad",
"StructFieldHeadSlice", "StructFieldHeadSlice",
"StructFieldHeadOmitEmptySlice", "StructFieldHeadOmitEmptySlice",
"StructFieldHeadStringTagSlice", "StructFieldHeadStringTagSlice",
@ -281,9 +273,6 @@ var opTypeStrings = [417]string{
"StructFieldMap", "StructFieldMap",
"StructFieldOmitEmptyMap", "StructFieldOmitEmptyMap",
"StructFieldStringTagMap", "StructFieldStringTagMap",
"StructFieldMapLoad",
"StructFieldOmitEmptyMapLoad",
"StructFieldStringTagMapLoad",
"StructFieldSlice", "StructFieldSlice",
"StructFieldOmitEmptySlice", "StructFieldOmitEmptySlice",
"StructFieldStringTagSlice", "StructFieldStringTagSlice",
@ -374,9 +363,6 @@ var opTypeStrings = [417]string{
"StructEndMap", "StructEndMap",
"StructEndOmitEmptyMap", "StructEndOmitEmptyMap",
"StructEndStringTagMap", "StructEndStringTagMap",
"StructEndMapLoad",
"StructEndOmitEmptyMapLoad",
"StructEndStringTagMapLoad",
"StructEndSlice", "StructEndSlice",
"StructEndOmitEmptySlice", "StructEndOmitEmptySlice",
"StructEndStringTagSlice", "StructEndStringTagSlice",
@ -454,418 +440,404 @@ const (
opSliceEnd opType = 6 opSliceEnd opType = 6
opArrayElem opType = 7 opArrayElem opType = 7
opArrayEnd opType = 8 opArrayEnd opType = 8
opMapHeadLoad opType = 9 opMapKey opType = 9
opMapKey opType = 10 opMapValue opType = 10
opMapValue opType = 11 opMapEnd opType = 11
opMapEnd opType = 12 opStructFieldRecursiveEnd opType = 12
opStructFieldRecursiveEnd opType = 13 opStructAnonymousEnd opType = 13
opStructAnonymousEnd opType = 14 opInt opType = 14
opInt opType = 15 opUint opType = 15
opUint opType = 16 opFloat32 opType = 16
opFloat32 opType = 17 opFloat64 opType = 17
opFloat64 opType = 18 opBool opType = 18
opBool opType = 19 opString opType = 19
opString opType = 20 opBytes opType = 20
opBytes opType = 21 opArray opType = 21
opArray opType = 22 opMap opType = 22
opMap opType = 23 opSlice opType = 23
opMapLoad opType = 24 opStruct opType = 24
opSlice opType = 25 opMarshalJSON opType = 25
opStruct opType = 26 opMarshalText opType = 26
opMarshalJSON opType = 27 opRecursive opType = 27
opMarshalText opType = 28 opIntString opType = 28
opRecursive opType = 29 opUintString opType = 29
opIntString opType = 30 opIntPtr opType = 30
opUintString opType = 31 opUintPtr opType = 31
opIntPtr opType = 32 opFloat32Ptr opType = 32
opUintPtr opType = 33 opFloat64Ptr opType = 33
opFloat32Ptr opType = 34 opBoolPtr opType = 34
opFloat64Ptr opType = 35 opStringPtr opType = 35
opBoolPtr opType = 36 opBytesPtr opType = 36
opStringPtr opType = 37 opArrayPtr opType = 37
opBytesPtr opType = 38 opSlicePtr opType = 38
opArrayPtr opType = 39 opMapPtr opType = 39
opSlicePtr opType = 40 opMarshalJSONPtr opType = 40
opMapPtr opType = 41 opMarshalTextPtr opType = 41
opMarshalJSONPtr opType = 42 opInterfacePtr opType = 42
opMarshalTextPtr opType = 43 opStructFieldHeadInt opType = 43
opInterfacePtr opType = 44 opStructFieldHeadOmitEmptyInt opType = 44
opStructFieldHeadInt opType = 45 opStructFieldHeadStringTagInt opType = 45
opStructFieldHeadOmitEmptyInt opType = 46 opStructFieldPtrHeadInt opType = 46
opStructFieldHeadStringTagInt opType = 47 opStructFieldPtrHeadOmitEmptyInt opType = 47
opStructFieldPtrHeadInt opType = 48 opStructFieldPtrHeadStringTagInt opType = 48
opStructFieldPtrHeadOmitEmptyInt opType = 49 opStructFieldHeadUint opType = 49
opStructFieldPtrHeadStringTagInt opType = 50 opStructFieldHeadOmitEmptyUint opType = 50
opStructFieldHeadUint opType = 51 opStructFieldHeadStringTagUint opType = 51
opStructFieldHeadOmitEmptyUint opType = 52 opStructFieldPtrHeadUint opType = 52
opStructFieldHeadStringTagUint opType = 53 opStructFieldPtrHeadOmitEmptyUint opType = 53
opStructFieldPtrHeadUint opType = 54 opStructFieldPtrHeadStringTagUint opType = 54
opStructFieldPtrHeadOmitEmptyUint opType = 55 opStructFieldHeadFloat32 opType = 55
opStructFieldPtrHeadStringTagUint opType = 56 opStructFieldHeadOmitEmptyFloat32 opType = 56
opStructFieldHeadFloat32 opType = 57 opStructFieldHeadStringTagFloat32 opType = 57
opStructFieldHeadOmitEmptyFloat32 opType = 58 opStructFieldPtrHeadFloat32 opType = 58
opStructFieldHeadStringTagFloat32 opType = 59 opStructFieldPtrHeadOmitEmptyFloat32 opType = 59
opStructFieldPtrHeadFloat32 opType = 60 opStructFieldPtrHeadStringTagFloat32 opType = 60
opStructFieldPtrHeadOmitEmptyFloat32 opType = 61 opStructFieldHeadFloat64 opType = 61
opStructFieldPtrHeadStringTagFloat32 opType = 62 opStructFieldHeadOmitEmptyFloat64 opType = 62
opStructFieldHeadFloat64 opType = 63 opStructFieldHeadStringTagFloat64 opType = 63
opStructFieldHeadOmitEmptyFloat64 opType = 64 opStructFieldPtrHeadFloat64 opType = 64
opStructFieldHeadStringTagFloat64 opType = 65 opStructFieldPtrHeadOmitEmptyFloat64 opType = 65
opStructFieldPtrHeadFloat64 opType = 66 opStructFieldPtrHeadStringTagFloat64 opType = 66
opStructFieldPtrHeadOmitEmptyFloat64 opType = 67 opStructFieldHeadBool opType = 67
opStructFieldPtrHeadStringTagFloat64 opType = 68 opStructFieldHeadOmitEmptyBool opType = 68
opStructFieldHeadBool opType = 69 opStructFieldHeadStringTagBool opType = 69
opStructFieldHeadOmitEmptyBool opType = 70 opStructFieldPtrHeadBool opType = 70
opStructFieldHeadStringTagBool opType = 71 opStructFieldPtrHeadOmitEmptyBool opType = 71
opStructFieldPtrHeadBool opType = 72 opStructFieldPtrHeadStringTagBool opType = 72
opStructFieldPtrHeadOmitEmptyBool opType = 73 opStructFieldHeadString opType = 73
opStructFieldPtrHeadStringTagBool opType = 74 opStructFieldHeadOmitEmptyString opType = 74
opStructFieldHeadString opType = 75 opStructFieldHeadStringTagString opType = 75
opStructFieldHeadOmitEmptyString opType = 76 opStructFieldPtrHeadString opType = 76
opStructFieldHeadStringTagString opType = 77 opStructFieldPtrHeadOmitEmptyString opType = 77
opStructFieldPtrHeadString opType = 78 opStructFieldPtrHeadStringTagString opType = 78
opStructFieldPtrHeadOmitEmptyString opType = 79 opStructFieldHeadBytes opType = 79
opStructFieldPtrHeadStringTagString opType = 80 opStructFieldHeadOmitEmptyBytes opType = 80
opStructFieldHeadBytes opType = 81 opStructFieldHeadStringTagBytes opType = 81
opStructFieldHeadOmitEmptyBytes opType = 82 opStructFieldPtrHeadBytes opType = 82
opStructFieldHeadStringTagBytes opType = 83 opStructFieldPtrHeadOmitEmptyBytes opType = 83
opStructFieldPtrHeadBytes opType = 84 opStructFieldPtrHeadStringTagBytes opType = 84
opStructFieldPtrHeadOmitEmptyBytes opType = 85 opStructFieldHeadArray opType = 85
opStructFieldPtrHeadStringTagBytes opType = 86 opStructFieldHeadOmitEmptyArray opType = 86
opStructFieldHeadArray opType = 87 opStructFieldHeadStringTagArray opType = 87
opStructFieldHeadOmitEmptyArray opType = 88 opStructFieldPtrHeadArray opType = 88
opStructFieldHeadStringTagArray opType = 89 opStructFieldPtrHeadOmitEmptyArray opType = 89
opStructFieldPtrHeadArray opType = 90 opStructFieldPtrHeadStringTagArray opType = 90
opStructFieldPtrHeadOmitEmptyArray opType = 91 opStructFieldHeadMap opType = 91
opStructFieldPtrHeadStringTagArray opType = 92 opStructFieldHeadOmitEmptyMap opType = 92
opStructFieldHeadMap opType = 93 opStructFieldHeadStringTagMap opType = 93
opStructFieldHeadOmitEmptyMap opType = 94 opStructFieldPtrHeadMap opType = 94
opStructFieldHeadStringTagMap opType = 95 opStructFieldPtrHeadOmitEmptyMap opType = 95
opStructFieldPtrHeadMap opType = 96 opStructFieldPtrHeadStringTagMap opType = 96
opStructFieldPtrHeadOmitEmptyMap opType = 97 opStructFieldHeadSlice opType = 97
opStructFieldPtrHeadStringTagMap opType = 98 opStructFieldHeadOmitEmptySlice opType = 98
opStructFieldHeadMapLoad opType = 99 opStructFieldHeadStringTagSlice opType = 99
opStructFieldHeadOmitEmptyMapLoad opType = 100 opStructFieldPtrHeadSlice opType = 100
opStructFieldHeadStringTagMapLoad opType = 101 opStructFieldPtrHeadOmitEmptySlice opType = 101
opStructFieldPtrHeadMapLoad opType = 102 opStructFieldPtrHeadStringTagSlice opType = 102
opStructFieldPtrHeadOmitEmptyMapLoad opType = 103 opStructFieldHeadStruct opType = 103
opStructFieldPtrHeadStringTagMapLoad opType = 104 opStructFieldHeadOmitEmptyStruct opType = 104
opStructFieldHeadSlice opType = 105 opStructFieldHeadStringTagStruct opType = 105
opStructFieldHeadOmitEmptySlice opType = 106 opStructFieldPtrHeadStruct opType = 106
opStructFieldHeadStringTagSlice opType = 107 opStructFieldPtrHeadOmitEmptyStruct opType = 107
opStructFieldPtrHeadSlice opType = 108 opStructFieldPtrHeadStringTagStruct opType = 108
opStructFieldPtrHeadOmitEmptySlice opType = 109 opStructFieldHeadMarshalJSON opType = 109
opStructFieldPtrHeadStringTagSlice opType = 110 opStructFieldHeadOmitEmptyMarshalJSON opType = 110
opStructFieldHeadStruct opType = 111 opStructFieldHeadStringTagMarshalJSON opType = 111
opStructFieldHeadOmitEmptyStruct opType = 112 opStructFieldPtrHeadMarshalJSON opType = 112
opStructFieldHeadStringTagStruct opType = 113 opStructFieldPtrHeadOmitEmptyMarshalJSON opType = 113
opStructFieldPtrHeadStruct opType = 114 opStructFieldPtrHeadStringTagMarshalJSON opType = 114
opStructFieldPtrHeadOmitEmptyStruct opType = 115 opStructFieldHeadMarshalText opType = 115
opStructFieldPtrHeadStringTagStruct opType = 116 opStructFieldHeadOmitEmptyMarshalText opType = 116
opStructFieldHeadMarshalJSON opType = 117 opStructFieldHeadStringTagMarshalText opType = 117
opStructFieldHeadOmitEmptyMarshalJSON opType = 118 opStructFieldPtrHeadMarshalText opType = 118
opStructFieldHeadStringTagMarshalJSON opType = 119 opStructFieldPtrHeadOmitEmptyMarshalText opType = 119
opStructFieldPtrHeadMarshalJSON opType = 120 opStructFieldPtrHeadStringTagMarshalText opType = 120
opStructFieldPtrHeadOmitEmptyMarshalJSON opType = 121 opStructFieldHeadRecursive opType = 121
opStructFieldPtrHeadStringTagMarshalJSON opType = 122 opStructFieldHeadOmitEmptyRecursive opType = 122
opStructFieldHeadMarshalText opType = 123 opStructFieldHeadStringTagRecursive opType = 123
opStructFieldHeadOmitEmptyMarshalText opType = 124 opStructFieldPtrHeadRecursive opType = 124
opStructFieldHeadStringTagMarshalText opType = 125 opStructFieldPtrHeadOmitEmptyRecursive opType = 125
opStructFieldPtrHeadMarshalText opType = 126 opStructFieldPtrHeadStringTagRecursive opType = 126
opStructFieldPtrHeadOmitEmptyMarshalText opType = 127 opStructFieldHeadIntString opType = 127
opStructFieldPtrHeadStringTagMarshalText opType = 128 opStructFieldHeadOmitEmptyIntString opType = 128
opStructFieldHeadRecursive opType = 129 opStructFieldHeadStringTagIntString opType = 129
opStructFieldHeadOmitEmptyRecursive opType = 130 opStructFieldPtrHeadIntString opType = 130
opStructFieldHeadStringTagRecursive opType = 131 opStructFieldPtrHeadOmitEmptyIntString opType = 131
opStructFieldPtrHeadRecursive opType = 132 opStructFieldPtrHeadStringTagIntString opType = 132
opStructFieldPtrHeadOmitEmptyRecursive opType = 133 opStructFieldHeadUintString opType = 133
opStructFieldPtrHeadStringTagRecursive opType = 134 opStructFieldHeadOmitEmptyUintString opType = 134
opStructFieldHeadIntString opType = 135 opStructFieldHeadStringTagUintString opType = 135
opStructFieldHeadOmitEmptyIntString opType = 136 opStructFieldPtrHeadUintString opType = 136
opStructFieldHeadStringTagIntString opType = 137 opStructFieldPtrHeadOmitEmptyUintString opType = 137
opStructFieldPtrHeadIntString opType = 138 opStructFieldPtrHeadStringTagUintString opType = 138
opStructFieldPtrHeadOmitEmptyIntString opType = 139 opStructFieldHeadIntPtr opType = 139
opStructFieldPtrHeadStringTagIntString opType = 140 opStructFieldHeadOmitEmptyIntPtr opType = 140
opStructFieldHeadUintString opType = 141 opStructFieldHeadStringTagIntPtr opType = 141
opStructFieldHeadOmitEmptyUintString opType = 142 opStructFieldPtrHeadIntPtr opType = 142
opStructFieldHeadStringTagUintString opType = 143 opStructFieldPtrHeadOmitEmptyIntPtr opType = 143
opStructFieldPtrHeadUintString opType = 144 opStructFieldPtrHeadStringTagIntPtr opType = 144
opStructFieldPtrHeadOmitEmptyUintString opType = 145 opStructFieldHeadUintPtr opType = 145
opStructFieldPtrHeadStringTagUintString opType = 146 opStructFieldHeadOmitEmptyUintPtr opType = 146
opStructFieldHeadIntPtr opType = 147 opStructFieldHeadStringTagUintPtr opType = 147
opStructFieldHeadOmitEmptyIntPtr opType = 148 opStructFieldPtrHeadUintPtr opType = 148
opStructFieldHeadStringTagIntPtr opType = 149 opStructFieldPtrHeadOmitEmptyUintPtr opType = 149
opStructFieldPtrHeadIntPtr opType = 150 opStructFieldPtrHeadStringTagUintPtr opType = 150
opStructFieldPtrHeadOmitEmptyIntPtr opType = 151 opStructFieldHeadFloat32Ptr opType = 151
opStructFieldPtrHeadStringTagIntPtr opType = 152 opStructFieldHeadOmitEmptyFloat32Ptr opType = 152
opStructFieldHeadUintPtr opType = 153 opStructFieldHeadStringTagFloat32Ptr opType = 153
opStructFieldHeadOmitEmptyUintPtr opType = 154 opStructFieldPtrHeadFloat32Ptr opType = 154
opStructFieldHeadStringTagUintPtr opType = 155 opStructFieldPtrHeadOmitEmptyFloat32Ptr opType = 155
opStructFieldPtrHeadUintPtr opType = 156 opStructFieldPtrHeadStringTagFloat32Ptr opType = 156
opStructFieldPtrHeadOmitEmptyUintPtr opType = 157 opStructFieldHeadFloat64Ptr opType = 157
opStructFieldPtrHeadStringTagUintPtr opType = 158 opStructFieldHeadOmitEmptyFloat64Ptr opType = 158
opStructFieldHeadFloat32Ptr opType = 159 opStructFieldHeadStringTagFloat64Ptr opType = 159
opStructFieldHeadOmitEmptyFloat32Ptr opType = 160 opStructFieldPtrHeadFloat64Ptr opType = 160
opStructFieldHeadStringTagFloat32Ptr opType = 161 opStructFieldPtrHeadOmitEmptyFloat64Ptr opType = 161
opStructFieldPtrHeadFloat32Ptr opType = 162 opStructFieldPtrHeadStringTagFloat64Ptr opType = 162
opStructFieldPtrHeadOmitEmptyFloat32Ptr opType = 163 opStructFieldHeadBoolPtr opType = 163
opStructFieldPtrHeadStringTagFloat32Ptr opType = 164 opStructFieldHeadOmitEmptyBoolPtr opType = 164
opStructFieldHeadFloat64Ptr opType = 165 opStructFieldHeadStringTagBoolPtr opType = 165
opStructFieldHeadOmitEmptyFloat64Ptr opType = 166 opStructFieldPtrHeadBoolPtr opType = 166
opStructFieldHeadStringTagFloat64Ptr opType = 167 opStructFieldPtrHeadOmitEmptyBoolPtr opType = 167
opStructFieldPtrHeadFloat64Ptr opType = 168 opStructFieldPtrHeadStringTagBoolPtr opType = 168
opStructFieldPtrHeadOmitEmptyFloat64Ptr opType = 169 opStructFieldHeadStringPtr opType = 169
opStructFieldPtrHeadStringTagFloat64Ptr opType = 170 opStructFieldHeadOmitEmptyStringPtr opType = 170
opStructFieldHeadBoolPtr opType = 171 opStructFieldHeadStringTagStringPtr opType = 171
opStructFieldHeadOmitEmptyBoolPtr opType = 172 opStructFieldPtrHeadStringPtr opType = 172
opStructFieldHeadStringTagBoolPtr opType = 173 opStructFieldPtrHeadOmitEmptyStringPtr opType = 173
opStructFieldPtrHeadBoolPtr opType = 174 opStructFieldPtrHeadStringTagStringPtr opType = 174
opStructFieldPtrHeadOmitEmptyBoolPtr opType = 175 opStructFieldHeadBytesPtr opType = 175
opStructFieldPtrHeadStringTagBoolPtr opType = 176 opStructFieldHeadOmitEmptyBytesPtr opType = 176
opStructFieldHeadStringPtr opType = 177 opStructFieldHeadStringTagBytesPtr opType = 177
opStructFieldHeadOmitEmptyStringPtr opType = 178 opStructFieldPtrHeadBytesPtr opType = 178
opStructFieldHeadStringTagStringPtr opType = 179 opStructFieldPtrHeadOmitEmptyBytesPtr opType = 179
opStructFieldPtrHeadStringPtr opType = 180 opStructFieldPtrHeadStringTagBytesPtr opType = 180
opStructFieldPtrHeadOmitEmptyStringPtr opType = 181 opStructFieldHeadArrayPtr opType = 181
opStructFieldPtrHeadStringTagStringPtr opType = 182 opStructFieldHeadOmitEmptyArrayPtr opType = 182
opStructFieldHeadBytesPtr opType = 183 opStructFieldHeadStringTagArrayPtr opType = 183
opStructFieldHeadOmitEmptyBytesPtr opType = 184 opStructFieldPtrHeadArrayPtr opType = 184
opStructFieldHeadStringTagBytesPtr opType = 185 opStructFieldPtrHeadOmitEmptyArrayPtr opType = 185
opStructFieldPtrHeadBytesPtr opType = 186 opStructFieldPtrHeadStringTagArrayPtr opType = 186
opStructFieldPtrHeadOmitEmptyBytesPtr opType = 187 opStructFieldHeadSlicePtr opType = 187
opStructFieldPtrHeadStringTagBytesPtr opType = 188 opStructFieldHeadOmitEmptySlicePtr opType = 188
opStructFieldHeadArrayPtr opType = 189 opStructFieldHeadStringTagSlicePtr opType = 189
opStructFieldHeadOmitEmptyArrayPtr opType = 190 opStructFieldPtrHeadSlicePtr opType = 190
opStructFieldHeadStringTagArrayPtr opType = 191 opStructFieldPtrHeadOmitEmptySlicePtr opType = 191
opStructFieldPtrHeadArrayPtr opType = 192 opStructFieldPtrHeadStringTagSlicePtr opType = 192
opStructFieldPtrHeadOmitEmptyArrayPtr opType = 193 opStructFieldHeadMapPtr opType = 193
opStructFieldPtrHeadStringTagArrayPtr opType = 194 opStructFieldHeadOmitEmptyMapPtr opType = 194
opStructFieldHeadSlicePtr opType = 195 opStructFieldHeadStringTagMapPtr opType = 195
opStructFieldHeadOmitEmptySlicePtr opType = 196 opStructFieldPtrHeadMapPtr opType = 196
opStructFieldHeadStringTagSlicePtr opType = 197 opStructFieldPtrHeadOmitEmptyMapPtr opType = 197
opStructFieldPtrHeadSlicePtr opType = 198 opStructFieldPtrHeadStringTagMapPtr opType = 198
opStructFieldPtrHeadOmitEmptySlicePtr opType = 199 opStructFieldHeadMarshalJSONPtr opType = 199
opStructFieldPtrHeadStringTagSlicePtr opType = 200 opStructFieldHeadOmitEmptyMarshalJSONPtr opType = 200
opStructFieldHeadMapPtr opType = 201 opStructFieldHeadStringTagMarshalJSONPtr opType = 201
opStructFieldHeadOmitEmptyMapPtr opType = 202 opStructFieldPtrHeadMarshalJSONPtr opType = 202
opStructFieldHeadStringTagMapPtr opType = 203 opStructFieldPtrHeadOmitEmptyMarshalJSONPtr opType = 203
opStructFieldPtrHeadMapPtr opType = 204 opStructFieldPtrHeadStringTagMarshalJSONPtr opType = 204
opStructFieldPtrHeadOmitEmptyMapPtr opType = 205 opStructFieldHeadMarshalTextPtr opType = 205
opStructFieldPtrHeadStringTagMapPtr opType = 206 opStructFieldHeadOmitEmptyMarshalTextPtr opType = 206
opStructFieldHeadMarshalJSONPtr opType = 207 opStructFieldHeadStringTagMarshalTextPtr opType = 207
opStructFieldHeadOmitEmptyMarshalJSONPtr opType = 208 opStructFieldPtrHeadMarshalTextPtr opType = 208
opStructFieldHeadStringTagMarshalJSONPtr opType = 209 opStructFieldPtrHeadOmitEmptyMarshalTextPtr opType = 209
opStructFieldPtrHeadMarshalJSONPtr opType = 210 opStructFieldPtrHeadStringTagMarshalTextPtr opType = 210
opStructFieldPtrHeadOmitEmptyMarshalJSONPtr opType = 211 opStructFieldHeadInterfacePtr opType = 211
opStructFieldPtrHeadStringTagMarshalJSONPtr opType = 212 opStructFieldHeadOmitEmptyInterfacePtr opType = 212
opStructFieldHeadMarshalTextPtr opType = 213 opStructFieldHeadStringTagInterfacePtr opType = 213
opStructFieldHeadOmitEmptyMarshalTextPtr opType = 214 opStructFieldPtrHeadInterfacePtr opType = 214
opStructFieldHeadStringTagMarshalTextPtr opType = 215 opStructFieldPtrHeadOmitEmptyInterfacePtr opType = 215
opStructFieldPtrHeadMarshalTextPtr opType = 216 opStructFieldPtrHeadStringTagInterfacePtr opType = 216
opStructFieldPtrHeadOmitEmptyMarshalTextPtr opType = 217 opStructFieldHead opType = 217
opStructFieldPtrHeadStringTagMarshalTextPtr opType = 218 opStructFieldHeadOmitEmpty opType = 218
opStructFieldHeadInterfacePtr opType = 219 opStructFieldHeadStringTag opType = 219
opStructFieldHeadOmitEmptyInterfacePtr opType = 220 opStructFieldPtrHead opType = 220
opStructFieldHeadStringTagInterfacePtr opType = 221 opStructFieldPtrHeadOmitEmpty opType = 221
opStructFieldPtrHeadInterfacePtr opType = 222 opStructFieldPtrHeadStringTag opType = 222
opStructFieldPtrHeadOmitEmptyInterfacePtr opType = 223 opStructFieldInt opType = 223
opStructFieldPtrHeadStringTagInterfacePtr opType = 224 opStructFieldOmitEmptyInt opType = 224
opStructFieldHead opType = 225 opStructFieldStringTagInt opType = 225
opStructFieldHeadOmitEmpty opType = 226 opStructFieldUint opType = 226
opStructFieldHeadStringTag opType = 227 opStructFieldOmitEmptyUint opType = 227
opStructFieldPtrHead opType = 228 opStructFieldStringTagUint opType = 228
opStructFieldPtrHeadOmitEmpty opType = 229 opStructFieldFloat32 opType = 229
opStructFieldPtrHeadStringTag opType = 230 opStructFieldOmitEmptyFloat32 opType = 230
opStructFieldInt opType = 231 opStructFieldStringTagFloat32 opType = 231
opStructFieldOmitEmptyInt opType = 232 opStructFieldFloat64 opType = 232
opStructFieldStringTagInt opType = 233 opStructFieldOmitEmptyFloat64 opType = 233
opStructFieldUint opType = 234 opStructFieldStringTagFloat64 opType = 234
opStructFieldOmitEmptyUint opType = 235 opStructFieldBool opType = 235
opStructFieldStringTagUint opType = 236 opStructFieldOmitEmptyBool opType = 236
opStructFieldFloat32 opType = 237 opStructFieldStringTagBool opType = 237
opStructFieldOmitEmptyFloat32 opType = 238 opStructFieldString opType = 238
opStructFieldStringTagFloat32 opType = 239 opStructFieldOmitEmptyString opType = 239
opStructFieldFloat64 opType = 240 opStructFieldStringTagString opType = 240
opStructFieldOmitEmptyFloat64 opType = 241 opStructFieldBytes opType = 241
opStructFieldStringTagFloat64 opType = 242 opStructFieldOmitEmptyBytes opType = 242
opStructFieldBool opType = 243 opStructFieldStringTagBytes opType = 243
opStructFieldOmitEmptyBool opType = 244 opStructFieldArray opType = 244
opStructFieldStringTagBool opType = 245 opStructFieldOmitEmptyArray opType = 245
opStructFieldString opType = 246 opStructFieldStringTagArray opType = 246
opStructFieldOmitEmptyString opType = 247 opStructFieldMap opType = 247
opStructFieldStringTagString opType = 248 opStructFieldOmitEmptyMap opType = 248
opStructFieldBytes opType = 249 opStructFieldStringTagMap opType = 249
opStructFieldOmitEmptyBytes opType = 250 opStructFieldSlice opType = 250
opStructFieldStringTagBytes opType = 251 opStructFieldOmitEmptySlice opType = 251
opStructFieldArray opType = 252 opStructFieldStringTagSlice opType = 252
opStructFieldOmitEmptyArray opType = 253 opStructFieldStruct opType = 253
opStructFieldStringTagArray opType = 254 opStructFieldOmitEmptyStruct opType = 254
opStructFieldMap opType = 255 opStructFieldStringTagStruct opType = 255
opStructFieldOmitEmptyMap opType = 256 opStructFieldMarshalJSON opType = 256
opStructFieldStringTagMap opType = 257 opStructFieldOmitEmptyMarshalJSON opType = 257
opStructFieldMapLoad opType = 258 opStructFieldStringTagMarshalJSON opType = 258
opStructFieldOmitEmptyMapLoad opType = 259 opStructFieldMarshalText opType = 259
opStructFieldStringTagMapLoad opType = 260 opStructFieldOmitEmptyMarshalText opType = 260
opStructFieldSlice opType = 261 opStructFieldStringTagMarshalText opType = 261
opStructFieldOmitEmptySlice opType = 262 opStructFieldRecursive opType = 262
opStructFieldStringTagSlice opType = 263 opStructFieldOmitEmptyRecursive opType = 263
opStructFieldStruct opType = 264 opStructFieldStringTagRecursive opType = 264
opStructFieldOmitEmptyStruct opType = 265 opStructFieldIntString opType = 265
opStructFieldStringTagStruct opType = 266 opStructFieldOmitEmptyIntString opType = 266
opStructFieldMarshalJSON opType = 267 opStructFieldStringTagIntString opType = 267
opStructFieldOmitEmptyMarshalJSON opType = 268 opStructFieldUintString opType = 268
opStructFieldStringTagMarshalJSON opType = 269 opStructFieldOmitEmptyUintString opType = 269
opStructFieldMarshalText opType = 270 opStructFieldStringTagUintString opType = 270
opStructFieldOmitEmptyMarshalText opType = 271 opStructFieldIntPtr opType = 271
opStructFieldStringTagMarshalText opType = 272 opStructFieldOmitEmptyIntPtr opType = 272
opStructFieldRecursive opType = 273 opStructFieldStringTagIntPtr opType = 273
opStructFieldOmitEmptyRecursive opType = 274 opStructFieldUintPtr opType = 274
opStructFieldStringTagRecursive opType = 275 opStructFieldOmitEmptyUintPtr opType = 275
opStructFieldIntString opType = 276 opStructFieldStringTagUintPtr opType = 276
opStructFieldOmitEmptyIntString opType = 277 opStructFieldFloat32Ptr opType = 277
opStructFieldStringTagIntString opType = 278 opStructFieldOmitEmptyFloat32Ptr opType = 278
opStructFieldUintString opType = 279 opStructFieldStringTagFloat32Ptr opType = 279
opStructFieldOmitEmptyUintString opType = 280 opStructFieldFloat64Ptr opType = 280
opStructFieldStringTagUintString opType = 281 opStructFieldOmitEmptyFloat64Ptr opType = 281
opStructFieldIntPtr opType = 282 opStructFieldStringTagFloat64Ptr opType = 282
opStructFieldOmitEmptyIntPtr opType = 283 opStructFieldBoolPtr opType = 283
opStructFieldStringTagIntPtr opType = 284 opStructFieldOmitEmptyBoolPtr opType = 284
opStructFieldUintPtr opType = 285 opStructFieldStringTagBoolPtr opType = 285
opStructFieldOmitEmptyUintPtr opType = 286 opStructFieldStringPtr opType = 286
opStructFieldStringTagUintPtr opType = 287 opStructFieldOmitEmptyStringPtr opType = 287
opStructFieldFloat32Ptr opType = 288 opStructFieldStringTagStringPtr opType = 288
opStructFieldOmitEmptyFloat32Ptr opType = 289 opStructFieldBytesPtr opType = 289
opStructFieldStringTagFloat32Ptr opType = 290 opStructFieldOmitEmptyBytesPtr opType = 290
opStructFieldFloat64Ptr opType = 291 opStructFieldStringTagBytesPtr opType = 291
opStructFieldOmitEmptyFloat64Ptr opType = 292 opStructFieldArrayPtr opType = 292
opStructFieldStringTagFloat64Ptr opType = 293 opStructFieldOmitEmptyArrayPtr opType = 293
opStructFieldBoolPtr opType = 294 opStructFieldStringTagArrayPtr opType = 294
opStructFieldOmitEmptyBoolPtr opType = 295 opStructFieldSlicePtr opType = 295
opStructFieldStringTagBoolPtr opType = 296 opStructFieldOmitEmptySlicePtr opType = 296
opStructFieldStringPtr opType = 297 opStructFieldStringTagSlicePtr opType = 297
opStructFieldOmitEmptyStringPtr opType = 298 opStructFieldMapPtr opType = 298
opStructFieldStringTagStringPtr opType = 299 opStructFieldOmitEmptyMapPtr opType = 299
opStructFieldBytesPtr opType = 300 opStructFieldStringTagMapPtr opType = 300
opStructFieldOmitEmptyBytesPtr opType = 301 opStructFieldMarshalJSONPtr opType = 301
opStructFieldStringTagBytesPtr opType = 302 opStructFieldOmitEmptyMarshalJSONPtr opType = 302
opStructFieldArrayPtr opType = 303 opStructFieldStringTagMarshalJSONPtr opType = 303
opStructFieldOmitEmptyArrayPtr opType = 304 opStructFieldMarshalTextPtr opType = 304
opStructFieldStringTagArrayPtr opType = 305 opStructFieldOmitEmptyMarshalTextPtr opType = 305
opStructFieldSlicePtr opType = 306 opStructFieldStringTagMarshalTextPtr opType = 306
opStructFieldOmitEmptySlicePtr opType = 307 opStructFieldInterfacePtr opType = 307
opStructFieldStringTagSlicePtr opType = 308 opStructFieldOmitEmptyInterfacePtr opType = 308
opStructFieldMapPtr opType = 309 opStructFieldStringTagInterfacePtr opType = 309
opStructFieldOmitEmptyMapPtr opType = 310 opStructField opType = 310
opStructFieldStringTagMapPtr opType = 311 opStructFieldOmitEmpty opType = 311
opStructFieldMarshalJSONPtr opType = 312 opStructFieldStringTag opType = 312
opStructFieldOmitEmptyMarshalJSONPtr opType = 313 opStructEndInt opType = 313
opStructFieldStringTagMarshalJSONPtr opType = 314 opStructEndOmitEmptyInt opType = 314
opStructFieldMarshalTextPtr opType = 315 opStructEndStringTagInt opType = 315
opStructFieldOmitEmptyMarshalTextPtr opType = 316 opStructEndUint opType = 316
opStructFieldStringTagMarshalTextPtr opType = 317 opStructEndOmitEmptyUint opType = 317
opStructFieldInterfacePtr opType = 318 opStructEndStringTagUint opType = 318
opStructFieldOmitEmptyInterfacePtr opType = 319 opStructEndFloat32 opType = 319
opStructFieldStringTagInterfacePtr opType = 320 opStructEndOmitEmptyFloat32 opType = 320
opStructField opType = 321 opStructEndStringTagFloat32 opType = 321
opStructFieldOmitEmpty opType = 322 opStructEndFloat64 opType = 322
opStructFieldStringTag opType = 323 opStructEndOmitEmptyFloat64 opType = 323
opStructEndInt opType = 324 opStructEndStringTagFloat64 opType = 324
opStructEndOmitEmptyInt opType = 325 opStructEndBool opType = 325
opStructEndStringTagInt opType = 326 opStructEndOmitEmptyBool opType = 326
opStructEndUint opType = 327 opStructEndStringTagBool opType = 327
opStructEndOmitEmptyUint opType = 328 opStructEndString opType = 328
opStructEndStringTagUint opType = 329 opStructEndOmitEmptyString opType = 329
opStructEndFloat32 opType = 330 opStructEndStringTagString opType = 330
opStructEndOmitEmptyFloat32 opType = 331 opStructEndBytes opType = 331
opStructEndStringTagFloat32 opType = 332 opStructEndOmitEmptyBytes opType = 332
opStructEndFloat64 opType = 333 opStructEndStringTagBytes opType = 333
opStructEndOmitEmptyFloat64 opType = 334 opStructEndArray opType = 334
opStructEndStringTagFloat64 opType = 335 opStructEndOmitEmptyArray opType = 335
opStructEndBool opType = 336 opStructEndStringTagArray opType = 336
opStructEndOmitEmptyBool opType = 337 opStructEndMap opType = 337
opStructEndStringTagBool opType = 338 opStructEndOmitEmptyMap opType = 338
opStructEndString opType = 339 opStructEndStringTagMap opType = 339
opStructEndOmitEmptyString opType = 340 opStructEndSlice opType = 340
opStructEndStringTagString opType = 341 opStructEndOmitEmptySlice opType = 341
opStructEndBytes opType = 342 opStructEndStringTagSlice opType = 342
opStructEndOmitEmptyBytes opType = 343 opStructEndStruct opType = 343
opStructEndStringTagBytes opType = 344 opStructEndOmitEmptyStruct opType = 344
opStructEndArray opType = 345 opStructEndStringTagStruct opType = 345
opStructEndOmitEmptyArray opType = 346 opStructEndMarshalJSON opType = 346
opStructEndStringTagArray opType = 347 opStructEndOmitEmptyMarshalJSON opType = 347
opStructEndMap opType = 348 opStructEndStringTagMarshalJSON opType = 348
opStructEndOmitEmptyMap opType = 349 opStructEndMarshalText opType = 349
opStructEndStringTagMap opType = 350 opStructEndOmitEmptyMarshalText opType = 350
opStructEndMapLoad opType = 351 opStructEndStringTagMarshalText opType = 351
opStructEndOmitEmptyMapLoad opType = 352 opStructEndRecursive opType = 352
opStructEndStringTagMapLoad opType = 353 opStructEndOmitEmptyRecursive opType = 353
opStructEndSlice opType = 354 opStructEndStringTagRecursive opType = 354
opStructEndOmitEmptySlice opType = 355 opStructEndIntString opType = 355
opStructEndStringTagSlice opType = 356 opStructEndOmitEmptyIntString opType = 356
opStructEndStruct opType = 357 opStructEndStringTagIntString opType = 357
opStructEndOmitEmptyStruct opType = 358 opStructEndUintString opType = 358
opStructEndStringTagStruct opType = 359 opStructEndOmitEmptyUintString opType = 359
opStructEndMarshalJSON opType = 360 opStructEndStringTagUintString opType = 360
opStructEndOmitEmptyMarshalJSON opType = 361 opStructEndIntPtr opType = 361
opStructEndStringTagMarshalJSON opType = 362 opStructEndOmitEmptyIntPtr opType = 362
opStructEndMarshalText opType = 363 opStructEndStringTagIntPtr opType = 363
opStructEndOmitEmptyMarshalText opType = 364 opStructEndUintPtr opType = 364
opStructEndStringTagMarshalText opType = 365 opStructEndOmitEmptyUintPtr opType = 365
opStructEndRecursive opType = 366 opStructEndStringTagUintPtr opType = 366
opStructEndOmitEmptyRecursive opType = 367 opStructEndFloat32Ptr opType = 367
opStructEndStringTagRecursive opType = 368 opStructEndOmitEmptyFloat32Ptr opType = 368
opStructEndIntString opType = 369 opStructEndStringTagFloat32Ptr opType = 369
opStructEndOmitEmptyIntString opType = 370 opStructEndFloat64Ptr opType = 370
opStructEndStringTagIntString opType = 371 opStructEndOmitEmptyFloat64Ptr opType = 371
opStructEndUintString opType = 372 opStructEndStringTagFloat64Ptr opType = 372
opStructEndOmitEmptyUintString opType = 373 opStructEndBoolPtr opType = 373
opStructEndStringTagUintString opType = 374 opStructEndOmitEmptyBoolPtr opType = 374
opStructEndIntPtr opType = 375 opStructEndStringTagBoolPtr opType = 375
opStructEndOmitEmptyIntPtr opType = 376 opStructEndStringPtr opType = 376
opStructEndStringTagIntPtr opType = 377 opStructEndOmitEmptyStringPtr opType = 377
opStructEndUintPtr opType = 378 opStructEndStringTagStringPtr opType = 378
opStructEndOmitEmptyUintPtr opType = 379 opStructEndBytesPtr opType = 379
opStructEndStringTagUintPtr opType = 380 opStructEndOmitEmptyBytesPtr opType = 380
opStructEndFloat32Ptr opType = 381 opStructEndStringTagBytesPtr opType = 381
opStructEndOmitEmptyFloat32Ptr opType = 382 opStructEndArrayPtr opType = 382
opStructEndStringTagFloat32Ptr opType = 383 opStructEndOmitEmptyArrayPtr opType = 383
opStructEndFloat64Ptr opType = 384 opStructEndStringTagArrayPtr opType = 384
opStructEndOmitEmptyFloat64Ptr opType = 385 opStructEndSlicePtr opType = 385
opStructEndStringTagFloat64Ptr opType = 386 opStructEndOmitEmptySlicePtr opType = 386
opStructEndBoolPtr opType = 387 opStructEndStringTagSlicePtr opType = 387
opStructEndOmitEmptyBoolPtr opType = 388 opStructEndMapPtr opType = 388
opStructEndStringTagBoolPtr opType = 389 opStructEndOmitEmptyMapPtr opType = 389
opStructEndStringPtr opType = 390 opStructEndStringTagMapPtr opType = 390
opStructEndOmitEmptyStringPtr opType = 391 opStructEndMarshalJSONPtr opType = 391
opStructEndStringTagStringPtr opType = 392 opStructEndOmitEmptyMarshalJSONPtr opType = 392
opStructEndBytesPtr opType = 393 opStructEndStringTagMarshalJSONPtr opType = 393
opStructEndOmitEmptyBytesPtr opType = 394 opStructEndMarshalTextPtr opType = 394
opStructEndStringTagBytesPtr opType = 395 opStructEndOmitEmptyMarshalTextPtr opType = 395
opStructEndArrayPtr opType = 396 opStructEndStringTagMarshalTextPtr opType = 396
opStructEndOmitEmptyArrayPtr opType = 397 opStructEndInterfacePtr opType = 397
opStructEndStringTagArrayPtr opType = 398 opStructEndOmitEmptyInterfacePtr opType = 398
opStructEndSlicePtr opType = 399 opStructEndStringTagInterfacePtr opType = 399
opStructEndOmitEmptySlicePtr opType = 400 opStructEnd opType = 400
opStructEndStringTagSlicePtr opType = 401 opStructEndOmitEmpty opType = 401
opStructEndMapPtr opType = 402 opStructEndStringTag opType = 402
opStructEndOmitEmptyMapPtr opType = 403
opStructEndStringTagMapPtr opType = 404
opStructEndMarshalJSONPtr opType = 405
opStructEndOmitEmptyMarshalJSONPtr opType = 406
opStructEndStringTagMarshalJSONPtr opType = 407
opStructEndMarshalTextPtr opType = 408
opStructEndOmitEmptyMarshalTextPtr opType = 409
opStructEndStringTagMarshalTextPtr opType = 410
opStructEndInterfacePtr opType = 411
opStructEndOmitEmptyInterfacePtr opType = 412
opStructEndStringTagInterfacePtr opType = 413
opStructEnd opType = 414
opStructEndOmitEmpty opType = 415
opStructEndStringTag opType = 416
) )
func (t opType) String() string { func (t opType) String() string {
if int(t) >= 417 { if int(t) >= 403 {
return "" return ""
} }
return opTypeStrings[int(t)] return opTypeStrings[int(t)]

View File

@ -335,44 +335,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
code = code.end.next code = code.end.next
} }
} }
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
}
code = code.next
} else {
b = append(b, '{', '}', ',')
code = code.end.next
}
}
case opMapKey: case opMapKey:
idx := load(ctxptr, code.elemIdx) idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length) length := load(ctxptr, code.length)
@ -3259,27 +3221,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} else { } else {
code = code.nextField code = code.nextField
} }
case opStructFieldMapLoad:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldStruct: case opStructFieldStruct:
b = append(b, code.key...) b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)

View File

@ -1,12 +1,9 @@
package json package json
import ( import (
"bytes"
"encoding"
"fmt" "fmt"
"math" "math"
"reflect" "reflect"
"runtime"
"sort" "sort"
"strings" "strings"
"unsafe" "unsafe"
@ -17,7 +14,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
ptrOffset := uintptr(0) ptrOffset := uintptr(0)
ctxptr := ctx.ptr() ctxptr := ctx.ptr()
code := codeSet.code code := codeSet.code
//fmt.Println(code.dump()) fmt.Println(code.dump())
for { for {
switch code.op { switch code.op {
@ -142,57 +139,57 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = bb b = bb
code = code.next code = code.next
case opMarshalJSON: case opMarshalJSONPtr:
ptr := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if ptr == 0 { if p == 0 {
b = encodeNull(b) b = encodeNull(b)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
break break
} }
v := ptrToInterface(code, ptr) store(ctxptr, code.idx, ptrToPtr(p))
bb, err := v.(Marshaler).MarshalJSON() fallthrough
case opMarshalJSON:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
bb, err := encodeMarshalJSON(b, ptrToInterface(code, p))
if err != nil { if err != nil {
return nil, errMarshaler(code, err)
}
runtime.KeepAlive(v)
if len(bb) == 0 {
return nil, errUnexpectedEndOfJSON(
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
0,
)
}
buf := bytes.NewBuffer(b)
//TODO: we should validate buffer with `compact`
if err := compact(buf, bb, false); err != nil {
return nil, err return nil, err
} }
b = buf.Bytes() b = encodeComma(bb)
b = encodeComma(b)
code = code.next code = code.next
case opMarshalText: case opMarshalTextPtr:
ptr := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
isPtr := code.typ.Kind() == reflect.Ptr if p == 0 {
p := ptrToUnsafePtr(ptr) b = encodeNull(b)
if p == nil || isPtr && *(*unsafe.Pointer)(p) == nil {
b = append(b, '"', '"', ',')
} else {
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
typ: code.typ,
ptr: p,
}))
bytes, err := v.(encoding.TextMarshaler).MarshalText()
if err != nil {
return nil, errMarshaler(code, err)
}
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b) b = encodeComma(b)
break
} }
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
b = append(b, `""`...)
b = encodeComma(b)
code = code.next
break
}
bb, err := encodeMarshalText(b, ptrToInterface(code, p))
if err != nil {
return nil, err
}
b = encodeComma(bb)
code = code.next code = code.next
case opSlice: 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 || slice.data == nil {
b = encodeNull(b) b = encodeNull(b)
b = encodeComma(b) b = encodeComma(b)
code = code.end.next code = code.end.next
@ -287,44 +284,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
code = code.end.next code = code.end.next
} }
} }
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
}
code = code.next
} else {
b = append(b, '{', '}', ',')
code = code.end.next
}
}
case opMapKey: case opMapKey:
idx := load(ctxptr, code.elemIdx) idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length) length := load(ctxptr, code.length)
@ -3225,27 +3184,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} else { } else {
code = code.nextField code = code.nextField
} }
case opStructFieldMapLoad:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldStruct: case opStructFieldStruct:
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)

View File

@ -17,6 +17,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
ptrOffset := uintptr(0) ptrOffset := uintptr(0)
ctxptr := ctx.ptr() ctxptr := ctx.ptr()
code := codeSet.code code := codeSet.code
fmt.Println(code.dump())
for { for {
switch code.op { switch code.op {
@ -337,50 +338,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
key := mapiterkey(iter) key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key)) store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, '{', '}', ',', '\n')
code = code.end.next
}
}
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if uintptr(uptr) == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{', '\n')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
} else {
b = appendIndent(ctx, b, code.next.indent)
}
code = code.next code = code.next
} else { } else {
b = appendIndent(ctx, b, code.indent) b = appendIndent(ctx, b, code.indent)
@ -3524,41 +3481,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} else { } else {
code = code.nextField code = code.nextField
} }
case opStructFieldMapLoad:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
b = encodeNull(b)
code = code.nextField
} else {
p = ptrToPtr(p)
mlen := maplen(ptrToUnsafePtr(p))
if mlen == 0 {
b = append(b, '{', '}', ',', '\n')
code = code.nextField
} else {
code = code.next
}
}
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
}
}
case opStructFieldStruct: case opStructFieldStruct:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset p := ptr + code.offset

View File

@ -337,50 +337,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
key := mapiterkey(iter) key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key)) store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, '{', '}', ',', '\n')
code = code.end.next
}
}
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if uintptr(uptr) == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{', '\n')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
} else {
b = appendIndent(ctx, b, code.next.indent)
}
code = code.next code = code.next
} else { } else {
b = appendIndent(ctx, b, code.indent) b = appendIndent(ctx, b, code.indent)
@ -3525,41 +3481,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} else { } else {
code = code.nextField code = code.nextField
} }
case opStructFieldMapLoad:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
b = encodeNull(b)
code = code.nextField
} else {
p = ptrToPtr(p)
mlen := maplen(ptrToUnsafePtr(p))
if mlen == 0 {
b = append(b, '{', '}', ',', '\n')
code = code.nextField
} else {
code = code.next
}
}
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
code = code.next
}
}
case opStructFieldStruct: case opStructFieldStruct:
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset p := ptr + code.offset